-
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
Standardisation of common attributes (classes, names) #32
Comments
Is there something in the mdast ecosystem to point to? React is Can we have an array of classes with spaces in them? This shouldn't be allowed: classes:
- 'myClass mySecondclass' Instead: classes:
- myClass
- mySecondclass |
FYI in unified-myst, this is what I am currently doing: https://github.com/executablebooks/unified-myst/blob/096dd8da49ce609ea9a1edec4a492e3798f63df1/packages/core-parse/src/directiveProcessor.js#L83-L111 |
@rowanc1 and @fwkoch further to our discussion regarding Take this simple example: # main
## subtitle
(target1)=
(target2)=
### Sub-subtitle
[ref1](target1)
[ref2](sub-subtitle) This is how it is resolved by docutils: $ myst-docutils-pseudoxml test.md
<document ids="main" names="main" source="test.md" title="main">
<title>
main
<subtitle ids="subtitle" names="subtitle">
subtitle
<target refid="target1">
<target refid="target2">
<section ids="sub-subtitle target2 target1" names="sub-subtitle target2 target1">
<title>
Sub-subtitle
<paragraph>
<reference refid="target1">
ref1
<reference refid="sub-subtitle">
ref2 As you can see, not only is the header assigned the identifiers coming from the targets, it is also assigned a "slug" identifier based on its content (which is not an unusual practice when rendering Markdown). Not allowing multiple identifiers would render this example, and by extension jupyter-book itself, non myst-spec compliant, which is obviously extremely problematic 😬. To clarify some extra terminology from docutils:
Here also is the rendering of this example as html/latex: $ myst-docutils-html5 test.md
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
...
<body>
<main id="main">
<h1 class="title">main</h1>
<p class="subtitle" id="subtitle">subtitle</p>
<section id="sub-subtitle">
<span id="target2"></span><span id="target1"></span>
<h2>Sub-subtitle</h2>
<p>
<a class="reference internal" href="#target1">ref1</a>
<a class="reference internal" href="#sub-subtitle">ref2</a>
</p>
</section>
</main>
</body>
</html> $ myst-docutils-latex test.md
...
\begin{document}
\title{main%
\label{main}%
\\%
\DUdocumentsubtitle{subtitle}%
\label{subtitle}}
\author{}
\date{}
\maketitle
\section{Sub-subtitle%
\label{sub-subtitle}%
\label{target2}%
\label{target1}%
}
\hyperref[target1]{ref1}
\hyperref[sub-subtitle]{ref2}
\end{document} |
FYI, if you want to see how anything is resolved by myst-docutils, simply install https://github.com/pypa/pipx, and |
Can you point to a user using multiple stacked targets in a Jupyter Book that exists today? Or an example of this being used in a sphinx project? A few notes:
My take: multiple-ids are unused (I have never seen this in any non-contrived, user example1), bring no additional features to the end user, and can be easily cleaned up by throwing warnings in a post-parsing transform in any implementation. Introducing a list of IDs to refer to a single element is a significant additional complexity that means all state management becomes harder, especially for cross-project linking (e.g. some equivalent of inter-sphinx, or any work around PIDs ongoing in research/library communities). Looking forward to talking this through on Monday. There are lots of options on how to support this in Python/JB before passing on to sphinx. I am suggesting we support a subset of sphinx's complexity, and provide tools to help users refactor their documents with explicit references/labels. Footnotes
|
Yeh absolutely, happy to discuss. What I want to emphasize, is this is not a trivial choice.
Any project that refers to headings by both targets and heading slugs.
I feel this is somewhat a misunderstanding of how Jupyter Book (via myst-parser) works:
I would not say that this is merely a quirk of docutils though, it is a core design aspect: https://docutils.sourceforge.io/docs/ref/doctree.html#common-attributes
But inter-sphinx already does work with multiple IDs
I feel this is a misunderstanding of what [a]
[a]: https://example1.com
[a]: https://example2.com goes to MDAST resembling <paragraph>
<linkReference identifier="a">
<definition identifier="a">
<definition identifier="a">
this is also the same for Whether we use something like
Taking the above discussion, I would ask what do you mean by a canonical ID? sphinx essentially handles this via the |
A thing that one might consider, is also setting a (probably SHA256) UUID for every node in the AST. This would provide an "unequivocal" identifier for all nodes, irrespective of what was referencing it. |
As specified here: https://docutils.sourceforge.io/docs/ref/doctree.html#common-attributes, there are some common attributes associated with all docutils nodes, and this should essentially be the same here.
As an example, here: https://github.com/executablebooks/myst-spec/blob/35f80974a69f68490b007c3e6d919ed246f64594/docs/examples/directives.admonitions.yml#L122
This should be
classes: ['tip']
The text was updated successfully, but these errors were encountered: