groff-commit
[Top][All Lists]
Advanced

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

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


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

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

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

Log message:
        The -TMathML option for eqn.

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

Patches:
Index: other.cpp
===================================================================
RCS file: /sources/groff/groff/src/preproc/eqn/other.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- other.cpp   26 May 2005 21:02:00 -0000      1.2
+++ other.cpp   3 Feb 2007 05:32:55 -0000       1.3
@@ -65,6 +65,7 @@
 
 void accent_box::output()
 {
+  if (output_format == troff) {
   printf("\\h'\\n[" WIDTH_FORMAT "]u-\\n[" WIDTH_FORMAT "]u/2u+\\n["
         SKEW_FORMAT "]u'",
         p->uid, ab->uid, p->uid);
@@ -76,6 +77,12 @@
         SKEW_FORMAT "]u)'",
         p->uid, ab->uid, p->uid);
   p->output();
+  } else if (output_format == mathml) {
+    printf("<mover accent='true'>");
+    p->output();
+    ab->output();
+    printf("</mover>")
+  }
 }
 #endif
 
@@ -110,6 +117,7 @@
 
 void accent_box::output()
 {
+  if (output_format == troff) {
   printf("\\Z" DELIMITER_CHAR);
   printf("\\h'\\n[" LEFT_WIDTH_FORMAT "]u+\\n[" SKEW_FORMAT "]u"
         "-(\\n[" WIDTH_FORMAT "]u/2u)'",
@@ -123,6 +131,12 @@
   p->output();
   printf(DELIMITER_CHAR);
   printf("\\h'\\n[" WIDTH_FORMAT "]u'", uid);
+  } else if (output_format == mathml) {
+    printf("<mover accent='true'>");
+    p->output();
+    ab->output();
+    printf("</mover>");
+  }
 }
 
 void accent_box::check_tabs(int level)
@@ -153,10 +167,14 @@
 
 void overline_char_box::output()
 {
+  if (output_format == troff) {
   printf("\\v'-%dM/2u-%dM'", 7*default_rule_thickness, x_height);
   printf((draw_flag ? "\\D'l%dM 0'" : "\\l'%dM\\&\\(ru'"),
         accent_width);
   printf("\\v'%dM/2u+%dM'", 7*default_rule_thickness, x_height);
+  } else if (output_format == mathml) {
+    printf("<mo>&macr;</mo>");
+  }
 }
 
 void overline_char_box::debug_print()
@@ -197,6 +215,7 @@
 
 void overline_box::output()
 {
+  if (output_format == troff) {
   // 9
   printf("\\Z" DELIMITER_CHAR);
   printf("\\v'-\\n[" HEIGHT_FORMAT "]u-(%dM/2u)'",
@@ -207,6 +226,11 @@
     printf("\\l'\\n[" WIDTH_FORMAT "]u\\&\\(ru'", p->uid);
   printf(DELIMITER_CHAR);
   p->output();
+  } else if (output_format == mathml) {
+    printf("<mover accent='false'>");
+    p->output();
+    printf("<mo>&macr;</mo></mover>");
+  }
 }
 
 void overline_box::debug_print()
@@ -267,6 +291,7 @@
 
 void uaccent_box::output()
 {
+  if (output_format == troff) {
   printf("\\Z" DELIMITER_CHAR);
   printf("\\h'\\n[" LEFT_WIDTH_FORMAT "]u-(\\n[" WIDTH_FORMAT "]u/2u)'",
         uid, ab->uid);
@@ -279,6 +304,12 @@
   p->output();
   printf(DELIMITER_CHAR);
   printf("\\h'\\n[" WIDTH_FORMAT "]u'", uid);
+  } else if (output_format == mathml) {
+    printf("<munder accent='true'>");
+    p->output();
+    ab->output();
+    printf("</munder>");
+  }
 }
 
 void uaccent_box::check_tabs(int level)
@@ -314,10 +345,14 @@
 
 void underline_char_box::output()
 {
+  if (output_format == troff) {
   printf("\\v'%dM/2u'", 7*default_rule_thickness);
   printf((draw_flag ? "\\D'l%dM 0'" : "\\l'%dM\\&\\(ru'"),
         accent_width);
   printf("\\v'-%dM/2u'", 7*default_rule_thickness);
+  } else if (output_format == mathml) {
+    printf("<mo>&lowbar;</mo>");
+  }
 }
 
 void underline_char_box::debug_print()
@@ -360,6 +395,7 @@
 
 void underline_box::output()
 {
+  if (output_format == troff) {
   // 10
   printf("\\Z" DELIMITER_CHAR);
   printf("\\v'\\n[" DEPTH_FORMAT "]u+(%dM/2u)'",
@@ -370,6 +406,11 @@
     printf("\\l'\\n[" WIDTH_FORMAT "]u\\&\\(ru'", p->uid);
   printf(DELIMITER_CHAR);
   p->output();
+  } else if (output_format == mathml) {
+    printf("<munder accent='true'>");
+    p->output();
+    printf("<mo>&macr;</mo></munder>");
+  }
 }
 
 // we want an underline box to have 0 subscript kern
@@ -405,9 +446,15 @@
 
 void size_box::output()
 {
+  if (output_format == troff) {
   printf("\\s[\\n[" SMALL_SIZE_FORMAT "]u]", uid);
   p->output();
   printf("\\s[\\n[" SIZE_FORMAT "]u]", uid);
+  } else if (output_format == mathml) {
+    printf("<mstyle mathsize='%s'>", size);
+    p->output();
+    printf("</mstyle>");
+  }
 }
 
 size_box::~size_box()
@@ -449,12 +496,32 @@
 
 void font_box::output()
 {
+  if (output_format == troff) {
   printf("\\f[%s]", f);
   const char *old_roman_font = current_roman_font;
   current_roman_font = f;
   p->output();
   current_roman_font = old_roman_font;
   printf("\\f[\\n[" FONT_FORMAT "]]", uid);
+  } else if (output_format == mathml) {
+    char *mlfont = f;
+    // bold and italic are already in MathML; translate eqn roman here
+    switch (f[0]) {
+    case 'I': case 'i':
+      mlfont = "italic";
+      break;
+    case 'B': case 'b':
+      mlfont = "bold";
+      break;
+    case 'R': case 'r':
+    default:
+      mlfont = "normal";
+      break;
+    }
+    printf("<mstyle mathvariant='%s'>", mlfont);
+    p->output();
+    printf("</mstyle>");
+  }
 }
 
 void font_box::debug_print()
@@ -480,10 +547,16 @@
 
 void fat_box::output()
 {
+  if (output_format == troff) {
   p->output();
   printf("\\h'-\\n[" WIDTH_FORMAT "]u'", p->uid);
   printf("\\h'%dM'", fat_offset);
   p->output();
+  } else if (output_format == mathml) {
+    printf("<mstyle mathvariant='double-struck'>");
+    p->output();
+    printf("</mstyle>");
+  }
 }
 
 
@@ -519,9 +592,14 @@
 
 void vmotion_box::output()
 {
+  if (output_format == troff) {
   printf("\\v'%dM'", -n);
   p->output();
   printf("\\v'%dM'", n);
+  } else if (output_format == mathml) {
+    printf("<merror>eqn vertical motion cannot be expressed in 
MathML</merror>");
+    p->output();
+  }
 }
 
 void vmotion_box::debug_print()
@@ -552,8 +630,13 @@
 
 void hmotion_box::output()
 {
+  if (output_format == troff) {
   printf("\\h'%dM'", n);
   p->output();
+  } else if (output_format == mathml) {
+    printf("<merror>eqn horizontal motion cannot be expessed in 
MathML</merror>");
+    p->output();
+  }
 }
 
 void hmotion_box::debug_print()
@@ -587,8 +670,10 @@
 
 void vcenter_box::output()
 {
+  if (output_format == troff)
   printf("\\v'-\\n[" SUP_RAISE_FORMAT "]u'", uid);
   p->output();
+  if (output_format == troff)
   printf("\\v'\\n[" SUP_RAISE_FORMAT "]u'", uid);
 }
 




reply via email to

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