From: arjen Date: Tue, 3 Apr 2012 14:59:43 +0000 (+0000) Subject: Added LaTeX translation for the value of attributes. X-Git-Url: http://www.andromeda.nl/gitweb/?p=xmldoc.git;a=commitdiff_plain;h=2c10833aa467b60ab571a82c9d3c1c4d2efc1950 Added LaTeX translation for the value of attributes. Changed the translation of ~ to the LaTeX sequence $\sim$. --- diff --git a/xp.c b/xp.c index fd997d4..41b6fc3 100644 --- a/xp.c +++ b/xp.c @@ -55,6 +55,9 @@ xmlParserInputPtr xmlNoNetExternalEntityLoader(const char *URL, const char *ID, xmlParserCtxtPtr ctxt); +#define LIBXML_DEBUG_ENABLED +//#define DEBUG + static int debug = 0; static int novalid = 0; static int noout = 0; @@ -95,7 +98,7 @@ struct { '_', "\\_" }, { '{', "\\{" }, { '}', "\\}" }, - { '~', "\\verb+~+" }, + { '~', "$\\sim$" }, { 160, "~" }, { 161, "!`" }, { 162, "..." }, @@ -348,6 +351,10 @@ xsltProcess(xmlDocPtr doc, xsltStylesheetPtr cur, const char *filename) { xmlXIncludeProcessFlags(doc, XSLT_PARSE_OPTIONS); +#ifdef DEBUG + xmlDebugDumpDocument(stdout, doc); +#endif + if (latex) { LatexEscape(xmlDocGetRootElement(doc)); @@ -399,6 +406,7 @@ xsltProcess(xmlDocPtr doc, xsltStylesheetPtr cur, const char *filename) { void LatexEscape(xmlNodePtr node) { xmlNodePtr child; + xmlAttrPtr attribute; xmlChar *byte; int unicode; @@ -406,6 +414,9 @@ void LatexEscape(xmlNodePtr node) int textlen; int i; +#ifdef DEBUG + fprintf(stderr, "\n-------- Node type %d\n", node->type); +#endif if (xmlNodeIsText(node)) { #ifdef DEBUG @@ -493,6 +504,10 @@ void LatexEscape(xmlNodePtr node) } else { + for (attribute = node->properties; attribute != 0; attribute = attribute->next) + { + LatexEscape(attribute->children); + } for (child = node->children; child != 0; child = child->next) { if (strcmp(child->name, "verbatim") != 0 )