tags:

views:

190

answers:

2

I want to generate HTML pages with rst2html, using my own templates. these templates include many % signs, like in

<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">

now, when I call rst2html using the command

rst2html --template=layout2.tpl rst/index.rst > index.html

i get the error

ValueError: unsupported format character '"' (0x22) at index 827

i found out the problem is that rst2html thinks that the %" is a placeholder.

i already tried escaping the % in the template, like

<TABLE border="0" cellpadding="0" cellspacing="0" width="100\%">

but this is not working, the error is the same.

so my question is how i can solve this issue. any help is greatly appreciated!

+5  A: 

Have you tried obvious things: escaping the '%' with '%'?

Here is normal string formatting to display a percent sign in the result:

>>> print "%d%%" % 100
100%

Maybe rst2html is the same? (I haven't tried this in rst2html -- I don't have it installed.)

Okay, now I've installed docutils. This works for me:

layout2.tpl:

<TABLE border="0" cellpadding="0" cellspacing="0" width="100%%">

Command line:

C:\Python26\Lib\site-packages>python C:\Python26\Lib\site-packages\docutils-0.5-
py2.6.egg\EGG-INFO\scripts\rst2html.py --template=c:\temp\layout2.tpl
^Z
<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">

So the result is as desired, I believe.

hughdbrown
That's the Python way -- the obvious solution usually works.
scrible
hmm. when i put the line<TABLE border="0" cellpadding="0" cellspacing="0" width="100'%'">i still getValueError: unsupported format character ''' (0x27) at index 827so the obvious is not working here -- or i'm doing something wrong ...
andreash
yep, that's it. the following works: <TABLE border="0" cellpadding="0" cellspacing="0" width="100%%">thanks a lot!
andreash
A: 

Doubt it, but maybe the XML command CDATA works.

<![CDATA[
...
]]>

I use it for storing paypal buttons in an XML document and inserting them with PHP.

Sir Oddfellow