-
Notifications
You must be signed in to change notification settings - Fork 0
Implement a MyST parser for Nikola #14
Comments
OK, some written points about the research I have made so far...
@choldgraf, thoughts are welcome 😉 (hopefully this makes more sense now that is written) |
Nice - thanks for this write up! My intuition is that the most useful next steps would be to improve the <div class="directive <directivename>">
<p><Directive content></p>
</div> at least that way the output could be styled etc. Over time the mapping from specific directives to HTML could be extended somehow (e.g., maybe somebody could define a Directive class and their own mappings, and if the class doesn't exist it falls back to defaults?) If you think that going the This could also be a good opportunity to improve the |
Thanks for the feedback, @choldgraf! |
Does that match your intuition as well? 🙂 |
It depends... 😜 |
OK, I have dived into the direct-to-html path a little bit more... some thoughts for discussion...
I think I disagree with @choldgraf here about where the support for roles and directives should potentially live... let me elaborate... The to_html function, as I have said before, it is using the default_parser. And the But the fact it is not configurable makes sense when you look at the core of the parsing process: https://github.com/executablebooks/MyST-Parser/blob/master/myst_parser/main.py#L158-L227 There, you can see the parser has a chained markdown-it-py object. A chain composed of multiple markdown-it-py plugins on top of the base object. IMHO, the design is suggesting to add new functionality as a markdown-it-py plugin and then use the base RendererHTML that should know how to render that properly. This is in fact in alignment with the recently created markdown-it-docutils which is, IIUC, a markdown-it plugin that provides support for roles and directives independent from docutils/sphinx, but all of that in the JS world instead of the Py one. So, eventually, there should be a markdown-it-py plugin providing the same functionality and then it will be just a matter to chain that plugin only if the renderer configured is "html". if config.renderer == "html":
md.use(docutils_plugin) Or, alternatively, if we do not want to modify the myst parser, we just recreate it and specifically add the non yet created docutils plugin (related: executablebooks/MyST-Parser#348). So, in summary, I think any sort of basic support for directives as @choldgraf indicate above should be implemented as a markdown-it-py plugin. Thoughts? Since @choldgraf suggested any implementation of directives should live in the myst parser, I am worried I am misunderstanding something basic here... |
I was looking into the MyST Parser and markdown-it-py code as well and came to the same conclusion on my flight haha. I think you're right that we should look at the https://github.com/executablebooks/markdown-it-docutils project for inspiration about how we'd accomplish the same thing on the python side. In general, we should assume that the JS and Python implementations of MyST will behave very similarly to one another so this makes sense to me. |
Note: I have deleted a duplicated comment.
That's great! I have started to look into markdown-it-py and their plugins internals...
Yep, I have started to look into that one too... but I want to see it a little bit more consolidated before deep diving into it.
Yep, totally...
Super! Thanks for confirming I was not missing something big, je je 😉 |
Update: We had agreed with @choldgraf about writing a series of blogposts to navigate the Nikola-Myst story and the underlying issue about how to natively support roles and directives in Myst without docutils/sphinx intervention. The ultimate idea is to showcase the problem, bring attention from the community, and foster the discussion about the topic. I have started on the content of those blog posts and the general outline (that needs to be split on multiple blog posts) would be something like this (feedback welcome): Myst support for NikolaCurrent supportExisting Myst plugin for NikolaProblems with current supportPros and Cons/LimitationsPossible AlternativesPython sideJS sideMyst support for roles and directivesHow it is now...Why do we want to go independent from docutils/sphinx?Discuss possible implementationsSome roles and directives on Nikola via MystShowcase a simple role or directive implementation via the Python API.Showcase the JS alternative through templating via markdown-it-docutils (and maybe markdown-it-myst?) |
@choldgraf I have updated the first message to create some child tickets addressing each part of the proposed layout I shared above. |
Background
In order to learn a bit more about the MyST parser, it maybe a useful and insightful exercise to first attempt at utilizing the MyST parser outside of the Jupyter Book context. @damianavila and I discussed using Nikola as a test-case, since Damian is familiar with Nikola, and also because "blogging functionality" is a highly-requested feature in Jupyter Book.
Update (by Damián)
@damianavila explored the space and in ongoing conversations with @choldgraf, we agreed we may publish some blog post storytelling the insights we gained in this exploration as a way to further push some discussion about fundamental pieces on the Myst ecosystem.
The current outline for the proposed blog post lives here: #14 (comment)
Steps:
The text was updated successfully, but these errors were encountered: