Reputation: 1136
I generate pdf (latex) from restructured text using python sphinx (1.4.6) .
I use narrow table column headers with texts like "stuff/misc/other". I need the slashes to be breakable, so the table headers don't overflow into the next column.
The LaTeX solution is to use \BreakableSlash
or \slash
where necessary. I can use python code to replace all slashes:
from sphinx.util.texescape import tex_replacements
# \BreakableSlash needs package hyphenat to be loaded
tex_replacements.append((u'/', ur'\BreakableSlash ') )
# tex_replacements.append((u'/', ur'\slash ') )
But that will break any URL like http://www.example.com/
into something like
http:\unhbox\voidb@x\penalty\@M\hskip\z@skip/\discretionary{-}{}{}\penalty\@M\hskip\z@skip\unhbox\voidb@x\penalty\@M\hskip\z@skip/\discretionary{-}{}{}\penalty\@M\hskip\[email protected]
or
http:/\penalty\exhyphenpenalty/\penalty\exhyphenpenaltywww.example.com
I'd like to use a general solution that works in both cases, where the editor of the documentation can still use normal ReST and doesn't have to worry about latex.
Any idea how to get classic slashes in URLs and breakable slashes everywhere else?
Upvotes: 1
Views: 199
Reputation: 1136
One way to do it, might be to write a Transform subclass. And then use add transform in setup(app) to use it in every read.
I could use DefaultSubstitutions from transforms.py as template for my own class.
Upvotes: 0
Reputation: 6259
You have not really given data and source code and only asked for an idea, so I take the liberty of only sketching a solution in pseudo code:
.split()
" ".join(my_list)
Upvotes: 1