Closed matclab closed 5 years ago
The example in the sphinx docs works:
.. _my-reference-label:
Section to cross-reference
--------------------------
This is the text of the section.
It refers to the section itself, see :ref:`my-reference-label`.
Produces this:
<div class="section" id="section-to-cross-reference">
<span id="my-reference-label"></span><h1>Section to cross-reference</h1>
<p>This is the text of the section.</p>
<p>It refers to the section itself, see <a class="reference external" href="#my-reference-label">Section To Cross-Reference</a>.</p>
</div>
Aha! It only works if you refer to labels defined BEFORE the reference.
So this works:
.. _formal-verification:
Formal Verification in a Nutshell
=================================
asdasd
balbla :ref:`formal-verification` blabla
But this doesn't:
balbla :ref:`formal-verification` blabla
.. _formal-verification:
Formal Verification in a Nutshell
=================================
asdasd
Not sure how to fix it, tho, but will take a look. One possible solution is to just do the links without checking. Worst case you end up with a link pointing at nothing.
Yes, just doing the links would do the trick. Another solution is perhaps to collect all the target for whic links are generated, and all the existing target, and verify at the end that the first set is included in the second one. Though, I'm not sure it will fit the actual visiting algorithm. Thanks a lot for investigating.
Yes, the thing is that those nodes that have not yet been visited are not there. Fixing that would require some sort of two-pass scan, so just not checking seems to be the only way forward.
Looking at the actual implementation ... I don't understand it. Yes, I wrote it. I think :-)
Rewriting it in a dumb but foolproof way.
Sigh: inliner.document doesn't have the whole document, it has the document as seen so far which makes some sense, I guess.
But I do need to have seen the whole document in order to resolve the references and replace them with links where the text is the title of the section.
« I don't understand it. Yes, I wrote it. I think »… I know that feeling ;-)
Solution in place where it will always produce "something" but the title in the ref (if not given explicitly) could be wrong.
I tried with 2693266, and after having deleted the spurious set_trace, it looks like it still fails with the following post:
.. slug: test
.. date: 2019-01-04 12:44:53 UTC+01:00
.. tags:
.. category:
.. link:
.. description:
.. type: text
balbla :ref:`formal-verification` blabla
.. _formal-verification:
Formal Verification in a Nutshell
=================================
asdasd
Could you check with current latest revision?
Turns out I was logging the warning in the document, which of course sucked.
On Tue, Jan 8, 2019 at 10:17 AM matclab notifications@github.com wrote:
I tried with 2693266 https://github.com/getnikola/plugins/commit/26932660a6869987294f7f659f0fd4ce3e3f3e50, and after having deleted the spurious set_trace, it looks like it still fails with the following post:
.. slug: test .. date: 2019-01-04 12:44:53 UTC+01:00 .. tags: .. category: .. link: .. description: .. type: text
balbla :ref:
formal-verification
blabla.. _formal-verification:
Formal Verification in a Nutshell
asdasd
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/getnikola/plugins/issues/295#issuecomment-452294700, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAGK6EUUFATOin-n2M8-MMcQzr-pBnyks5vBJpegaJpZM4ZzvTo .
Yep, it works. Thanks a lot.
One last thing, according to sphinx documentation I think one could do a reference with the title of a section, like :ref:`Formal Verification in a Nutshell`
. However it only works if you do :ref:`formal-verification-in-a-nutshell`
. Is it intended ?
Still it is only a minor glitch. Thanks a lot for the work.
Could be added, but again it would only work reliably for sections defined before the reference.
On second look, I don't see that in the sphinx doc. It seems to support:
:ref:`some-label`
:ref:`A Title <some-label>`
And both should be working now with varying levels of success.
What is supported is
`Section Title`_
But that is just a regular docutils link and should already work.
Ho, I somewhat mixed the two.
anyway thank you again :+1:
I'm writing a document with the following code:
And nikola says :
ERROR: rest: [posts/2019-01/post.rst:89] ref label formal verification is missing or not immediately before figure or section.
Doing some others tries, and adding:
gives the following stack trace: