Menu

#378 #__init__ -> #__init_: last underscore of URL in replacement substitution is dropped

closed-invalid
nobody
None
5
2020-03-03
2019-09-23
No

a.rst

.. _`__init__`:

|__init__|

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

with

rst2html a.rst

produces

Unknown target name: &quot;a.html#__init_&quot;.</div>
Unknown target name: &quot;a.html#__init_&quot;.</div>

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

I also filed this for pandoc:
https://github.com/jgm/pandoc/issues/5763

Discussion

  • Günter Milde

    Günter Milde - 2019-09-25
    • status: open --> closed-invalid
     
  • Günter Milde

    Günter Milde - 2019-09-25

    The problem is in the embedded link in
    some.__init__ <some.pdf#some.__init__>__

    In an embedded link,

    ... a target URI that is not recognized as standalone hyperlink happens to end with an underscore, this needs to be backslash-escaped to avoid being parsed as hyperlink reference. For example

         Use the `source <parrots.txt\_>`__.
    

    creates an anonymous reference to the file parrots.txt_.

    -- http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#embedded-uris-and-aliases

    You may either escape the last underscore:

    `some.__init__ <some.pdf#some.__init_\_>`__
    

    or write the target as a recognized URI:

    `some.__init__ <file:some.pdf#some.__init__>`__
    

    For documents meant to be read in source form, the use of independent block-level hyperlink targets is strongly recommended:

       .. |__init__| replace:: `some.__init__`_
    
       .. _some.__init__: some.pdf#some.__init__
    
     
    👍
    1

Log in to post a comment.

MongoDB Logo MongoDB