version 1.19, 2019/04/12 11:37:09 |
version 1.34, 2019/04/28 15:32:05 |
|
|
*/ |
*/ |
|
|
/* |
/* |
|
* How the output from each node behaves |
|
* with respect to mdoc(7) structure. |
|
*/ |
|
enum nodeclass { |
|
CLASS_VOID = 0, /* No output at all, children are skipped. */ |
|
CLASS_TEXT, /* Node prints only text, no macros. */ |
|
CLASS_TRANS, /* Transparent: only the children are shown. */ |
|
CLASS_LINE, /* Generates only simple in-line macros. */ |
|
CLASS_ENCL, /* Explicit or implicit partial blocks. */ |
|
CLASS_BLOCK, /* Output linebreak before and after. */ |
|
CLASS_NOFILL /* Block preserving leading whitespace. */ |
|
}; |
|
|
|
/* |
* All node types used for formatting purposes. |
* All node types used for formatting purposes. |
* More DocBook XML elements are recognized, but remapped or discarded. |
* More DocBook XML elements are recognized, but remapped or discarded. |
*/ |
*/ |
enum nodeid { |
enum nodeid { |
NODE_DELETE_WARN, |
|
NODE_DELETE, |
|
NODE_IGNORE, |
|
/* Alpha-ordered hereafter. */ |
|
NODE_AFFILIATION, |
|
NODE_APPENDIX, |
NODE_APPENDIX, |
NODE_APPLICATION, |
|
NODE_ARG, |
NODE_ARG, |
NODE_AUTHOR, |
NODE_AUTHOR, |
NODE_AUTHORGROUP, |
NODE_AUTHORGROUP, |
|
|
NODE_ENTRY, |
NODE_ENTRY, |
NODE_ENVAR, |
NODE_ENVAR, |
NODE_ERRORNAME, |
NODE_ERRORNAME, |
NODE_ESCAPE, |
|
NODE_FIELDSYNOPSIS, |
NODE_FIELDSYNOPSIS, |
NODE_FILENAME, |
NODE_FILENAME, |
NODE_FIRSTTERM, |
NODE_FIRSTTERM, |
|
|
NODE_FUNCTION, |
NODE_FUNCTION, |
NODE_GLOSSTERM, |
NODE_GLOSSTERM, |
NODE_GROUP, |
NODE_GROUP, |
NODE_HOLDER, |
NODE_IMAGEDATA, |
NODE_INCLUDE, |
NODE_INCLUDE, |
NODE_INDEX, |
NODE_INDEX, |
NODE_INFO, |
NODE_INFO, |
|
|
NODE_MML_MSUP, |
NODE_MML_MSUP, |
NODE_MODIFIER, |
NODE_MODIFIER, |
NODE_NOTE, |
NODE_NOTE, |
|
NODE_OLINK, |
NODE_OPTION, |
NODE_OPTION, |
NODE_ORDEREDLIST, |
NODE_ORDEREDLIST, |
NODE_ORGNAME, |
|
NODE_PARA, |
NODE_PARA, |
NODE_PARAMDEF, |
NODE_PARAMDEF, |
NODE_PARAMETER, |
NODE_PARAMETER, |
NODE_PERSONNAME, |
NODE_PERSONNAME, |
NODE_PREFACE, |
NODE_PREFACE, |
|
NODE_PRODUCTNAME, |
NODE_PROGRAMLISTING, |
NODE_PROGRAMLISTING, |
NODE_PROMPT, |
NODE_PROMPT, |
|
NODE_PUBDATE, |
NODE_QUOTE, |
NODE_QUOTE, |
NODE_REFCLASS, |
NODE_REFCLASS, |
NODE_REFDESCRIPTOR, |
NODE_REFDESCRIPTOR, |
|
|
NODE_REFNAMEDIV, |
NODE_REFNAMEDIV, |
NODE_REFPURPOSE, |
NODE_REFPURPOSE, |
NODE_REFSYNOPSISDIV, |
NODE_REFSYNOPSISDIV, |
NODE_RELEASEINFO, |
|
NODE_REPLACEABLE, |
NODE_REPLACEABLE, |
NODE_ROW, |
NODE_ROW, |
NODE_SBR, |
NODE_SBR, |
NODE_SCREEN, |
NODE_SCREEN, |
NODE_SECTION, |
NODE_SECTION, |
NODE_SIMPLELIST, |
NODE_SIMPLELIST, |
|
NODE_SIMPLESECT, |
NODE_SPANSPEC, |
NODE_SPANSPEC, |
|
NODE_SUBSCRIPT, |
NODE_SUBTITLE, |
NODE_SUBTITLE, |
|
NODE_SUPERSCRIPT, |
NODE_SYNOPSIS, |
NODE_SYNOPSIS, |
|
NODE_SYSTEMITEM, |
NODE_TABLE, |
NODE_TABLE, |
NODE_TBODY, |
NODE_TBODY, |
NODE_TERM, |
NODE_TERM, |
NODE_TEXT, |
|
NODE_TFOOT, |
NODE_TFOOT, |
NODE_TGROUP, |
NODE_TGROUP, |
NODE_THEAD, |
NODE_THEAD, |
NODE_TIP, |
NODE_TIP, |
NODE_TITLE, |
NODE_TITLE, |
NODE_TYPE, |
NODE_TYPE, |
NODE_ULINK, |
|
NODE_VARIABLELIST, |
NODE_VARIABLELIST, |
NODE_VARLISTENTRY, |
NODE_VARLISTENTRY, |
NODE_VARNAME, |
NODE_VARNAME, |
|
NODE_VOID, |
NODE_WARNING, |
NODE_WARNING, |
NODE_WORDASWORD, |
NODE_WORDASWORD, |
NODE_YEAR, |
NODE_XREF, |
NODE__MAX |
NODE_UNKNOWN, |
|
NODE_TEXT, |
|
NODE_ESCAPE, |
|
NODE_IGNORE, |
|
NODE_DELETE, |
|
NODE_DELETE_WARN |
}; |
}; |
|
|
/* |
/* |
|
|
ATTRKEY_COLS, |
ATTRKEY_COLS, |
ATTRKEY_DEFINITION, |
ATTRKEY_DEFINITION, |
ATTRKEY_ENDTERM, |
ATTRKEY_ENDTERM, |
|
ATTRKEY_ENTITYREF, |
|
ATTRKEY_FILEREF, |
ATTRKEY_HREF, |
ATTRKEY_HREF, |
ATTRKEY_ID, |
ATTRKEY_ID, |
ATTRKEY_LINKEND, |
ATTRKEY_LINKEND, |
|
ATTRKEY_LOCALINFO, |
ATTRKEY_NAME, |
ATTRKEY_NAME, |
ATTRKEY_OPEN, |
ATTRKEY_OPEN, |
ATTRKEY_PUBLIC, |
ATTRKEY_PUBLIC, |
ATTRKEY_REP, |
ATTRKEY_REP, |
ATTRKEY_SYSTEM, |
ATTRKEY_SYSTEM, |
|
ATTRKEY_TARGETDOC, |
|
ATTRKEY_TARGETPTR, |
ATTRKEY_URL, |
ATTRKEY_URL, |
ATTRKEY_XLINK_HREF, |
ATTRKEY_XLINK_HREF, |
ATTRKEY__MAX |
ATTRKEY__MAX |
|
|
*/ |
*/ |
enum attrval { |
enum attrval { |
/* Alpha-order... */ |
/* Alpha-order... */ |
|
ATTRVAL_EVENT, |
|
ATTRVAL_IPADDRESS, |
ATTRVAL_MONOSPACED, |
ATTRVAL_MONOSPACED, |
ATTRVAL_NOREPEAT, |
ATTRVAL_NOREPEAT, |
ATTRVAL_OPT, |
ATTRVAL_OPT, |
ATTRVAL_PLAIN, |
ATTRVAL_PLAIN, |
ATTRVAL_REPEAT, |
ATTRVAL_REPEAT, |
ATTRVAL_REQ, |
ATTRVAL_REQ, |
|
ATTRVAL_SYSTEMNAME, |
ATTRVAL__MAX |
ATTRVAL__MAX |
}; |
}; |
|
|
|
|
struct pnode { |
struct pnode { |
enum nodeid node; /* Node type. */ |
enum nodeid node; /* Node type. */ |
char *b; /* String value. */ |
char *b; /* String value. */ |
int spc; /* Whitespace before this node. */ |
|
struct pnode *parent; /* Parent node or NULL. */ |
struct pnode *parent; /* Parent node or NULL. */ |
|
int flags; |
|
#define NFLAG_LINE (1 << 0) /* New line before this node. */ |
|
#define NFLAG_SPC (1 << 1) /* Whitespace before this node. */ |
struct pnodeq childq; /* Queue of children. */ |
struct pnodeq childq; /* Queue of children. */ |
struct pattrq attrq; /* Attributes of the node. */ |
struct pattrq attrq; /* Attributes of the node. */ |
TAILQ_ENTRY(pnode) child; |
TAILQ_ENTRY(pnode) child; |
|
|
|
|
|
|
enum attrkey attrkey_parse(const char *); |
enum attrkey attrkey_parse(const char *); |
|
const char *attrkey_name(enum attrkey); |
enum attrval attrval_parse(const char *); |
enum attrval attrval_parse(const char *); |
|
const char *attr_getval(const struct pattr *a); |
|
enum nodeid pnode_parse(const char *name); |
|
const char *pnode_name(enum nodeid); |
|
enum nodeclass pnode_class(enum nodeid); |
|
|
struct pnode *pnode_alloc(struct pnode *); |
struct pnode *pnode_alloc(struct pnode *); |
|
struct pnode *pnode_alloc_text(struct pnode *, const char *); |
void pnode_unlink(struct pnode *); |
void pnode_unlink(struct pnode *); |
void pnode_unlinksub(struct pnode *); |
void pnode_unlinksub(struct pnode *); |
enum attrval pnode_getattr(struct pnode *, enum attrkey); |
enum attrval pnode_getattr(struct pnode *, enum attrkey); |
const char *pnode_getattr_raw(struct pnode *, enum attrkey, const char *); |
const char *pnode_getattr_raw(struct pnode *, enum attrkey, const char *); |
struct pnode *pnode_findfirst(struct pnode *, enum nodeid); |
struct pnode *pnode_findfirst(struct pnode *, enum nodeid); |
|
struct pnode *pnode_takefirst(struct pnode *, enum nodeid); |