groff-commit
[Top][All Lists]
Advanced

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

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


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

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

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

Log message:
        The -TMathML option for eqn.

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

Patches:
Index: pile.cpp
===================================================================
RCS file: /sources/groff/groff/src/preproc/eqn/pile.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- pile.cpp    26 May 2005 21:02:00 -0000      1.3
+++ pile.cpp    3 Feb 2007 05:32:58 -0000       1.4
@@ -56,6 +56,7 @@
 
 void pile_box::output()
 {
+  if (output_format == troff) {
   int i;
   printf("\\v'-\\n[" SUP_RAISE_FORMAT "]u'", uid);
   for (i = 0; i < col.len; i++) {
@@ -95,6 +96,22 @@
   printf("\\v'\\n[" SUP_RAISE_FORMAT "]u'", uid);
   printf("\\v'-(%du*\\n[" BASELINE_SEP_FORMAT "]u)'", col.len - 1, uid);
   printf("\\h'\\n[" WIDTH_FORMAT "]u'", uid);
+  } else if (output_format == mathml) {
+    char *av;
+    switch (col.align) {
+      case LEFT_ALIGN: av = "left"; break;
+      case RIGHT_ALIGN: av = "right"; break;
+      case CENTER_ALIGN: av = "center"; break;
+      default: assert(0);
+    }
+    printf("<mtable columnalign='%s'>", av);
+    for (int i = 0; i < col.len; i++) {
+      printf("<mtr><mtd>");
+      col.p[i]->output();
+      printf("</mtd></mtr>");
+    }
+    printf("</mtable>");
+  }
 }
 
 pile_box::pile_box(box *pp) : col(pp)
@@ -163,6 +180,7 @@
 
 void matrix_box::output()
 {
+  if (output_format == troff) {
   printf("\\h'%dM'", matrix_side_sep);
   for (int i = 0; i < len; i++) {
     int j;
@@ -208,6 +226,27 @@
       printf("\\h'%dM'", column_sep);
   }
   printf("\\h'%dM'", matrix_side_sep);
+  } else if (output_format == mathml) {
+    int n = p[0]->len; // Each column must have the same number of rows in it
+    printf("<mtable>");
+    for (int i = 0; i < n; i++) {
+      printf("<mtr>");
+      for (int j = 0; j < len; j++) {
+       char *av;
+       switch (p[j]->align) {
+       case LEFT_ALIGN: av = "left"; break;
+       case RIGHT_ALIGN: av = "right"; break;
+       case CENTER_ALIGN: av = "center"; break;
+       default: assert(0);
+       }
+       printf("<mtd columnalign='%s'>", av);
+       p[j]->p[i]->output();
+       printf("</mtd>");
+      }
+      printf("</mtr>");
+    }
+    printf("</mtable>");
+  }
 }
 
 matrix_box::matrix_box(column *pp)




reply via email to

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