version 1.56, 2019/03/22 16:42:49 |
version 1.61, 2019/03/22 17:28:59 |
|
|
|
|
static const char *attrkeys[ATTRKEY__MAX] = { |
static const char *attrkeys[ATTRKEY__MAX] = { |
"choice", |
"choice", |
|
"class", |
"close", |
"close", |
"id", |
"id", |
|
"linkend", |
"open", |
"open", |
"rep" |
"rep" |
}; |
}; |
|
|
static const char *attrvals[ATTRVAL__MAX] = { |
static const char *attrvals[ATTRVAL__MAX] = { |
|
"monospaced", |
"norepeat", |
"norepeat", |
"opt", |
"opt", |
"plain", |
"plain", |
Line 490 pnode_unlinksub(struct pnode *pn) |
|
Line 493 pnode_unlinksub(struct pnode *pn) |
|
} |
} |
|
|
/* |
/* |
|
* Retrieve an enumeration attribute from a node. |
|
* Return ATTRVAL__MAX if the node has no such attribute. |
|
*/ |
|
enum attrval |
|
pnode_getattr(struct pnode *pn, enum attrkey key) |
|
{ |
|
struct pattr *ap; |
|
|
|
TAILQ_FOREACH(ap, &pn->attrq, child) |
|
if (ap->key == key) |
|
return ap->val; |
|
return(ATTRVAL__MAX); |
|
} |
|
|
|
/* |
|
* Retrieve an attribute string from a node. |
|
* Return defval if the node has no such attribute. |
|
*/ |
|
const char * |
|
pnode_getattr_raw(struct pnode *pn, enum attrkey key, const char *defval) |
|
{ |
|
struct pattr *ap; |
|
|
|
TAILQ_FOREACH(ap, &pn->attrq, child) |
|
if (ap->key == key) |
|
return ATTRVAL__MAX == ap->val ? ap->rawval : |
|
attrvals[ap->val]; |
|
return(defval); |
|
} |
|
|
|
/* |
* Reset the lookaside buffer. |
* Reset the lookaside buffer. |
*/ |
*/ |
static void |
static void |
Line 686 pnode_printpara(struct parse *p, struct pnode *pn) |
|
Line 720 pnode_printpara(struct parse *p, struct pnode *pn) |
|
struct pnode *pp; |
struct pnode *pp; |
|
|
assert(p->newln); |
assert(p->newln); |
if (NULL == pn->parent || NODE_LISTITEM == pn->parent->node) |
if ((pp = TAILQ_PREV(pn, pnodeq, child)) == NULL && |
|
(pp = pn->parent) == NULL) |
return; |
return; |
|
|
pp = TAILQ_PREV(pn, pnodeq, child); |
switch (pp->node) { |
if (NULL == pp) |
case NODE_ENTRY: |
pp = pn->parent; |
case NODE_LISTITEM: |
if ((NODE_SECTION != pp->node && NODE_PREFACE != pp->node) || |
return; |
2 < p->level) |
case NODE_PREFACE: |
puts(".Pp"); |
case NODE_SECTION: |
|
if (p->level < 3) |
|
return; |
|
break; |
|
default: |
|
break; |
|
} |
|
puts(".Pp"); |
} |
} |
|
|
/* |
/* |
|
|
pnode_printmathfenced(struct parse *p, struct pnode *pn) |
pnode_printmathfenced(struct parse *p, struct pnode *pn) |
{ |
{ |
struct pnode *pp; |
struct pnode *pp; |
struct pattr *ap; |
|
|
|
TAILQ_FOREACH(ap, &pn->attrq, child) |
printf("left %s ", pnode_getattr_raw(pn, ATTRKEY_OPEN, "(")); |
if (ATTRKEY_OPEN == ap->key) { |
|
printf("left %s ", ap->rawval); |
|
break; |
|
} |
|
if (NULL == ap) |
|
printf("left ( "); |
|
|
|
pp = TAILQ_FIRST(&pn->childq); |
pp = TAILQ_FIRST(&pn->childq); |
pnode_print(p, pp); |
pnode_print(p, pp); |
Line 928 pnode_printmathfenced(struct parse *p, struct pnode *p |
|
Line 963 pnode_printmathfenced(struct parse *p, struct pnode *p |
|
pnode_print(p, pp); |
pnode_print(p, pp); |
} |
} |
|
|
TAILQ_FOREACH(ap, &pn->attrq, child) |
printf("right %s ", pnode_getattr_raw(pn, ATTRKEY_CLOSE, ")")); |
if (ATTRKEY_CLOSE == ap->key) { |
|
printf("right %s ", ap->rawval); |
|
break; |
|
} |
|
if (NULL == ap) |
|
printf("right ) "); |
|
} |
} |
|
|
/* |
/* |
|
|
pnode_printprologue(struct parse *p, struct pnode *pn) |
pnode_printprologue(struct parse *p, struct pnode *pn) |
{ |
{ |
struct pnode *pp; |
struct pnode *pp; |
struct pattr *ap; |
|
const char *name; |
|
|
|
pp = NULL == p->root ? NULL : |
pp = NULL == p->root ? NULL : |
pnode_findfirst(p->root, NODE_REFMETA); |
pnode_findfirst(p->root, NODE_REFMETA); |
Line 1099 pnode_printprologue(struct parse *p, struct pnode *pn) |
|
Line 1126 pnode_printprologue(struct parse *p, struct pnode *pn) |
|
if (NULL != pp) { |
if (NULL != pp) { |
pnode_printrefmeta(p, pp); |
pnode_printrefmeta(p, pp); |
pnode_unlink(pp); |
pnode_unlink(pp); |
} else { |
} else |
name = "UNKNOWN"; |
printf(".Dt %s 1\n", |
TAILQ_FOREACH(ap, &p->root->attrq, child) { |
pnode_getattr_raw(p->root, ATTRKEY_ID, "UNKNOWN")); |
if (ATTRKEY_ID == ap->key) { |
|
name = ap->rawval; |
|
break; |
|
} |
|
} |
|
printf(".Dt %s 1\n", name); |
|
} |
|
puts(".Os"); |
puts(".Os"); |
|
|
if (PARSE_EQN & p->flags) { |
if (PARSE_EQN & p->flags) { |
|
|
pnode_print(struct parse *p, struct pnode *pn) |
pnode_print(struct parse *p, struct pnode *pn) |
{ |
{ |
struct pnode *pp; |
struct pnode *pp; |
|
const char *ccp; |
char *cp; |
char *cp; |
int last, sv; |
int last, sv; |
|
|
Line 1311 pnode_print(struct parse *p, struct pnode *pn) |
|
Line 1332 pnode_print(struct parse *p, struct pnode *pn) |
|
fputs("An", stdout); |
fputs("An", stdout); |
break; |
break; |
case (NODE_EMPHASIS): |
case (NODE_EMPHASIS): |
|
case (NODE_FIRSTTERM): |
pnode_printmopen(p); |
pnode_printmopen(p); |
fputs("Em", stdout); |
fputs("Em", stdout); |
break; |
break; |
Line 1360 pnode_print(struct parse *p, struct pnode *pn) |
|
Line 1382 pnode_print(struct parse *p, struct pnode *pn) |
|
assert(p->newln); |
assert(p->newln); |
puts(".Sh LEGAL NOTICE"); |
puts(".Sh LEGAL NOTICE"); |
break; |
break; |
|
case (NODE_LINK): |
|
ccp = pnode_getattr_raw(pn, ATTRKEY_LINKEND, NULL); |
|
if (NULL == ccp) |
|
break; |
|
pnode_printmopen(p); |
|
printf("Sx %s\n", ccp); |
|
p->newln = 1; |
|
return; |
case (NODE_LITERAL): |
case (NODE_LITERAL): |
pnode_printmopen(p); |
pnode_printmopen(p); |
fputs("Li", stdout); |
fputs("Li", stdout); |
break; |
break; |
|
case (NODE_LITERALLAYOUT): |
|
assert(p->newln); |
|
puts(".Bd -literal"); |
|
break; |
case (NODE_MML_MFENCED): |
case (NODE_MML_MFENCED): |
pnode_printmathfenced(p, pn); |
pnode_printmathfenced(p, pn); |
pnode_unlinksub(pn); |
pnode_unlinksub(pn); |
Line 1406 pnode_print(struct parse *p, struct pnode *pn) |
|
Line 1440 pnode_print(struct parse *p, struct pnode *pn) |
|
pnode_printmopen(p); |
pnode_printmopen(p); |
fputs("Qo", stdout); |
fputs("Qo", stdout); |
break; |
break; |
case (NODE_LITERALLAYOUT): |
|
/* FALLTHROUGH */ |
|
case (NODE_PROGRAMLISTING): |
case (NODE_PROGRAMLISTING): |
/* FALLTHROUGH */ |
|
case (NODE_SCREEN): |
case (NODE_SCREEN): |
assert(p->newln); |
assert(p->newln); |
puts(".Bd -literal"); |
printf(".Bd %s\n", ATTRVAL_MONOSPACED == |
|
pnode_getattr(pn, ATTRKEY_CLASS) ? |
|
"-literal" : "-unfilled"); |
break; |
break; |
case (NODE_REFENTRYINFO): |
case (NODE_REFENTRYINFO): |
/* Suppress. */ |
/* Suppress. */ |
Line 1586 pnode_print(struct parse *p, struct pnode *pn) |
|
Line 1619 pnode_print(struct parse *p, struct pnode *pn) |
|
case (NODE_EMPHASIS): |
case (NODE_EMPHASIS): |
case (NODE_ENVAR): |
case (NODE_ENVAR): |
case (NODE_FILENAME): |
case (NODE_FILENAME): |
|
case (NODE_FIRSTTERM): |
case (NODE_FUNCTION): |
case (NODE_FUNCTION): |
case (NODE_FUNCSYNOPSISINFO): |
case (NODE_FUNCSYNOPSISINFO): |
case (NODE_LITERAL): |
case (NODE_LITERAL): |