Skip to content
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

Add attributes syntax #37

Open
chrisjsewell opened this issue Apr 11, 2022 · 2 comments
Open

Add attributes syntax #37

chrisjsewell opened this issue Apr 11, 2022 · 2 comments
Labels
enhancement New feature or request MEP MyST Enhancement Proposal

Comments

@chrisjsewell
Copy link
Member

chrisjsewell commented Apr 11, 2022

Relevant links:

Attributes are a common Markdown syntax extension, e.g. {#id .class value=key}, which I think might be useful in MyST.

At a block-level, I think this would be relatively simple to implement in https://github.com/executablebooks/MyST-Parser, since they would essentially follow the same rules/logic as targets, e.g.

(target)=
# header

would be equivalent to

{#target}
# header

But then extra logic could also be added, to propagate classes as well as identifiers (for now we would ignore key/values), e.g.

{#target .class1 .class2}
# header

Would relate to HTML like

<h1 id="target" class="class1 class2">header</h1>

another place they could be added, is for defining role options, e.g. {name}`content`{#id .class key=value}

The problem here, though, is that docutils roles syntax does not support options.
Although it is of note, that the role functions themselves, do actually accept an options key-word: https://github.com/live-clones/docutils/blob/48bb76093b4ba83654b2f2c86e7c52c4bb39c63b/docutils/docutils/parsers/rst/roles.py#L197-L211

@chrisjsewell chrisjsewell added the enhancement New feature or request label Apr 11, 2022
@rowanc1 rowanc1 added the MEP MyST Enhancement Proposal label Apr 11, 2022
@chrisjsewell
Copy link
Member Author

One thing I'd note here, is that pandoc have their header attributes inline with the heading text, rather than above it:

# header {#target}

But actually this is contrary to the Markdown creator's proposal

Allow attributes to be added on the line before any block element and directly after any inline element

which I think makes a lot more sense

@rowanc1
Copy link
Member

rowanc1 commented Oct 7, 2022

Another pointer to some users asking questions about this:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request MEP MyST Enhancement Proposal
Projects
None yet
Development

No branches or pull requests

2 participants