Extensibility in djot #77
Replies: 4 comments 5 replies
-
And my AsciiDoctor! Nothing substantial to add, just my agreement on that:
Basically, I've wrote a whole post on the topic and then learned that my wish is granted in the form of djot ) |
Beta Was this translation helpful? Give feedback.
-
I think it might be helpful here, to split up the extensibility into types and have a think about how each one can/should be achieved in djot.
plus ideally being able to pass (key/value) options to all Also, comparing to reStructuredText roles (inline) and directives (block), it would be helpful for each to have a singular "name", to convey semantic meaning An inline role :myname:`content`
A leaf block directive
.. myname::
A directive with an argument, options and content
.. myname:: argument
:key: value
content I think of the name akin to a function name in programming languages def myname(argument, key=value, content=content):
return some_ast InlineThis takes into account #112, i.e. possibly making the emoji syntax more generic Inline, nestedHere, there is only really one option: It does feel a little verbose though Perhaps ideally it would be something like Inline, verbatimThere is kind of three options here:
(2) is the most concise, although it's maybe not really the intended use for the "raw format" syntax Inline, leafHere there is only one, if #112 is enacted
BlockBlock, nested
Note, I opened #140 to potentially make this easier to distinguish Block, verbatimThere are two very similar
Were Block, leafI don't think there is really anything that can be used for this currently? Looking above, I feel there could be some subtle improvements here FYI, personally, I use Sphinx a lot, and am the author of MyST-Parser, a CommonMark extended syntax with approximate feature parity to reStructuredText. So I'm definitely interested in looking to create a djot parser for Sphinx |
Beta Was this translation helpful? Give feedback.
-
Currently
just parses as
That is, we don't allow bare keys without values. Some have argued that we should make these bare words class names, avoiding the need for the leading period. Giving them a special "role" function would be another option, but what if there is more than one? |
Beta Was this translation helpful? Give feedback.
-
When I first looked at the syntax reference, I thought that djot was not extensible. However, Dr. MacFarlane corrected me.
Three design decisions together make djot extensible:
Any program that does post-processing can look for certain attributes on items and reform the AST as needed. AFAICT, this is sufficiently powerful to take away any need for extensibility in the language.
My original use case was for rich EBNF, like in Go's specification. However, I believe the sky's the limit with this, so much so in fact that it might replace all of my uses of Markdown and LaTeX.
I created this discussion as something to point to if someone asks the same question I did.
(Note: I originally emailed Dr. MacFarlane about this, and he made me aware of Discussions. I haven't used GitHub much for at least 2.5 years. I give Dr. MacFarlane permission to talk more about our email conversation if needed.)
Beta Was this translation helpful? Give feedback.
All reactions