add custom processing of text nodes, for -- subsitution (#5854)

This commit is contained in:
Frédéric Péters 2014-11-04 14:18:55 +01:00
parent 996b4a112f
commit 4d812d6990
2 changed files with 12 additions and 1 deletions

View File

@ -265,6 +265,15 @@ def convertLegi2Tex(input, outputFileName, annexes, d, draft=0, toc=True,
xsl_style.freeStylesheet()
insertAnnex(preprocessed_xml_doc, annexes, d)
ctxt = preprocessed_xml_doc.xpathNewContext()
# some custom preprocessing of text content:
# marks -- as TABELLIO-- so substitution with the proper command
# (\hyp{}) can happen in the postprocessing phase.
for node in ctxt.xpathEval('//text()'):
if '--' in node.content:
node.setContent(node.content.replace('--', 'TABELLIO--'))
ctxt.xpathFreeContext()
# processing
if draft:
xslParam['with-draft-tag'] = '1'
@ -291,7 +300,8 @@ def convertLegi2Tex(input, outputFileName, annexes, d, draft=0, toc=True,
for before, after in [(u'’', u"'"), (u'\u2019', u"'"),
(u'“', u'\guillemotleft'), (u'\u201C', u'«'),
(u'”', u'\guillemotright'), (u'\u201D', u'»'),
(u'‑', u'-'), (u'\u2011', u'-')]:
(u'‑', u'-'), (u'\u2011', u'-'),
(u'TABELLIO--', u'\hyp{}'),]:
doc = doc.replace(before, after)
# look for end of parts and change the multicol environment not to have

View File

@ -107,6 +107,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<xsl:text>\usepackage[T1]{fontenc}&#10;</xsl:text>
<xsl:text>\usepackage{ucs}&#10;</xsl:text>
<xsl:text>\usepackage{relsize}&#10;</xsl:text>
<xsl:text>\usepackage{hyphenat}&#10;</xsl:text>
<xsl:text>% --------------------------------------------&#10;</xsl:text>
<xsl:text>% Check for PDFLaTeX/LaTeX &#10;</xsl:text>
<xsl:text>% --------------------------------------------&#10;</xsl:text>