3
votes

I am trying to write a jekyll plugin that will take a normal markdown file and provide some extra functionality on top of it. In particular, I need to do some (not actually) fancy things with tables. I know you can write straight HTML into a markdown file, but there is a requirement that the content folks don't want to / can't edit HTML.

As an extra wrench in the works, the mobile layout has a UX requirement that I essentially have to render the table as a group of divs as opposed to a table.

My initial thought was to pass the {{page.content}} variable to a ruby function extending Liquid::Tag. From there I was planning on parsing the markdown file and either: 1. If normal non-table markdown, use as normal 2. If table markdown, look for custom identifier in markdown, do what needs to be done (e.g. add class, etc)

If I do something like this:

def render(context)
    content = Liquid::Template.parse(@markup).render context
end

It renders the context as a normal markdown file. However, I want to break up the context variable and work with the pieces before rendering. I've tried a few different approaches that I've gotten from the jekyll docs and Stack Overflow and gotten nowhere.

Does anyone have any experience with this? I am heading down the right path? For what it's worth, Ruby/Jekyll/Liquid is fairly new to me, so if you think I may have missed something fairly basic and obvious then please let me know.

1
What is the markdown and what is the resulting html ?David Jacquel
The markdown is a table that you can generate from tablesgenerator.com/markdown_tables and the result is a basic HTML table. I am trying to provide functionality to the content team above and beyond what that does.JR Smith

1 Answers

2
votes

A markdown table tool for editors !

I don't know other way to simplify editor's work on Jekyll, but I'll be very interested in earing from your project. Good luck.