version 1.40, 2014/10/12 15:08:45 |
version 1.42, 2014/10/12 15:48:42 |
|
|
|
|
static const char *attrkeys[ATTRKEY__MAX] = { |
static const char *attrkeys[ATTRKEY__MAX] = { |
"choice", |
"choice", |
|
"close", |
"id", |
"id", |
|
"open", |
"rep" |
"rep" |
}; |
}; |
|
|
Line 863 pnode_printparamdef(struct parse *p, struct pnode *pn) |
|
Line 865 pnode_printparamdef(struct parse *p, struct pnode *pn) |
|
} |
} |
|
|
/* |
/* |
|
* The <mml:mfenced> node is a little peculiar. |
|
* First, it can have arbitrary open and closing tokens, which default |
|
* to parentheses. |
|
* Second, >1 arguments are separated by commas. |
|
*/ |
|
static void |
|
pnode_printmathfenced(struct parse *p, struct pnode *pn) |
|
{ |
|
struct pnode *pp; |
|
struct pattr *ap; |
|
|
|
TAILQ_FOREACH(ap, &pn->attrq, child) |
|
if (ATTRKEY_OPEN == ap->key) { |
|
printf("left %s ", ap->rawval); |
|
break; |
|
} |
|
if (NULL == ap) |
|
printf("left ( "); |
|
|
|
pp = TAILQ_FIRST(&pn->childq); |
|
pnode_print(p, pp); |
|
|
|
while (NULL != (pp = TAILQ_NEXT(pp, child))) { |
|
putchar(','); |
|
pnode_print(p, pp); |
|
} |
|
|
|
TAILQ_FOREACH(ap, &pn->attrq, child) |
|
if (ATTRKEY_CLOSE == ap->key) { |
|
printf("right %s ", ap->rawval); |
|
break; |
|
} |
|
if (NULL == ap) |
|
printf("right ) "); |
|
} |
|
|
|
/* |
* These math nodes require special handling because they have infix |
* These math nodes require special handling because they have infix |
* syntax, instead of the usual prefix or prefix. |
* syntax, instead of the usual prefix or prefix. |
* So we need to break up the first and second child node with a |
* So we need to break up the first and second child node with a |
Line 878 pnode_printmath(struct parse *p, struct pnode *pn) |
|
Line 917 pnode_printmath(struct parse *p, struct pnode *pn) |
|
|
|
switch (pn->node) { |
switch (pn->node) { |
case (NODE_MML_MSUP): |
case (NODE_MML_MSUP): |
printf(" sup "); |
fputs(" sup ", stdout); |
break; |
break; |
case (NODE_MML_MFRAC): |
case (NODE_MML_MFRAC): |
printf(" over "); |
fputs(" over ", stdout); |
break; |
break; |
case (NODE_MML_MSUB): |
case (NODE_MML_MSUB): |
printf(" sub "); |
fputs(" sub ", stdout); |
break; |
break; |
default: |
default: |
break; |
break; |
Line 1029 pnode_printprologue(struct parse *p, struct pnode *pn) |
|
Line 1068 pnode_printprologue(struct parse *p, struct pnode *pn) |
|
} |
} |
} |
} |
|
|
|
/* |
|
* We can have multiple <term> elements within a <varlistentry>, which |
|
* we should comma-separate as list headers. |
|
*/ |
static void |
static void |
pnode_printvarlistentry(struct parse *p, struct pnode *pn) |
pnode_printvarlistentry(struct parse *p, struct pnode *pn) |
{ |
{ |
struct pnode *pp; |
struct pnode *pp; |
|
int first = 1; |
|
|
assert(p->newln); |
assert(p->newln); |
|
fputs(".It", stdout); |
|
p->newln = 0; |
|
|
TAILQ_FOREACH(pp, &pn->childq, child) |
TAILQ_FOREACH(pp, &pn->childq, child) |
if (NODE_TERM == pp->node) { |
if (NODE_TERM == pp->node) { |
assert(p->newln); |
if ( ! first) |
fputs(".It", stdout); |
putchar(','); |
p->newln = 0; |
|
pnode_print(p, pp); |
pnode_print(p, pp); |
pnode_unlink(pp); |
pnode_unlink(pp); |
pnode_printmclose(p, 1); |
first = 0; |
return; |
} else |
} |
break; |
|
|
puts(".It"); |
putchar('\n'); |
p->newln = 1; |
p->newln = 1; |
} |
} |
|
|
Line 1241 pnode_print(struct parse *p, struct pnode *pn) |
|
Line 1287 pnode_print(struct parse *p, struct pnode *pn) |
|
p->newln = 0; |
p->newln = 0; |
break; |
break; |
case (NODE_MML_MFENCED): |
case (NODE_MML_MFENCED): |
printf("left {"); |
pnode_printmathfenced(p, pn); |
|
pnode_unlinksub(pn); |
break; |
break; |
case (NODE_MML_MROW): |
case (NODE_MML_MROW): |
case (NODE_MML_MI): |
case (NODE_MML_MI): |
Line 1440 pnode_print(struct parse *p, struct pnode *pn) |
|
Line 1487 pnode_print(struct parse *p, struct pnode *pn) |
|
putchar('\n'); |
putchar('\n'); |
puts(".EN"); |
puts(".EN"); |
p->newln = 1; |
p->newln = 1; |
break; |
|
case (NODE_MML_MFENCED): |
|
printf("right }"); |
|
break; |
break; |
case (NODE_MML_MROW): |
case (NODE_MML_MROW): |
case (NODE_MML_MI): |
case (NODE_MML_MI): |