python - How to escape single quotes in reStructuredText when converting to HTML using Sphinx -


for documentation project writing need include table date format strings. works fine, @ end have slight problem want print literal ' quote , 2 literal quotes (separately , between other quotes). sphinx changes these up/down quotes, looks neat, in particular case makes text unreadable. best come was:

======   ===========   ======  ===================== ``'``    escape            | " ``'`` hour ``'`` h" -> "hour 9"          text           delimiter ``''``   single                | "ss ``''`` sss" -> "45 ``'`` 876"          quote           literal   ======   ===========   ======  ===================== 

this produces right quotes, inserts spaces before , after, see removed, since example not syntactically correct way. 1 rephrase question as: how remove spaces before , after literal quotes when using backticks.

i have tried standard ways of escaping. backslashes have no effect, since ' not restructuredtext special character. if remove spaces backticks `` won't work anymore.

sample output spaces: enter image description here

i found answer burried in documentation:

http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup

it turns out can escape space characters using backslash "\" before them. "\ " rendered "". useful instances need use whitespace formatting, don't want whitespace show up, in question above.

so solution be:

======   ===========   ======  ===================== ``'``    escape            | "\ ``'``\ hour\ ``'``\ h" -> "hour 9"          text           delimiter ``''``   single                | "ss\ ``''``\ sss" -> "45\ ``'``\ 876"          quote           literal   ======   ===========   ======  ===================== 

ugly read, effective.

another example inline formatting of function calls:

**dateformat (**\ *<string,number,void>* **sourcedate,** *string* **sourcedateformat,** *string* **returndateformat)** 

it turns out way formatting correct (variable types italic , rest bold, whithout having space between opening parenthesis , variable type).


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -