ReST: link bookmark

Sergio Spina sergio.am.spina at gmail.com
Tue Apr 19 04:58:09 EDT 2016


Il giorno domenica 17 aprile 2016 12:14:57 UTC+2, Sergio Spina ha scritto:
> Il giorno domenica 17 aprile 2016 12:04:38 UTC+2, Sergio Spina ha scritto:
> > I would know what is the way to implement in ReST a link bookmark like in this example:
> > 
> > > <html>
> > > <body>
> > >
> > > <p>This text stand for an example of text containing
> > > a <a name="B3Pa9-5ZRIx-1">bookmarked target</span> bookmark.</p>
> > >
> > > <p>So let's go all together to visit the bookmarked target
> > > clicking on <a href="#B3Pa9-5ZRIx-1">this link</a>.</p>
> > >
> > > </body>
> > > </html>
> > 
> > The string that is the name of the anchor is produced by an algorithm and 1) cannot be left away and 2) cannot be seen in the printed document.
> > 
> > Thanks.
> 
> The correct example is:
> 
> > <html>
> > <body>
> >
> > <p>This text stand for an example of text containig
> > a <a name="B3Pa9-5ZRIx-1">target</a> bookmark.</p>
> >
> > <p>So let's go all together to visit the target clicking
> > on <a href="#B3Pa9-5ZRIx-1">this link</a>.</p>
> >
> > </body>
> > </html>
> 
> Sorry for the mispelling.

I've tried some experiments looking for a hint:

    # file: test.htm

    <html>
    <body>
    
    <p>This text stand for an example of text containing
    a <a name="B3Pa9-5ZRIx-1">bookmarked target</a> bookmark.</p>
    
    <p>So let's go all together to visit the bookmarked target
    clicking on <a href="#B3Pa9-5ZRIx-1">this link</a>.</p>
    
    </body>
    </html>

First try:

    # test.htm converted at http://www.siafoo.net/html.xml
    
    This text stand for an example of text containig a `target <>`_ bookmark.

    So let's go all together to visit the target clicking on `this
    link <#B3Pa9-5ZRIx-1>`_ .

that is not what I'm looking for;

    # pandoc -f html test.htm -s -o test.rst
    
    This text stand for an example of text containig a target bookmark.
    
    So let's go all together to visit the target clicking on `this
    link <#B3Pa9-5ZRIx-1>`__.

that is not what I'm looking for;

    # html2rst.py taken from http://docutils.sourceforge.net/sandbox/cliechti/html2rst/html2rst.py
    # python html2rst.py test.htm > test.rst
    
    This text stand for an example of text containig a target bookmark.
    
    So let's go all together to visit the target clicking on `this
    link`_.
    
    .. _this link: #B3Pa9-5ZRIx-1

Not a good try.

Is there a better way ?



More information about the Python-list mailing list