Mark Irvine
Mark Irvine

Reputation: 1369

How to preserve spaces in hyperlinks when converting restructured text to html?

I'm using python docutils and the rst2html.py script to convert restructured text to html.

I want to convert a line like this:

Test1 `(link1)  <C:/path with spaces/file.html>`_ 

Into something like this:

<p>Test1 <a class="reference external" href="C:/path with spaces/file.html">(link1)</a>

But instead I get this (spaces in path are dropped):

<p>Test1 <a class="reference external" href="C:/pathwithspaces/file.html">(link1)</a>

How do I preserve the whitespace in links?

Upvotes: 1

Views: 1367

Answers (1)

PEdroArthur
PEdroArthur

Reputation: 884

I don't know how you are grabbing the line from the file (or stdin), but you should convert the link related string to HTML entities. You can find more information in the following link Escaping HTML - Python Wiki.

Hope this help you.

Upvotes: 2

Related Questions