tajmone / pandoc-goodies

A tresure-box of resources for pandoc, pp and Texts word processor.
MIT License
211 stars 41 forks source link

native gfm task list as lua-filter #3

Closed robinrosenstock closed 5 years ago

robinrosenstock commented 6 years ago

Hi @tajmone !

I just wanted to inform you and the others, that there is now a lua-filter which implements the gfm task lists. It is maintained by john mcfarlane and works on the AST. Propably this is a better approach than to do it with pp. Maybe you could make a note about that in the readme here, that it may be better to use this lua-filter instead of your code?

I don't want to make your contributions bad, though, and I want to thank you again for your efforts.

tajmone commented 6 years ago

I just wanted to inform you and the others, that there is now a lua-filter which implements the gfm task lists.

I saw the notification about its release, but didn't have a chance to try out yet, but it's definitely great news!

Propably this is a better approach than to do it with pp.

Definitely better. And it should be possible to use it along with other PP macros too, so existing documents that use the PP macros for task lists will still work, while they are ported to the new Lua filter method. As for the CSS, that remains the same (and the PP macro !TaskListInlineCSS still comes handy when working with documents or templates that don't provide CSS styling for Task Lists!)

Maybe you could make a note about that in the readme here, that it may be better to use this lua-filter instead of your code?

I will, and thanks for reminding me about it — I've been absorbed on some other pending projects and didn't find time to update Pandoc-Goodies lately.

I don't want to make your contributions bad, though, and I want to thank you again for your efforts.

On the contrary, you're improving the project with your advise (and shielding me from my chronic forgetfulness).

tajmone commented 6 years ago

For the time being I've added a note in the PP macros "GFM Task-List" section, mentioning the task-list Lua filter as a better alternative, and providing links to it:

When I have more time, I'll carry out some tests with the filter, to see if the current "GitHub" HTML template styles for Task Lists work out-of-the-box with the html ouput of the filter, or if I need to tweak the SCSS source to cover styling of Task Lists created with either PP macros or the Lua filter.

Ideally, the GitHub HTML template show display Task Lists with the exact same styling, regardless of how they were generated. Probably some tweaking or extra class names will be needed to achieve this, even through from a quick peek at the Lua source it seems it adopts the same classes naming convention as GitHub.

I'd rather change the PP macros and the Template's Sass files to adapt them to the Lua filter output, in order to attain same styling in HTML and the current template, than create a tweaked version of the Lua filter.

In this respect, if you've had a chance to test it, and you have some suggestions regarding the compatibility status of the filter HTML output with the GitHub HTML5 template stylesheet, and/or if using the filter along with PP TaskList macros causes conflicts or differing styled checkboxes, please tell me about them.

robinrosenstock commented 6 years ago

Ideally, the GitHub HTML template show display Task Lists with the exact same styling, regardless of how they were generated. Probably some tweaking or extra class names will be needed to achieve this, even through from a quick peek at the Lua source it seems it adopts the same classes naming convention as GitHub.

I'd rather change the PP macros and the Template's Sass files to adapt them to the Lua filter output, in order to attain same styling in HTML and the current template, than create a tweaked version of the Lua filter.

It is not really clear to me what you mean with all of this. Why is this needed, especially with the templates and css you mentioned? Personally I'll just use the lua-filter and then ... all is ok, I guess. Why are you doing so much work?

tajmone commented 6 years ago

I'll just use the lua-filter and then ... all is ok, I guess.

maybe, but I haven't had the chance to try this. GitHub task lists are rendered via classes, not plain HTML tags. So, styling is needed to achieve the actual look and feel of Task List boxes, otherwise they look broken.

Why are you doing so much work?

In this repo I'm just sharing with others some code that I use in other personal projects I maintain (some public, most private). These projects rely heavily on some of the code published here (plus others not found here), and they consists of literally hundreds of document files. Macros and styling are an important part of that work, and even though most projects use different styles, I try my best to keep all that it's possible into commonly shared modules, which makes it easier to maintain.

The passage to pandoc v2 broke many documents, but having a comon code base allowed me to quickly fix issues and port all documents to work with v2 in a half day work.

Strange as it might sound, editing and creating script-automated documentation is one of the main areas of my job, so I often need to find workarounds to fit my needs to large scale projects. Maybe the Pandoc-Goodies project doesn't make much sense as it is right now, as I surely haven't managed to give it a specific goal or spend more than so much time docuemnting it. What I'm trying to do right now is sharing into the open source part of the code solutions that I've built for my everyday job, in the hope that others might benefit from it (I assume that people working in the same areas tend to bump into the same problems).

I am not in a position to share all of the code I employ in my work, for obvious reasons; but whenever it's possible to do so, I'm happy to do it.

Most of the stuff published here works out of the box, regardless of the choatic context. At the end of the day, a working template is a usable template. Other stuff might make less sense at a first glance 😢 — but it hopefully will, as I find the time to put the various bits and pieces together 😄 (as they are in the toolchain I work with).

virgilwashere commented 5 years ago

And even better,

https://github.com/pandoc/lua-filters/commit/8e33efbb32068bb4ead977ad380ba491271c2cef

Remove filter task-list

Task lists are now supported by pandoc, thereby rendering the task-list filter obsolete.

tajmone commented 5 years ago

Thanks for the update @virgilwashere !

tajmone commented 5 years ago

@geniusupgrader , you were right: current pandoc version doesn't need any CSS to show correctly the checkboxes of task-lists. Even when outputing to a non-standalone document, which contains no CSS, they show properly. The HTML generated is:

<ul>
<li><input type="checkbox" disabled="" />
Element 1/li>
<li><input type="checkbox" disabled="" checked="" />
Element 2</li>
</ul>

Anyhow, I'm now gradually updating the whole repo to latest pandoc and PP version. After over a year without updates some minor tweaks are required. Nothing huge, but a couple of macros stopped working as expected, CSS styles needed tweaking, and some macros are just obsolete.

Also, there are new features which could be exploited in both pandoc and PP.