Hi,
It would be easier to give an answer if you could give an example of the
input XML, the (subset of) the XSL template, the expected latex file
(where does foo[PRS.3[SG.F]] occur?).
Thanks,
BG
On Tue, 15 Aug 2017 01:06:13 +0200, maxwell <maxw...@umiacs.umd.edu> wrote:
I am using dblatex to format grammars. I modified some things that Andy
Black had written to handle "interlinear glossing", including the
necessary XSL templates for these structures. Our XeLaTeX style sheet
uses the 'expex' package to format the interlinear text.
But I've run into a problem. In the form of expex that we're using, a
certain type of list is delineated by square brackets [].
Unfortunately, we also use '[' and in particular ']' in some of our
glosses. It looks like this in our XML:
<ilr:langData>foo</ilr:langData>
<ilr:gloss>PRS.3[SG.F]</ilr:gloss>
where 'PRS.3[SG.F]' is one of our glosses containing ']'. Our modified
xsl converts this into the following latex:
foo[PRS.3[SG.F]]
Here the outer [] is the list that expex expects. This extra ']' from
our gloss causes expex to choke, because the moment it sees a ']', it
assumes that's the end of the list.
I experimented with the latex file, and discovered that converting our
']' into a latex command would work:
\newcommand{\textrightsqbracket}{]}
...
foo[PRS.3\textrightsqbracket{}SG.F]]
Unfortunately, I can't persuade dblatex to output this. I thought I
could modify the template for text() to replace any ']' in our XML with
the latex command, like this:
...
<xsl:value-of select="replace(., '\]', '\\textrightsqbracket{}')"/>
...
I think this is doing the right thing, but then something else in
dblatex comes along and changes its output
foo[PRS.3\textrightsqbracket{}SG.F]]
to
foo[PRS.3\textbackslash{}textrightsqbracket\{\}SG.F]]
which of course doesn't work when I feed this through latex.
I tracked the "something" in dblatex that's making this change down to
this:
text = text.replace("\\", r"\textbackslash")
in LatexCodec.encode() in the file texcodec.py, which gets called from
if not(self._fontmgr):
return LatexCodec.encode(self, text)
in XetexCodec.encode().
It's unclear to me when this text.replace() code gets called. In most
places in the xsl, I can write
<xsl:text>\foobar{}</xsl:text>
and the backslash doesn't get changed into a \textbackslash. But in
other places it does, and I haven't been able to avoid it happening in
the template for text().
Short of building my own post-processor for the output of dblatex, or
entirely turning off the conversion of '\' to \textbackslash inside
texcodec.py (which is probably dangerous!), is there any trick? Some
way to protect the '\' so
\textrightsqbracket{}
doesn't become
\textbackslash{}textrightsqbracket\{\}
(I guess I could use \3 or some such in my .xsl, in place of the
backslash before the 'textrightsqbracket', and then modify codec.py to
convert \3 to a plain backslash...)
Mike Maxwell
University of Maryland
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Dblatex-users mailing list
Dblatex-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dblatex-users
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Dblatex-users mailing list
Dblatex-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dblatex-users