-
Notifications
You must be signed in to change notification settings - Fork 6
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
Introduce leaf directives #57
Comments
thoughts @rowanc1 ? |
Intriguing, is that leaf div syntax used elsewhere? I will get the proposal @mmcky and I are stewing on posted tomorrow. I think it complements this well, although it is smaller in scope -- only about the block title changes. |
Relatively similar: https://talk.commonmark.org/t/generic-directives-plugins-syntax/444 and then I also opened jgm/djot#215 |
I really like this for things like iframes, and fenced directives that @mmcky has introduced which don't have body content and should be a single line but end up being two. |
A trick thing here though is: do you interpret the content of a leaf div, as its body, or its argument? or have some way of discriminating the two? For example, for admonitions we definitely want the content to be the body, but for other things like images you would want it to be the argument: .. note:: The body that can have *nested syntax*
.. image:: path/to/image.png you might even what these as separate (leaf) syntaxes, something like: ::{note} The body that can have *nested syntax*
..{image} path/to/image.png So |
Here I guess you would call |
Just to be clear:
and, well, if you just wanted |
Oh this is interesting for gated directives like For example in the ```{exercise-start}
:label: ex1
```
```{code-cell} python
<some code>
```
```{exercise-end}
``` So https://ebp-sphinx-exercise.readthedocs.io/en/latest/syntax.html#alternative-gated-syntax |
so then your example above would potentially go to: {label=ex1}
..{exercise-start}
```{code-cell} python
<some code>
```
..{exercise-end} |
gentle nudge @rowanc1 😉 |
Leaf directives are a cool idea, and allow for really terse syntax, which I think is awesome. I also really like the idea that they have almost the same syntax as a colon directive. I think that we probably don't need a difference between parsing an argument vs parsing markdown, and we just do it in the same way that we don't have syntax differences between I like saying to a user, "want to do this on one line":
"remove a colon, and put it on one line!" 💥
|
This is not the difference, though, it's the difference between using the argument vs the body Lets say you had a directive that could look like this:
what does this represent?
|
Say I switch to the
|
<div>
<p><em>Hello</em></p>
</div> (similar to https://djot.net/playground/?text=%3A%3A%3A%0A*Hello*%0A%3A%3A%3A&mode=html&sourcepos=false) |
You'll find this is what https://myst-parser.readthedocs.io/en/stable/live-preview.html already does now (since v0.19) with The potential difference for |
In addition to taking arguments (titles) from the remainder of the line, I would like to propose that "block attributes" be interpreted inside the braces of the directive as well:
|
Off hand, I don't feel this would not be viable / a good idea
|
background
Restructured text allow for the syntax:
It is a nice, terse, one-line syntax for an admonition.
This comes at a price though; the parsing of a directive's "structure" is dependent on the type of directive.
Because the body content can possibly be on the first line, this does not work:
It is simply treated as a note with two body paragraphs
This means you then have to then use a different directive 😒:
https://github.com/executablebooks/MyST-Parse currently follows this logic with
colon_fence
, e.g.However, https://myst-tools.org/docs/mystjs/admonitions#admonition-titles does not
proposal
I propose "disambiguating" this difference, by introducing a "leaf div" to compliment the block "div"
In executablebooks/mdit-py-plugins#72, I have sketched out what this would look like for a markdown-it plugin
Note with block attributes, you could also provide options to leaf divs, e.g. this
would be equivalent to
The text was updated successfully, but these errors were encountered: