version 1.55, 2019/04/29 02:00:50 |
version 1.60, 2019/05/07 23:41:48 |
Line 97 static const struct alias aliases[] = { |
|
Line 97 static const struct alias aliases[] = { |
|
{ "imageobject", NODE_IGNORE }, |
{ "imageobject", NODE_IGNORE }, |
{ "indexterm", NODE_DELETE }, |
{ "indexterm", NODE_DELETE }, |
{ "informaltable", NODE_TABLE }, |
{ "informaltable", NODE_TABLE }, |
|
{ "jobtitle", NODE_IGNORE }, |
{ "keycap", NODE_KEYSYM }, |
{ "keycap", NODE_KEYSYM }, |
{ "keycode", NODE_IGNORE }, |
{ "keycode", NODE_IGNORE }, |
{ "keycombo", NODE_IGNORE }, |
{ "keycombo", NODE_IGNORE }, |
{ "mediaobject", NODE_BLOCKQUOTE }, |
{ "mediaobject", NODE_BLOCKQUOTE }, |
|
{ "orgdiv", NODE_IGNORE }, |
{ "orgname", NODE_IGNORE }, |
{ "orgname", NODE_IGNORE }, |
{ "othercredit", NODE_AUTHOR }, |
{ "othercredit", NODE_AUTHOR }, |
{ "othername", NODE_PERSONNAME }, |
{ "othername", NODE_PERSONNAME }, |
Line 130 static const struct alias aliases[] = { |
|
Line 132 static const struct alias aliases[] = { |
|
{ "trademark", NODE_IGNORE }, |
{ "trademark", NODE_IGNORE }, |
{ "ulink", NODE_LINK }, |
{ "ulink", NODE_LINK }, |
{ "userinput", NODE_LITERAL }, |
{ "userinput", NODE_LITERAL }, |
{ "year", NODE_IGNORE }, |
|
{ NULL, NODE_IGNORE } |
{ NULL, NODE_IGNORE } |
}; |
}; |
|
|
Line 269 xml_text(struct parse *p, const char *word, int sz) |
|
Line 270 xml_text(struct parse *p, const char *word, int sz) |
|
|
|
n = pnode_alloc(p->cur); |
n = pnode_alloc(p->cur); |
n->node = NODE_TEXT; |
n->node = NODE_TEXT; |
n->flags = ((p->flags & PFLAG_LINE) ? NFLAG_LINE : 0) | |
if (p->flags & PFLAG_LINE && TAILQ_PREV(n, pnodeq, child) != NULL) |
((p->flags & PFLAG_SPC) ? NFLAG_SPC : 0); |
n->flags |= NFLAG_LINE; |
|
if (p->flags & PFLAG_SPC) |
|
n->flags |= NFLAG_SPC; |
p->flags &= ~(PFLAG_LINE | PFLAG_SPC); |
p->flags &= ~(PFLAG_LINE | PFLAG_SPC); |
|
|
/* |
/* |
Line 353 pnode_closetext(struct parse *p, int check_last_word) |
|
Line 356 pnode_closetext(struct parse *p, int check_last_word) |
|
|
|
while (cp > n->b && !isspace((unsigned char)cp[-1])) |
while (cp > n->b && !isspace((unsigned char)cp[-1])) |
cp--; |
cp--; |
|
last_word = cp; |
|
while (cp > n->b && isspace((unsigned char)cp[-1])) |
|
cp--; |
if (cp == n->b) |
if (cp == n->b) |
return; |
return; |
|
*cp = '\0'; |
|
|
last_word = cp; |
|
while (cp > n->b && isspace((unsigned char)cp[-1])) |
|
*--cp = '\0'; |
|
|
|
/* Move the last word into its own node, for use with .Pf. */ |
/* Move the last word into its own node, for use with .Pf. */ |
|
|
n = pnode_alloc_text(p->cur, last_word); |
n = pnode_alloc_text(p->cur, last_word); |
Line 373 xml_entity(struct parse *p, const char *name) |
|
Line 376 xml_entity(struct parse *p, const char *name) |
|
struct pnode *n; |
struct pnode *n; |
const char *ccp; |
const char *ccp; |
char *cp; |
char *cp; |
unsigned int codepoint; |
long codepoint; |
enum pstate pstate; |
enum pstate pstate; |
|
|
if (p->del > 0) |
if (p->del > 0) |
Line 418 xml_entity(struct parse *p, const char *name) |
|
Line 421 xml_entity(struct parse *p, const char *name) |
|
} |
} |
} |
} |
if (*name == '#') { |
if (*name == '#') { |
codepoint = strtonum(name + 1, 0, 0x10ffff, &ccp); |
errno = 0; |
if (ccp == NULL) { |
if (name[1] == 'x') { |
|
ccp = name + 2; |
|
codepoint = strtol(ccp, &cp, 16); |
|
} else { |
|
ccp = name + 1; |
|
codepoint = strtol(ccp, &cp, 10); |
|
} |
|
if (*ccp != '\0' && *cp == '\0' && errno != ERANGE && |
|
codepoint >= 0 && codepoint <= 0x10ffff) { |
n = pnode_alloc(p->cur); |
n = pnode_alloc(p->cur); |
xasprintf(&n->b, "\\[u%4.4X]", codepoint); |
xasprintf(&n->b, "\\[u%4.4X]", codepoint); |
goto done; |
goto done; |
Line 434 xml_entity(struct parse *p, const char *name) |
|
Line 445 xml_entity(struct parse *p, const char *name) |
|
n->b = xstrdup(entity->roff); |
n->b = xstrdup(entity->roff); |
done: |
done: |
n->node = NODE_ESCAPE; |
n->node = NODE_ESCAPE; |
n->flags = ((p->flags & PFLAG_LINE) ? NFLAG_LINE : 0) | |
if (p->flags & PFLAG_LINE && TAILQ_PREV(n, pnodeq, child) != NULL) |
((p->flags & PFLAG_SPC) ? NFLAG_SPC : 0); |
n->flags |= NFLAG_LINE; |
|
if (p->flags & PFLAG_SPC) |
|
n->flags |= NFLAG_SPC; |
p->flags &= ~(PFLAG_LINE | PFLAG_SPC); |
p->flags &= ~(PFLAG_LINE | PFLAG_SPC); |
} |
} |
|
|
Line 507 xml_elem_start(struct parse *p, const char *name) |
|
Line 520 xml_elem_start(struct parse *p, const char *name) |
|
} |
} |
|
|
n = pnode_alloc(p->cur); |
n = pnode_alloc(p->cur); |
|
if (p->flags & PFLAG_LINE && p->cur != NULL && |
|
TAILQ_PREV(n, pnodeq, child) != NULL) |
|
n->flags |= NFLAG_LINE; |
|
p->flags &= ~PFLAG_LINE; |
|
|
/* |
/* |
* Some elements are self-closing. |
* Some elements are self-closing. |
Line 527 xml_elem_start(struct parse *p, const char *name) |
|
Line 544 xml_elem_start(struct parse *p, const char *name) |
|
switch (pnode_class(p->ncur)) { |
switch (pnode_class(p->ncur)) { |
case CLASS_LINE: |
case CLASS_LINE: |
case CLASS_ENCL: |
case CLASS_ENCL: |
n->flags = ((p->flags & PFLAG_LINE) ? NFLAG_LINE : 0) | |
if (p->flags & PFLAG_SPC) |
((p->flags & PFLAG_SPC) ? NFLAG_SPC : 0); |
n->flags |= NFLAG_SPC; |
break; |
break; |
case CLASS_NOFILL: |
case CLASS_NOFILL: |
p->nofill++; |
p->nofill++; |