=================================================================== RCS file: /cvs/docbook2mdoc/node.h,v retrieving revision 1.9 retrieving revision 1.25 diff -u -p -r1.9 -r1.25 --- docbook2mdoc/node.h 2019/04/03 17:53:02 1.9 +++ docbook2mdoc/node.h 2019/04/14 18:07:35 1.25 @@ -1,4 +1,4 @@ -/* $Id: node.h,v 1.9 2019/04/03 17:53:02 schwarze Exp $ */ +/* $Id: node.h,v 1.25 2019/04/14 18:07:35 schwarze Exp $ */ /* * Copyright (c) 2014 Kristaps Dzonsons * Copyright (c) 2019 Ingo Schwarze @@ -22,21 +22,28 @@ */ /* + * 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. */ +}; + +/* * All node types used for formatting purposes. * More DocBook XML elements are recognized, but remapped or discarded. */ enum nodeid { - NODE_DELETE_WARN, - NODE_DELETE, - NODE_IGNORE, - /* Alpha-ordered hereafter. */ - NODE_AFFILIATION, - NODE_APPLICATION, + NODE_APPENDIX, NODE_ARG, NODE_AUTHOR, NODE_AUTHORGROUP, NODE_BLOCKQUOTE, - NODE_BOOK, NODE_BOOKINFO, NODE_CAUTION, NODE_CITEREFENTRY, @@ -48,13 +55,14 @@ enum nodeid { NODE_CONTRIB, NODE_COPYRIGHT, NODE_DATE, + NODE_DOCTYPE, NODE_EDITOR, NODE_EMAIL, NODE_EMPHASIS, + NODE_ENTITY, NODE_ENTRY, NODE_ENVAR, NODE_ERRORNAME, - NODE_ESCAPE, NODE_FIELDSYNOPSIS, NODE_FILENAME, NODE_FIRSTTERM, @@ -66,7 +74,7 @@ enum nodeid { NODE_FUNCTION, NODE_GLOSSTERM, NODE_GROUP, - NODE_HOLDER, + NODE_INCLUDE, NODE_INDEX, NODE_INFO, NODE_INFORMALEQUATION, @@ -79,6 +87,7 @@ enum nodeid { NODE_LITERAL, NODE_LITERALLAYOUT, NODE_MANVOLNUM, + NODE_MARKUP, NODE_MEMBER, NODE_MML_MATH, NODE_MML_MFENCED, @@ -93,7 +102,6 @@ enum nodeid { NODE_NOTE, NODE_OPTION, NODE_ORDEREDLIST, - NODE_ORGNAME, NODE_PARA, NODE_PARAMDEF, NODE_PARAMETER, @@ -101,6 +109,7 @@ enum nodeid { NODE_PREFACE, NODE_PROGRAMLISTING, NODE_PROMPT, + NODE_PUBDATE, NODE_QUOTE, NODE_REFCLASS, NODE_REFDESCRIPTOR, @@ -114,35 +123,37 @@ enum nodeid { NODE_REFNAMEDIV, NODE_REFPURPOSE, NODE_REFSYNOPSISDIV, - NODE_RELEASEINFO, NODE_REPLACEABLE, NODE_ROW, NODE_SBR, NODE_SCREEN, NODE_SECTION, - NODE_SGMLTAG, NODE_SIMPLELIST, + NODE_SIMPLESECT, NODE_SPANSPEC, NODE_SUBTITLE, NODE_SYNOPSIS, + NODE_SYSTEMITEM, NODE_TABLE, NODE_TBODY, NODE_TERM, - NODE_TEXT, NODE_TFOOT, NODE_TGROUP, NODE_THEAD, NODE_TIP, NODE_TITLE, NODE_TYPE, - NODE_ULINK, NODE_VARIABLELIST, NODE_VARLISTENTRY, NODE_VARNAME, NODE_WARNING, NODE_WORDASWORD, - NODE_YEAR, - NODE__MAX + NODE_UNKNOWN, + NODE_TEXT, + NODE_ESCAPE, + NODE_IGNORE, + NODE_DELETE, + NODE_DELETE_WARN }; /* @@ -155,10 +166,18 @@ enum attrkey { ATTRKEY_CLASS, ATTRKEY_CLOSE, ATTRKEY_COLS, + ATTRKEY_DEFINITION, + ATTRKEY_ENDTERM, + ATTRKEY_HREF, ATTRKEY_ID, ATTRKEY_LINKEND, + ATTRKEY_NAME, ATTRKEY_OPEN, + ATTRKEY_PUBLIC, ATTRKEY_REP, + ATTRKEY_SYSTEM, + ATTRKEY_URL, + ATTRKEY_XLINK_HREF, ATTRKEY__MAX }; @@ -168,12 +187,15 @@ enum attrkey { */ enum attrval { /* Alpha-order... */ + ATTRVAL_EVENT, + ATTRVAL_IPADDRESS, ATTRVAL_MONOSPACED, ATTRVAL_NOREPEAT, ATTRVAL_OPT, ATTRVAL_PLAIN, ATTRVAL_REPEAT, ATTRVAL_REQ, + ATTRVAL_SYSTEMNAME, ATTRVAL__MAX }; @@ -196,8 +218,7 @@ struct pattr { struct pnode { enum nodeid node; /* Node type. */ char *b; /* String value. */ - char *real; /* Storage for "b". */ - size_t bsz; /* strlen(b) */ + int spc; /* Whitespace before this node. */ struct pnode *parent; /* Parent node or NULL. */ struct pnodeq childq; /* Queue of children. */ struct pattrq attrq; /* Attributes of the node. */ @@ -210,16 +231,24 @@ struct pnode { struct ptree { struct pnode *root; /* The document element. */ int flags; -#define TREE_FAIL (1 << 0) /* A fatal parse error occurred. */ -#define TREE_EQN (1 << 1) /* The document needs inline eqn(7). */ -#define TREE_CLOSED (1 << 2) /* The document element was closed. */ +#define TREE_ERROR (1 << 0) /* A parse error occurred. */ +#define TREE_WARN (1 << 1) /* A parser warning occurred. */ +#define TREE_CLOSED (1 << 3) /* The document element was closed. */ }; enum attrkey attrkey_parse(const char *); +const char *attrkey_name(enum attrkey); 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 *); void pnode_unlink(struct pnode *); void pnode_unlinksub(struct pnode *); enum attrval pnode_getattr(struct pnode *, enum attrkey); const char *pnode_getattr_raw(struct pnode *, enum attrkey, const char *); struct pnode *pnode_findfirst(struct pnode *, enum nodeid); +struct pnode *pnode_takefirst(struct pnode *, enum nodeid);