-
Notifications
You must be signed in to change notification settings - Fork 10
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
Resolving references #7
Comments
Excellent breakdown, thank you. The kinds of references in rST were the only part that still confused me, but this seems to be exhaustive! I’ve been documenting the weirder parts of rST/doctrees as I went, this overview should also go somewhere people can find it! Yeah, doing an earlier pair of passes for substitutions seems like an easy way to fix this in the future. |
I've also been looking into the system messages that are raised related to the references. This wasn't clearly documented in the spec (indeed, most messages aren't documented at all), and I had to dig into docutils' The message levels are documented in PEP 258. Section titles:
Footnotes and footnote references:
Citations and citation references:
Explicit hyperlink targets and references:
Inline internal targets:
Substitution definitions and references:
Although the ReST spec treats any link targets other than explicit hyperlink targets and inline internal targets as explicit links, docutils is actually treating any link target other than section titles as explicit. The above list describes how docutils actually does things. |
OK, some progress from my side!
The README can now be perfectly rendered (almost: There’s no space inserted between two consecutive lines of text) |
So @flying-sheep started working on resolving references by writing a two-pass transform approach: one which would walk the tree to keep track of every target of a reference, and then one which would walk the tree making the corresponding changes. I'm not sure anymore that all references can be resolved that way.
So, the different types of targets and references in ReST are:
implicit targets, which include section titles, footnotes which are either manually numbered or have autonumber labels, and citations. [See my next comment for what docutils actually treats as explicit and implicit targets.]The thing that makes this hard, perhaps impossible, to resolve in those two passes is substitutions, which in
docutils
get handled earlier than every other reference. Right now our parser only accepts animage
directive inside a substitution definition, but in the general case substitution references can be replaced by any inline content (with thereplace
directive, for example), which can in turn have auto-numbered footnote references, anonymous hyperlink references or hyperlinks with an embedded URL.I guess for now we could handle everything in those two passes, but in the future we'll have to move the code for substitutions to its own separate two passes that run before the others.
The text was updated successfully, but these errors were encountered: