MinchinWeb / blog.minchin.ca

Source for the Pelican-powered blog at blog.minchin.ca
1 stars 0 forks source link

Move to CommonMark #133

Open MinchinWeb opened 11 months ago

MinchinWeb commented 11 months ago

I've been thinking for a while that I would like to move to a CommonMark Markdown parser. The goal would be to have consistence performance, backed by a spec that has worked through many of the edge cases. As well, the hope is to make it easier to move Markdown content between applications (like to/from Obsidian).

Also, Pelican has taken to installing a CommonMark parser (markdown-it-py) as a sub-dependency of rich, which Pelican has taken to using as a CLI output library. So we already have the parser installed!

One complication is that the original Python commonmark.py parser (available on PyPI as commonmark) has been deprecated in favour of markdown-it-py (available as markdown-it-py[plugins]).

Markdown-it-py does support plugins. This is another complication in that I use several Markdown plugins currently, and not entirely standard Markdown as is.

Another issue is how to deal with front matter; I think Pelican is using it's own standard.

Available, existing Pelican Plugins:

There doesn't appear to be anything in the pelican-plugins organization.

c.f. https://github.com/getpelican/pelican/issues/2984

MinchinWeb commented 11 months ago
MinchinWeb commented 11 months ago

Update todo list.

Also, a footnote plugin: mdit_py_plugins.footnote.footnote_plugin

MinchinWeb commented 11 months ago

Can now pull H1 tag if no title, but it has to be built in to the reader (no plugin provides both the metadata and the content).

MinchinWeb commented 11 months ago

Can now use Markdown-IT's front matter plugin to separate front matter from the body of the post. May need to do a lot of metadata wrangling now to get it to work as expected....

There is still an issue where if it pulls out the title, it strings it along with spaces between each letter.

MinchinWeb commented 10 months ago

Frontmatter is now processed as YAML; this is built in to the (WIP) Pelican reader.

Wikilinks are now handled by a dedicated plugin --> https://github.com/MinchinWeb/minchin.pelican.plugins.wikilinks

Backlinks can be handled by an existing plugin (by someone else!) --> https://github.com/renyuneyun/pelican-interrefs

MinchinWeb commented 10 months ago

https://github.com/MinchinWeb/minchin.pelican.plugins.wikilinks/issues/1

Re Wikilinks: they could be handled as a Markdown-IT plugin, that relies on Pelican to actually render the link targets (as a follow-on processing step). This would likely be better, as it would provide less false positives. To investigate.

MinchinWeb commented 9 months ago

Additional icons for checkboxes:

egberts commented 4 months ago

WOW! I was about to embark down on the Markdown-IT integration path for Pelican.

But I am spending time studying Pelican internals and writing up a flowchart on this.

egberts commented 4 months ago

Related?

https://github.com/getpelican/pelican/issues/3344

MinchinWeb commented 4 months ago

WOW! I was about to embark down on the Markdown-IT integration path for Pelican.

I wrote a (Pelican) plugin to do this -->

https://github.com/MinchinWeb/minchin.pelican.readers.commonmark

I've published this to PyPI; you should be able to use it as is. Please try it out, and let me know if you run into any issues or shortcomings. I use it regularly on my side.

One disappointment I discovered with using Markdown-IT-Py is that very few of the Markdown-IT plugins originally written in JS have been ported to Python yet.

egberts commented 4 months ago

And it WORKS! Nice job.

This is an evaluation mode, not an implementation. But nice job.