Try to adopt Myst Spec where possible.
I've recently talks with a couple of the myst folks, and I'd like to see if we can adopt the myst AST, or at least something as close to it as possible.
See the structure of the Myst AST
The myst spec are published as json schema, I haven't found it as Python objects, so I've started to write a notebook to see if we can directly generate teh Python dataclasses to represent those nodes.
https://gist.github.com/Carreau/d5d80d644b4f43e601e67874619d855a
It a bit rough on the edges, and I'm ok if there is some manual edition.
Once this is done, the goal is to mostly replace the custom ast I have in here
Once the above is roughly done, we can also replace the serializers I have with something more straightforward : https://gist.github.com/Carreau/62350dabcd75b90eccffb9fca7c2c431,
This would allow to emit json that can be rendered by the MyST Js libraries.
I don't expect us to have custom nodes and variations, but the closer we are to another spec the better. The Myst folks would I think also welcome feedback on their AST if we need any changes.
If we also find a library that already goes from json schema to pyhton-implementation i'm all for it, I just hadn't found any that support json schema $ref.
Note, it look like we can render the Mdast directly using MystJS:
<html>
<head>
<script src="https://unpkg.com/mystjs"></script>
</head>
<body onload="init();">
<div id="output"></div>
<script>
function init() {
const myst = new MyST();
const html = myst.renderMdast({type: "text", value:"Hello"})
document.getElementById('output').innerHTML = html;
}
</script>
</body>
</html>
Are you aware of something equivalent of BlockVerbatim in the myst spec? The closest I have found is Code, but syntax of Code is different from BlockVerbatim, as in the three backticks.
Trying to replace BlockVerbatim for parsing this block in numpy docs: https://github.com/numpy/numpy/blob/b30653165c4a44b40be733217b26ac9a936772a5/numpy/distutils/init.py#L7-L11
UPDATE: Code and InlineCode seems to work fine for BlockVerbatim and Verbatim
UPDATE:
CodeandInlineCodeseems to work fine forBlockVerbatimandVerbatim
Perfect, That sounds good, and if it makes less nodes that's a plus !
Status of Nodes to replace/remove:
| Node | Replaced | Removed | Comments |
|---|---|---|---|
Verbatim |
-- | ||
Directive |
-- | ||
Link |
-- | ||
Math |
-- | ||
BlockMath |
-- | ||
SubstitutionDef |
-- | ||
SubstitutionRef |
-- | ||
Target |
-- | ||
Unimplemented |
-- | ||
Comment |
-- | ||
Fig |
-- | ||
RefInfo |
-- | ||
ListItem |
-- | ||
Signature |
-- | ||
NumpydocExample |
-- | ||
NumpydocSeeAlso |
-- | ||
NumpydocSignature |
-- | ||
Section |
-- | ||
Parameters |
-- | ||
Param |
-- | ||
Token |
-- | ||
Code3 |
-- | ||
CodeLine |
-- | ||
Code2 |
-- | ||
GenToken |
-- | ||
Code |
-- | ||
BlockQuote |
-- | ||
Transition |
-- | ||
Paragraph |
-- | ||
Admonition |
-- | ||
TocTree |
-- | ||
BlockDirective |
-- | ||
BlockVerbatim |
-- | ||
Options |
-- | ||
FieldList |
-- | ||
FieldListItem |
-- | ||
DefList |
-- | ||
DefListItem |
-- | ||
SeeAlsoItem |
-- |