-
Notifications
You must be signed in to change notification settings - Fork 200
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
Have a special syntax for page titles? #4
Comments
Agree, currently the docutils transform <document>
<section names="top-level title">
<title>
Top-Level Title
<paragraph>
A paragraph. To: <document names="top-level title">
<title>
Top-Level Title
<paragraph>
A paragraph. |
Just a note that I just realized setext |
(Sorry for a drive-by comment)...in a Sphinx thing I did in 2018, it was a pain to get the title from the doctree. For one, it happens a bit later in the Sphinx build phases than I wanted...I had already parsed the YAML frontmatter that I implemented but couldn't use it until I got the title. If I had the option to get it from myst frontmatter and it winds up in the doctree, I'd be pleased. FWIW, as someone who has done a lot of low-level Sphinx stuff, what you're doing is wonderful. |
Thanks @pauleveritt 😄 @choldgraf where we are at with this issue, since I recall there has been some further thought on it downstream in myst-nb/jupyter-book? |
I don't believe there has been specific new development on this topic, but here's a thought: The challenge with having a special title syntax is that Markdown treats ATX and Setext the same way (roughly). E.g.,:
Will both be parsed as So, two thoughts:
|
A question about goals/non-goals. Do you want the same markdown document to be usable outside MyST/Sphinx? Meaning, someone could write a If so, you might want an approach which gracefully degrades to a heading. Which alas, I don't think exists. 😄 |
Haha yeah, I think that is a goal, though one we recognize is a balance between new functionality and the ability to degrade gracefully. So it all depends on the pros / cons I think. For this case, I agree with you though as you say, I'm not sure there's anything that exists that would degrade nicely (unless we over-wrote the behavior of some commonmark syntax, which also doesn't seem to be ideal) |
A front matter solution would be my recommendation |
I actually quite like supporting a front-matter title - it seems to nicely go along with the principle of "explicit is better than implicit" (and right now we implicitly choose the first section header as the document title). The only challenge I foresee is that editing notebook-level metadata in ipynb files is a PITA but I think it's something we could work around (and not strictly myst-parser's problem to solve) |
I just looked at how nteract handles this, and they do add an I think that we should just piggy-back off of that and use the same fields (title first, maybe authors in the future) and provide docs for how users can edit these on a per-notebook basis. This UI in nteract is available when you click and filling out the fields adds this metadata:
Also note, in rST there appears to be a |
I'm in favor of title in frontmatter, but my needs are a good bit different. |
@pauleveritt you mentioned that you had looked into this in Sphinx and that the title was determined later in the process than you'd like. Do you remember whether: if a Then we could try to inject a |
as I mentioned previously, you just need to interject before |
Ah, it wasn't clear to me from your earlier comment whether that transform will always be applied (aka, overwrite the doctitle that's there if it exists) So then, I think what needs to happen here is to register a transform that precedes the sphinx title transform and adds a title node if there's the right metadata, yeah? I think this is where sphinx adds the title https://github.com/sphinx-doc/sphinx/blob/af62fa61e6cbd88d0798963211e73e5ba0d55e6d/sphinx/environment/collectors/title.py#L34 |
My case was unique. I had a system the embedded YAML into a frontmatter-style directive. The YAML created a You have your parser, so you don't have this problem, so it's just a distraction. 😄 It does make me want to ask: any chance the frontmatter -> YAML instance could be pluggable? I'd love to have pydantic validate it, allowing me to bail out of a build very early. |
Yes, plus encapsulate all content in a top-level section.
Including configurable validation for the front-matter wouldn't be that difficult. I think proper validation against a jsonschema would be better than using pydantic though. Feel free to open a separate issue. |
I realize this is a pretty old issue, but I haven't really found a way to get myst to work for this. Concrete repro: This compiles well using
This does not compile as a title:
What's the "right" way to set the document's title and the author's name in a standalone myst document? |
I would find it helpful to have a specific syntax for page titles so that you don't end up wasting your first markdown hash on it and have to start using
##
from then on.A few ways we could do it:
setext
header for it (e.g. a single==========
line)What do folks think about this idea?
The text was updated successfully, but these errors were encountered: