picocms / Pico

Pico is a stupidly simple, blazing fast, flat file CMS.
http://picocms.org/
MIT License
3.81k stars 616 forks source link

Alternative to Parsedown? #576

Closed mo8it closed 3 years ago

mo8it commented 3 years ago

I use PicoCMS on Nextcloud and I love it! But I faced one issue which is descriped here: https://github.com/erusev/parsedown-extra/issues/87

parsedown-extra has many very old issues which are not fixed. There are also no new commits in 2020. Are there any plans to get an alternative to parsedown? What about forking it?

Thanks for your great work.

PhrozenByte commented 3 years ago

Whether we're going to switch to another Markdown parser or not is something we'll definitely decide for Pico 3.0, see #535

We'll also think about changing Pico's Markdown parser. Unfortunately Parsedown's development process got very unreliable lately. However, there's a lot to consider - not just BC, but also performance-wise (Parsedown is by far the most performant Markdown parser I know).

Forking Parsedown or even writing a new Markdown parser is definitely out of what we can carry out. Furthermore I don't believe that re-inventing the wheel is feasible - there are a lot of Markdown parsers out there.

However, since we don't want to force users to enable caching (this would make Pico's install process way more complex), we must use a Markdown parser that is able to parse Markdown files on-the-fly (performance-wise, obviously they can all parse files on-the-fly).

Another thing to keep in mind is compatibility. There's no real Markdown standard besides CommonMark. However, CommonMark wasn't really widely adopted and the project is kinda stuttering. For historic reasons basically all Markdown parsers use different approaches and interpret Markdown files differently. This will cause compatibility issues - which might get very frustrating to deal with for users. Switching from one non-standard Markdown parser (Parsedown) to another non-standard parser is nothing I'd like to do. However, likely it's our only choice. There's only one fully CommonMark compatible parser and that's the CommonMark reference parser - that is very slow unfortunately.

So, in the end we'll have to consider performance, standards compatibility and backwards compatibility with Parsedown. This is a very, very complex topic :unamused:

As I said, more opinions about this topic are very welcome! :heart:

mo8it commented 3 years ago

Thanks for the detailed reply.

I did a work around by preprossesing the files with my own python script. I also extended markdown with table of content from headings. Here you can see the result: https://nextcloud.jinext.xyz/sites/open2privacy

Is the team interested in the python script or at least in the part to fix the issue with footnotes? Maybe you can do a hook or something like that. Or maybe you can make a plugin from it? I would love to help the community.

PhrozenByte commented 3 years ago

Sorry for the late response, holidays :smile:

Sharing your work with the community is always welcome! :heart: Unfortunately we can't really officially incorporate a Python script in Pico (Pico uses PHP), however, if users experience the same problem as you, I'm pretty sure they would love to use your work to fix it. Depending on how big your Python script is, simply paste it here, create a Gist or create a new repo (GitHub is no requirement :wink:). We can reference it here and in our Wiki.

coofercat commented 3 years ago

I'd like to chime in with a vote to get off Parsedown. It seems to have an issue that's not getting fixed that bit me just now, and the folks over at OctoberCMS (https://github.com/octobercms/october/issues/3480). For any searchers looking for a solution, this seems to work: https://github.com/tmoravec/parsedown-extra/commit/6ce5c079f6502f7dd857d651e02c8ee5022a1493

The real solution is of course to fix it properly - which doesn't look like it's going to happen in the upstream library, so maybe it is indeed time to switch to a new one (although I can sympathise with the issues this raises).

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! :+1: