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

last underscore of URL in replacement substitution is dropped (rst source) #5763

Closed
rpuntaie opened this issue Sep 20, 2019 · 8 comments
Closed

Comments

@rpuntaie
Copy link

pandoc 2.7.3

a.rst

|__init__|

.. |__init__| replace:: `some.__init__ <some.pdf#some.__init__>`__

with

pandoc -f rst a.rst

produces

[WARNING] Reference not found for 'some.pdf#some.__init_' at chunk 

Note, that the last _ of __init__ has been dropped.

@jgm jgm added this to the 2.8 milestone Sep 20, 2019
@jgm
Copy link
Owner

jgm commented Sep 22, 2019

Is this really a bug? Try with rst2html.py:

a.rst:1: (ERROR/3) Unknown target name: "some.pdf#some.__init_".
a.rst:3: (ERROR/3) Unknown target name: "some.pdf#some.__init_".

We are conforming to docutils behavior here.

rst2html.py (Docutils 0.15 [release], Python 3.7.4, on darwin)

@jgm jgm removed this from the 2.8 milestone Sep 22, 2019
@rpuntaie
Copy link
Author

Rather this is also an rst2html bug. I will file a bug report there, too.

@rpuntaie
Copy link
Author

Filed also for docutils: https://sourceforge.net/p/docutils/bugs/378/

@jgm
Copy link
Owner

jgm commented Sep 24, 2019

If they confirm it's a bug, I'll fix it here too.

@rpuntaie
Copy link
Author

https://sourceforge.net/p/docutils/bugs/378/
has clarified the issue and produced an alternative.

@rpuntaie
Copy link
Author

There <file: solution proposed in https://sourceforge.net/p/docutils/bugs/378/
does not work for pandoc 2.7.3.

I keep this here in the context instead of opening a new issue:

a.rst

.. _`__init__`:

|__init__|

.. |__init__| replace:: `target <file:a.html#__init__>`__

with

pandoc -f rst a.rst

produces

[WARNING] Reference not found for '#__init_' at line 5 column 13
[WARNING] Reference not found for 'file:a.html#__init_' at chunk line 1 column 34

Note, that the last _ of __init__ has been dropped.

rst2html a.rst

does not produce an error.

@rpuntaie rpuntaie reopened this Sep 25, 2019
@jgm jgm added this to the 2.8 milestone Sep 25, 2019
jgm added a commit that referenced this issue Sep 29, 2019
@jgm
Copy link
Owner

jgm commented Sep 29, 2019

Solved part, maybe all of it.
Now we get:

% pandoc a.rst
[WARNING] Reference not found for '#__init_' at line 5 column 13
<div id="__init__">
<p><a href="file:a.html#__init__">target</a></p>
</div>

We get the link right now. I'm not sure what the first line of a.rst is supposed to be doing, and whether pandoc is mistaken in stripping the final _ in that case. rst2html.py just seems to ignore it entirely.

@rpuntaie
Copy link
Author

rst2html a.rst produces a <p id="init"> instead of <p id="__init__">. I made https://sourceforge.net/p/docutils/bugs/379/

The first line is enclosed in backticks. It is a normal target. It could be somewhere else in the file or even in another file. I just placed it in the file so that the target for __init__ exists, since I address it with <file:a.html#__init__>. So Pandoc and rst2html should treat it like a normal target. Pandoc should not produce a warning.

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