version 1.1, 2019/03/26 18:32:07 |
version 1.3, 2019/03/26 21:52:09 |
|
|
}; |
}; |
|
|
static const struct element elements[] = { |
static const struct element elements[] = { |
{ "acronym", NODE_ACRONYM }, |
{ "acronym", NODE_IGNORE }, |
{ "affiliation", NODE_AFFILIATION }, |
{ "affiliation", NODE_AFFILIATION }, |
{ "anchor", NODE_ANCHOR }, |
{ "anchor", NODE_IGNORE }, |
{ "application", NODE_APPLICATION }, |
{ "application", NODE_APPLICATION }, |
{ "arg", NODE_ARG }, |
{ "arg", NODE_ARG }, |
{ "author", NODE_AUTHOR }, |
{ "author", NODE_AUTHOR }, |
Line 75 static const struct element elements[] = { |
|
Line 75 static const struct element elements[] = { |
|
{ "envar", NODE_ENVAR }, |
{ "envar", NODE_ENVAR }, |
{ "fieldsynopsis", NODE_FIELDSYNOPSIS }, |
{ "fieldsynopsis", NODE_FIELDSYNOPSIS }, |
{ "filename", NODE_FILENAME }, |
{ "filename", NODE_FILENAME }, |
{ "firstname", NODE_FIRSTNAME }, |
{ "firstname", NODE_IGNORE }, |
{ "firstterm", NODE_FIRSTTERM }, |
{ "firstterm", NODE_FIRSTTERM }, |
{ "footnote", NODE_FOOTNOTE }, |
{ "footnote", NODE_FOOTNOTE }, |
{ "funcdef", NODE_FUNCDEF }, |
{ "funcdef", NODE_FUNCDEF }, |
Line 115 static const struct element elements[] = { |
|
Line 115 static const struct element elements[] = { |
|
{ "option", NODE_OPTION }, |
{ "option", NODE_OPTION }, |
{ "orderedlist", NODE_ORDEREDLIST }, |
{ "orderedlist", NODE_ORDEREDLIST }, |
{ "orgname", NODE_ORGNAME }, |
{ "orgname", NODE_ORGNAME }, |
{ "othername", NODE_OTHERNAME }, |
{ "othername", NODE_IGNORE }, |
{ "para", NODE_PARA }, |
{ "para", NODE_PARA }, |
{ "paramdef", NODE_PARAMDEF }, |
{ "paramdef", NODE_PARAMDEF }, |
{ "parameter", NODE_PARAMETER }, |
{ "parameter", NODE_PARAMETER }, |
{ "part", NODE_SECTION }, |
{ "part", NODE_SECTION }, |
{ "personname", NODE_PERSONNAME }, |
{ "personname", NODE_PERSONNAME }, |
{ "phrase", NODE_PHRASE }, |
{ "phrase", NODE_IGNORE }, |
{ "preface", NODE_PREFACE }, |
{ "preface", NODE_PREFACE }, |
{ "primary", NODE_PRIMARY }, |
{ "primary", NODE_PRIMARY }, |
{ "programlisting", NODE_PROGRAMLISTING }, |
{ "programlisting", NODE_PROGRAMLISTING }, |
Line 157 static const struct element elements[] = { |
|
Line 157 static const struct element elements[] = { |
|
{ "spanspec", NODE_SPANSPEC }, |
{ "spanspec", NODE_SPANSPEC }, |
{ "structname", NODE_STRUCTNAME }, |
{ "structname", NODE_STRUCTNAME }, |
{ "subtitle", NODE_SUBTITLE }, |
{ "subtitle", NODE_SUBTITLE }, |
{ "surname", NODE_SURNAME }, |
{ "surname", NODE_IGNORE }, |
{ "synopsis", NODE_SYNOPSIS }, |
{ "synopsis", NODE_SYNOPSIS }, |
{ "table", NODE_TABLE }, |
{ "table", NODE_TABLE }, |
{ "tbody", NODE_TBODY }, |
{ "tbody", NODE_TBODY }, |
Line 167 static const struct element elements[] = { |
|
Line 167 static const struct element elements[] = { |
|
{ "thead", NODE_THEAD }, |
{ "thead", NODE_THEAD }, |
{ "tip", NODE_TIP }, |
{ "tip", NODE_TIP }, |
{ "title", NODE_TITLE }, |
{ "title", NODE_TITLE }, |
{ "trademark", NODE_TRADEMARK }, |
{ "trademark", NODE_IGNORE }, |
{ "type", NODE_TYPE }, |
{ "type", NODE_TYPE }, |
{ "ulink", NODE_ULINK }, |
{ "ulink", NODE_ULINK }, |
{ "userinput", NODE_USERINPUT }, |
{ "userinput", NODE_USERINPUT }, |
Line 176 static const struct element elements[] = { |
|
Line 176 static const struct element elements[] = { |
|
{ "varname", NODE_VARNAME }, |
{ "varname", NODE_VARNAME }, |
{ "warning", NODE_WARNING }, |
{ "warning", NODE_WARNING }, |
{ "wordasword", NODE_WORDASWORD }, |
{ "wordasword", NODE_WORDASWORD }, |
|
{ "xi:include", NODE_WARN }, |
{ "year", NODE_YEAR }, |
{ "year", NODE_YEAR }, |
{ NULL, NODE__MAX } |
{ NULL, NODE__MAX } |
}; |
}; |
Line 262 xml_elem_start(void *arg, const XML_Char *name, const |
|
Line 263 xml_elem_start(void *arg, const XML_Char *name, const |
|
if (ps->tree->flags && TREE_FAIL) |
if (ps->tree->flags && TREE_FAIL) |
return; |
return; |
|
|
/* FIXME: find a better way to ditch other namespaces. */ |
|
if (strcmp(name, "xi:include") == 0) |
|
return; |
|
|
|
/* Close out the text node, if there is one. */ |
/* Close out the text node, if there is one. */ |
if (ps->cur != NULL && ps->cur->node == NODE_TEXT) { |
if (ps->cur != NULL && ps->cur->node == NODE_TEXT) { |
pnode_trim(ps->cur); |
pnode_trim(ps->cur); |
Line 284 xml_elem_start(void *arg, const XML_Char *name, const |
|
Line 281 xml_elem_start(void *arg, const XML_Char *name, const |
|
return; |
return; |
} |
} |
|
|
if (elem->node == NODE_INLINEEQUATION) |
switch (elem->node) { |
|
case NODE_WARN: |
|
if (ps->warn) |
|
fprintf(stderr, "%s:%zu:%zu: warning: " |
|
"ignoring element <%s>\n", ps->fname, |
|
XML_GetCurrentLineNumber(ps->xml), |
|
XML_GetCurrentColumnNumber(ps->xml), name); |
|
/* FALLTHROUGH */ |
|
case NODE_IGNORE: |
|
return; |
|
case NODE_INLINEEQUATION: |
ps->tree->flags |= TREE_EQN; |
ps->tree->flags |= TREE_EQN; |
|
break; |
|
default: |
|
break; |
|
} |
|
|
if ((dat = calloc(1, sizeof(*dat))) == NULL) { |
if ((dat = calloc(1, sizeof(*dat))) == NULL) { |
perror(NULL); |
perror(NULL); |
|
|
xml_elem_end(void *arg, const XML_Char *name) |
xml_elem_end(void *arg, const XML_Char *name) |
{ |
{ |
struct parse *ps; |
struct parse *ps; |
|
const struct element *elem; |
|
|
ps = arg; |
ps = arg; |
if (ps->tree->flags && TREE_FAIL) |
if (ps->tree->flags && TREE_FAIL) |
return; |
return; |
|
|
/* FIXME: find a better way to ditch other namespaces. */ |
|
if (strcmp(name, "xi:include") == 0) |
|
return; |
|
|
|
/* Close out the text node, if there is one. */ |
/* Close out the text node, if there is one. */ |
if (ps->cur->node == NODE_TEXT) { |
if (ps->cur->node == NODE_TEXT) { |
pnode_trim(ps->cur); |
pnode_trim(ps->cur); |
ps->cur = ps->cur->parent; |
ps->cur = ps->cur->parent; |
} |
} |
ps->cur = ps->cur->parent; |
|
|
for (elem = elements; elem->name != NULL; elem++) |
|
if (strcmp(elem->name, name) == 0) |
|
break; |
|
|
|
switch (elem->node) { |
|
case NODE_IGNORE: |
|
case NODE_WARN: |
|
break; |
|
default: |
|
assert(elem->node == ps->cur->node); |
|
ps->cur = ps->cur->parent; |
|
} |
} |
} |
|
|
struct parse * |
struct parse * |