groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Groff-commit] groff/src/preproc/eqn box.cpp


From: Eric S. Raymond
Subject: [Groff-commit] groff/src/preproc/eqn box.cpp
Date: Sat, 03 Feb 2007 05:32:47 +0000

CVSROOT:        /sources/groff
Module name:    groff
Changes by:     Eric S. Raymond <esr>   07/02/03 05:32:47

Modified files:
        src/preproc/eqn: box.cpp 

Log message:
        The -TMathML option for eqn.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/groff/src/preproc/eqn/box.cpp?cvsroot=groff&r1=1.3&r2=1.4

Patches:
Index: box.cpp
===================================================================
RCS file: /sources/groff/groff/src/preproc/eqn/box.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- box.cpp     26 May 2005 21:02:00 -0000      1.3
+++ box.cpp     3 Feb 2007 05:32:47 -0000       1.4
@@ -226,26 +226,36 @@
 
 void start_string()
 {
+  if (output_format == troff) {
   printf(".nr " COMPATIBLE_REG " \\n(.C\n");
   printf(".cp 0\n");
   printf(".ds " LINE_STRING "\n");
+  }
 }
 
 void output_string()
 {
+  if (output_format == troff)
   printf("\\*(" LINE_STRING "\n");
+  else if (output_format == mathml)
+    putchar('\n');
 }
 
 void restore_compatibility()
 {
+  if (output_format == troff)
   printf(".cp \\n(" COMPATIBLE_REG "\n");
 }
 
 void do_text(const char *s)
 {
+  if (output_format == troff) {
   printf(".eo\n");
   printf(".as " LINE_STRING " \"%s\n", s);
   printf(".ec\n");
+  } else if (output_format == mathml) {
+    fputs(s, stdout);
+  }
 }
 
 void set_minimum_size(int n)
@@ -275,9 +285,10 @@
 
 void box::top_level()
 {
+  box *b = this;
+  if (output_format == troff) {
   // debug_print();
   // putc('\n', stderr);
-  box *b = this;
   printf(".nr " SAVED_FONT_REG " \\n[.f]\n");
   printf(".ft\n");
   printf(".nr " SAVED_PREV_FONT_REG " \\n[.f]\n");
@@ -338,6 +349,11 @@
     printf(".ne \\n[" HEIGHT_FORMAT "]u-%dM>?0+(\\n["
           DEPTH_FORMAT "]u-%dM>?0)\n",
           b->uid, body_height, b->uid, body_depth);
+  } else if (output_format == mathml) {
+    printf("<math>");
+    b->output();
+    printf("</math>");
+  }
   delete b;
   next_uid = 0;
 }
@@ -538,8 +554,15 @@
 
 void quoted_text_box::output()
 {
-  if (text)
+  if (text) {
+    if (output_format == troff)
+      fputs(text, stdout);
+    else if (output_format == mathml) {
+      fputs("<mtext>", stdout);
     fputs(text, stdout);
+      fputs("</mtext>", stdout);
+    }
+  }
 }
 
 tab_box::tab_box() : disabled(0)
@@ -569,7 +592,11 @@
 
 void space_box::output()
 {
+  if (output_format == troff)
   printf("\\h'%dM'", thick_space);
+  else if (output_format == mathml)
+    // &ThickSpace; doesn't display right under Firefox 1.5.
+    printf("<mtext>&ensp;</mtext>");
 }
 
 half_space_box::half_space_box()
@@ -579,7 +606,10 @@
 
 void half_space_box::output()
 {
+  if (output_format == troff)
   printf("\\h'%dM'", thin_space);
+  else if (output_format == mathml)
+    printf("<mtext>&ThinSpace;</mtext>");
 }
 
 void box_list::list_debug_print(const char *sep)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]