Created Debian package
[xmldoc.git] / xp.c
diff --git a/xp.c b/xp.c
index fd997d4..52a6491 100644 (file)
--- a/xp.c
+++ b/xp.c
@@ -37,7 +37,7 @@
 #include <libxslt/xsltutils.h>
 #include <libxslt/extensions.h>
 
-#include <libexslt/exsltconfig.h>
+#include <libexslt/exslt.h>
 
 
 #ifndef HAVE_STAT
@@ -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;
@@ -88,14 +91,15 @@ struct
    {  '$',     "\\$"              },
    {  '%',     "\\%"              },
    {  '&',     "\\&"              },
-   {  '<',     "\\verb+<+"        },
-   {  '>',     "\\verb+>+"        },
+   {  '<',     "$<$"              },
+   {  '>',     "$>$"              },
    {  '\\',    "$\\backslash$"    },
-   {  '^',     "\\verb+^+"        },
+   {  '^',     "$\\wedge$"        },
    {  '_',     "\\_"              },
    {  '{',     "\\{"              },
+   {  '|',     "$\\mid$"          },
    {  '}',     "\\}"              },
-   {  '~',     "\\verb+~+"        },
+   {  '~',     "$\\sim$"          },
    {  160,     "~"                },
    {  161,     "!`"               },
    {  162,     "..."              },
@@ -348,6 +352,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 +407,7 @@ xsltProcess(xmlDocPtr doc, xsltStylesheetPtr cur, const char *filename) {
 void LatexEscape(xmlNodePtr node)
 {
    xmlNodePtr  child;
+   xmlAttrPtr  attribute;
    xmlChar     *byte;
    int         unicode;
 
@@ -406,6 +415,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,9 +505,13 @@ 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 )
+         if (strcmp(child->name, "verbatim") != 0 && strcmp(child->name, "example") != 0)
          {
             LatexEscape(child);
          }