-
-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to Pandoc (commonmark-hs) #137
Comments
According to jgm/commonmark-hs#1 Pandoc will eventually use I'm inclined towards going with |
What's the goal in making the switch? I understood we wanted to open the possibility of using Pandoc features like citations or image properties, in which case we'd want to use Pandoc itself rather than |
That's correct; however that cannot be at the expense of dropping GHCJS support (I have another project in mind that will need this) or adding a buggy and less performant parser (see the link above). Fortunately, commonmark-hs will eventually be used as the parser in Pandoc; so by porting to commonmark-hs we will eventually be supporting Pandoc. As for things like citations or image properties, I imagine they will eventually get the corresponding commonmark extension ported (there are already some extensions here of which |
Ok, if I understand correctly then, the move to In fact I don't think we care about Pandoc at all: as you say, commonmark-hs has a powerful extension mechanism and has already quite a few supported. If we ever want some Pandoc feature, commonmark-hs knows how to produce a Pandoc AST so we don't even care whether Pandoc ever uses commonmark-hs as its main markdown parser. Potential issue: it looks like commonmark-hs does not support yaml headers yet jgm/commonmark-hs#17 . Note that |
But on the other hand, if we would directly use pandoc (+ lua-filters), we could also support some other popular file-formats like I like for example the possibility to evaluate code blocks in emacs-org-mode: e.g.
|
I am also strongly in favor of using pandoc for the markdown. pandoc is a very viable option for writing complete papers, thesises or even books. Not being able reuse my multi-line formulas because they are wrapped as mathjax code blocks is kind of a killer for using neuron. |
@maralorn @michelk See here; the current Pandoc parser is infeasible because I need the neuron Markdown parser to work in GHCJS for other projects of mine. Fortunately though, as @Nadrieril expressed here, commonmark-hs does provide a way to parse directly into the Pandoc AST. So any code that operates on the AST could immediately be supported, with extensions written for code operating on pre-parsed text. Pandoc's author explains the overall migration plan here:
|
A possible solution for people who want to write their zettels in orgmode or use citations or whatnot, would be to make neuron more library-like, so that people can reuse the cool bits but e.g. provide their own code for getting input data. If neuron uses the Pandoc AST internally, it would be quite flexible. Somewhat like a more opiniated rib, maybe. |
@srid you're mentioning GHCJS. I have also an related project in mind: What about a flashcard system, similar to Just an idea... |
I read something similar here. |
@Nadrieril That's an interesting idea, one that is worth exploring I think; but we can do this in the neuron executable (without opening up the library-based hydra). I'm currently playing with commonmark-hs and am keeping this in mind in the background. Discussing with @felko over at zulip chat ... my thoughts are: If we support multiple markup, then commonmark would be one of them, to be used by @michelk Yup, a flashcard app is something I wanted to write myself, using reflex. |
The Pandoc AST feature branch (#166) is ready to use if anybody is interested in testing. I'll merge it to master soonish. It parses text using commonmark, but uses the pandoc AST (thus neuron can potentially support other formats). |
Thank you. I only had to change math-blocks from
to
and from
and we don't need to escape Thanks a lot. |
That is exactly how it should be! So great! |
Cool! I'm gonna finish #172 (which switches to reflex-dom; but I'll make sure to test that mathjax/etc. continue to render as before) before merging all of this to |
This is now merged to Note that as of #172 neuron uses reflex-dom (not pandoc's native HTML writer) to render the HTML from the AST. This README section contains instructions on how to hack on the renderer, for those interested in improving it. |
Oh, also note that installation instructions have changed. In particular, you would need to run this command: nix-env -if https://github.com/srid/neuron/archive/master.tar.gz You can simply run this again, in order to upgrade your current install. Just make sure that you are still using the cache. |
Requests for Pandoc arose a few times.
Let's switch to
Pandoccommonmark-hs (which Pandoc will eventually be using as its markdown parser).In order to migrate away from MMark to Pandoc, we will have to rewrite the
replaceLink
extension, which I've refactored to be general and small enough:neuron/src/Text/MMark/Extension/ReplaceLink.hs
Lines 16 to 25 in fdf18dd
Essentially the extension takes a
Map
of links, and for each link it renders the given HTML in the final output (the Map is computed ahead by neuron).The following should continue to work:
z:
,zquery:
,<ID>
, etc linkstitle
,date
andtags
)The text was updated successfully, but these errors were encountered: