0
votes

I want to write a documentation with Sphinx using reStructuredText.

In my documentation I want to add this line of python code, which uses an apostrophe after the name jack. This apostrophe is escaped by a backslash in Python:

print('I am jack\'s raging bile duct')

When I add this to a reStructuredText (rst) file like this:

This is a simple example:
::

print('I am jack\'s raging bile duct')

after compiling to a html file I will see this:

enter image description here

How can I get rid of the backslash \ in my rst/Sphinx output html and still use the aposthrophe after jack and ' ?

1
I might be missing something, but are you trying to show a purposefully wrong Python syntax? - sinoroc
You mean: print('I am jack\'s raging bile duct')? What is wrong with it? When I run the script it prints "I am jack's raging bile duct". See also stackoverflow.com/questions/14104728/… - StefanOverFlow
I think I see what is a little confusing regarding my question. Yes I am actually looking for "wrong Python syntax", as I use this format in a totally different context. I just chose the Python example to illustrate the issue. - StefanOverFlow
OK, then I would just remove the backslash. I don't think docutils nor Sphinx care about it. The syntax highlighting might be wrong though, so you might want to disable it. - sinoroc

1 Answers

1
votes

You can use double quotes

print("I am jack's raging bile duct")