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

Error parsing reStructuredText hyperlink inside directive #10281

Closed
cmorve-te opened this issue Oct 10, 2024 · 3 comments
Closed

Error parsing reStructuredText hyperlink inside directive #10281

cmorve-te opened this issue Oct 10, 2024 · 3 comments

Comments

@cmorve-te
Copy link

cmorve-te commented Oct 10, 2024

The indented hyperlink reference in https://github.com/llvm/llvm-project/blob/36a0d442eb4d2f1e0782bc2a1b1715fc7631faec/clang-tools-extra/docs/clang-tidy/checks/modernize/pass-by-value.rst?plain=1#L153, inside a "seealso" directive, is not corrected parsed by pandoc 3.5

# /pandoc-3.5/bin/pandoc /pass-by-value.rst -f rst -t html5 > /pass-by-value_pandoc.html
[WARNING] Reference not found for 'want speed? pass by value' at /pass-by-value.rst_chunk line 3 column 87

if the document is changed to remove the spaces before the .., it works correctly

-  .. _Want Speed? Pass by Value: https://web.archive.org/web/20140205194657/http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/
+.. _Want Speed? Pass by Value: https://web.archive.org/web/20140205194657/http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/

"seealso" is a sphinx directive, but if replaced with "note" rst2html parses everything correctly (without a need to remove the spaces before the ..):

$ rst2html pass-by-value.rst > pass-by-value.html
$ grep -F 'Want Speed? Pass by Value' pass-by-value.html 
<p class="last">For more information about the pass-by-value idiom, read: <a class="reference external" href="https://web.archive.org/web/20140205194657/http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/">Want Speed? Pass by Value</a>.</p>
@cmorve-te cmorve-te added the bug label Oct 10, 2024
@jgm
Copy link
Owner

jgm commented Oct 10, 2024

I believe this is because we do an initial pass to find link references, and we only look at those at the outer level. Fixing this would require, at least, making that first parsing pass more complete.

@jgm
Copy link
Owner

jgm commented Oct 10, 2024

Question: is this definition scoped to the indented context?
Or can you link to `Want Speed? Pass by Value`_. elsewhere in the document?

@cmorve-te
Copy link
Author

According to rst2html they are not scoped:

  • You can link from elsewhere
  • If you add another definition with the same name in global scope, or even inside another directive, it errors complaining about the duplicate

@jgm jgm closed this as completed in c8fda8f Oct 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants