From fec3b0f270a27ab0e27fbde42138a4378ff9e39e Mon Sep 17 00:00:00 2001 From: ng0 Date: Sun, 21 Apr 2019 08:55:09 +0000 Subject: [PATCH] docbook2mdoc: Import as wip/docbook2mdoc. Update to 1.0.0 release. ChangeLog: $Id: ChangeLog,v 1.1 2019/04/17 18:50:38 schwarze Exp $ 2019-04-17 18:45 tag VERSION_1_0_0 2019-04-17 18:45 schwarze Deleted: index.xml (1.14) Added: NEWS (1.1) Changed: Makefile (1.25), "Exp", lines: +10 -11 release 1.0.0 2019-04-16 21:21 schwarze Changed: docbook2mdoc.c (1.131), "Exp", lines: +2 -1 node.c (1.22), "Exp", lines: +2 -1 node.h (1.31), "Exp", lines: +2 -1 statistics.c (1.35), "Exp", lines: +3 -1 translate to .Sy 2019-04-16 21:19 schwarze Changed: parse.c (1.46), "Exp", lines: +3 -1 treat and like
2019-04-16 14:58 schwarze Changed: node.c (1.21), "Exp", lines: +5 -5 node.h (1.30), "Exp", lines: +3 -2 parse.c (1.45), "Exp", lines: +15 -2 preserve leading whitespace in no-fill mode 2019-04-16 14:26 schwarze Changed: docbook2mdoc.c (1.130), "Exp", lines: +63 -42 macro.c (1.14), "Exp", lines: +20 -1 macro.h (1.5), "Exp", lines: +8 -1 Reorganize printing of .Pp macro lines, much improved formatting: Refrain from manual tree inspection. Instead, let and other nodes keep paragraph state and automatically emit .Pp when needed before printing text or macros. 2019-04-15 19:15 schwarze Changed: docbook2mdoc.c (1.129), "Exp", lines: +16 -1 node.c (1.20), "Exp", lines: +2 -1 node.h (1.29), "Exp", lines: +2 -1 Minimal translation of to .Sx. This might need refinement in the future, but that won't be easy because the element is horribly underspecified and the usage is practice is very inconsistent. 2019-04-15 00:34 schwarze Changed: docbook2mdoc.c (1.128), "Exp", lines: +36 -1 node.c (1.19), "Exp", lines: +5 -1 node.h (1.28), "Exp", lines: +5 -1 statistics.c (1.34), "Exp", lines: +4 -1 The element is woefully underspecified, so the various attributes may be used quite differently in different documents, but let's try a basic translation anyway. 2019-04-14 23:59 schwarze Changed: macro.c (1.13), "Exp", lines: +6 -1 bugfix: closing quote was missing in macro_addarg() 2019-04-14 23:07 schwarze Changed: docbook2mdoc.c (1.127), "Exp", lines: +12 -3 statistics.c (1.33), "Exp", lines: +15 -1 ignore around 2019-04-14 22:37 schwarze Changed: docbook2mdoc.c (1.126), "Exp", lines: +19 -1 node.c (1.18), "Exp", lines: +4 -1 node.h (1.27), "Exp", lines: +4 -1 parse.c (1.44), "Exp", lines: +5 -1 statistics.c (1.32), "Exp", lines: +6 -1 Rudimentary implementation of by printing the filename. Ignore the wrappers ,
, , . 2019-04-14 21:11 schwarze Changed: docbook2mdoc.c (1.125), "Exp", lines: +8 -1 node.c (1.17), "Exp", lines: +2 -2 statistics.c (1.31), "Exp", lines: +2 -1 The is no perfect way to render in mdoc(7). For now, use .Bo/.Bc as a full block. 2019-04-14 20:13 schwarze Changed: docbook2mdoc.c (1.124), "Exp", lines: +14 -1 node.c (1.16), "Exp", lines: +3 -1 node.h (1.26), "Exp", lines: +3 -1 statistics.c (1.30), "Exp", lines: +9 -1 render and with \(ha and _ 2019-04-14 19:29 schwarze Changed: docbook2mdoc.c (1.123), "Exp", lines: +7 -3 statistics.c (1.29), "Exp", lines: +15 -1 do not emit .Em or .Fl right before another macro 2019-04-14 18:28 schwarze Changed: docbook2mdoc.c (1.122), "Exp", lines: +8 -4 statistics.c (1.28), "Exp", lines: +2 -1 avoid overquoting when is nested inside 2019-04-14 18:07 schwarze Changed: docbook2mdoc.c (1.121), "Exp", lines: +23 -14 node.c (1.15), "Exp", lines: +4 -8 node.h (1.25), "Exp", lines: +2 -6 parse.c (1.43), "Exp", lines: +6 -1 statistics.c (1.27), "Exp", lines: +39 -1 Minor improvements to the handling of some meta-information: * Translate and to .Ss or lower. * Do not uppercase high-level and similar elements. * Handle like stand-alone . * Handle <editor> by the <author> handler function. * Make <copyright> print "Copyright (C)". * Ignore some transparent nodes. 2019-04-14 16:26 schwarze Changed: statistics.c (1.26), "Exp", lines: +11 -3 Parse internal subset declarations in <!DOCTYPE> tags as XML; in particular, they can contain XML comments. Similar to parts of parse.c rev. 1.23, but simpler. 2019-04-14 14:59 schwarze Changed: statistics.c (1.25), "Exp", lines: +6 -2 Make <sbr> self-closing even without a trailing slash. This logically merges parse.c rev. 1.23, even though the physical code differs. 2019-04-14 14:00 schwarze Changed: docbook2mdoc.c (1.120), "Exp", lines: +1 -4 node.c (1.14), "Exp", lines: +1 -2 node.h (1.24), "Exp", lines: +1 -2 parse.c (1.42), "Exp", lines: +6 -1 statistics.c (1.24), "Exp", lines: +29 -1 Minor improvements for some inline elements: * New aliases <keycap> and <property>. * Make <application> an alias for <command>. * Ignore <keycode> and <returnvalue>. 2019-04-14 12:59 schwarze Changed: macro.c (1.12), "Exp", lines: +7 -4 Relax child macro escaping: * No escaping needed in ARG_UPPER mode. * There are only four callable three-letter macros. 2019-04-14 12:38 schwarze Changed: README (1.7), "Exp", lines: +4 -3 docbook2mdoc.c (1.119), "Exp", lines: +146 -12 statistics.c (1.23), "Exp", lines: +12 -1 Move content from <bookinfo>, <articleinfo>, <refentryinfo>, and <refmeta> that is not used in the prologue to the AUTHORS section. 2019-04-13 15:54 schwarze Changed: docbook2mdoc.c (1.118), "Exp", lines: +20 -1 node.c (1.13), "Exp", lines: +6 -2 node.h (1.23), "Exp", lines: +5 -1 statistics.c (1.22), "Exp", lines: +2 -1 rudimentary implementation of <systemitem> 2019-04-13 15:13 schwarze Changed: docbook2mdoc.c (1.117), "Exp", lines: +44 -42 Improve formatting of <arg> and <group>: * Respect the repeat attribute even if there is a child macro. * Mark up all children of <group>, not just the first. * Implement the repeat attribute for <group>. * Do the proper was_impl dance for <group>. 2019-04-13 13:06 schwarze Changed: docbook2mdoc.c (1.116), "Exp", lines: +64 -54 node.c (1.12), "Exp", lines: +17 -1 node.h (1.22), "Exp", lines: +3 -1 parse.c (1.41), "Exp", lines: +2 -1 statistics.c (1.21), "Exp", lines: +7 -1 Improve the proplogue: * Use <pubdate> or <date> for .Dd. * Clean up the way how <title> from <bookinfo> is used for .Nd. * Treat <articleinfo> just like <bookinfo>. 2019-04-12 21:37 schwarze Changed: docbook2mdoc.c (1.115), "Exp", lines: +38 -11 parse.c (1.40), "Exp", lines: +2 -1 statistics.c (1.20), "Exp", lines: +11 -1 Author node polishing: * In the AUTHORS section, set -nosplit mode. * In <author>, do not recurse for <email>: it is pointless because it cannot reasonably contain child elements, but it can trigger assertions. * For standalone <email>, do the standard was_impl dance. * Treat <othercredit> just like <author>. 2019-04-12 19:14 schwarze Added: tree.c (1.1) Changed: Makefile (1.24), "Exp", lines: +3 -2 docbook2mdoc.1 (1.12), "Exp", lines: +32 -3 docbook2mdoc.c (1.114), "Exp", lines: +2 -2 format.h (1.2), "Exp", lines: +3 -2 main.c (1.6), "Exp", lines: +30 -5 node.c (1.11), "Exp", lines: +15 -3 node.h (1.21), "Exp", lines: +3 -1 Implement lint and tree dump output modes. Thanks to the previously committed node property infrastructure in node.c, this needs only 110 lines of code (including the license and the documentation). 2019-04-12 16:40 schwarze Changed: README (1.6), "Exp", lines: +7 -6 docbook2mdoc.c (1.113), "Exp", lines: +13 -7 node.c (1.10), "Exp", lines: +150 -1 node.h (1.20), "Exp", lines: +24 -9 parse.c (1.39), "Exp", lines: +68 -178 Infrastructure to access node properties that can be used by both the parser and the formatter. Use it to decide whether a text node needs .Pf before a macro, whether the first word of a text node needs to be split off after a macro, and whether a macro node can suppress the SPACE flag. 2019-04-12 12:07 schwarze Changed: docbook2mdoc.c (1.112), "Exp", lines: +25 -12 Finally get rid of the "sv" variable in pnode_print(). Switch <literal> and <quote> between explicit and implicit enclosures depending on whether we are already inside an implicit context. 2019-04-12 11:37 schwarze Changed: docbook2mdoc.c (1.111), "Exp", lines: +6 -14 node.h (1.19), "Exp", lines: +1 -2 parse.c (1.38), "Exp", lines: +1 -4 There is no need to ever use the eqn(7) inline syntax ($$): Its purpose it to inline eqn(7) source code in the *input* file. On the *output* side, equations are inlined by default. To display them, the .EQ block needs to be wrapped in .Bd. This patch gets rid of another user of "sv". 2019-04-12 11:19 schwarze Changed: docbook2mdoc.c (1.110), "Exp", lines: +24 -19 Clean up the <refnamediv> mess to get rid of the worst "sv" user: Explicit loop over <refname> elements in <refnamediv>. Treat stray <refname> elements just like <command>. 2019-04-12 10:34 schwarze Changed: docbook2mdoc.c (1.109), "Exp", lines: +17 -7 Improve <link linkend="..."> formatting. Take markup of the content into account. Do not break a partial implicit macro line, if one is open. Do not let the parentheses extend too far. 2019-04-12 09:39 schwarze Changed: docbook2mdoc.c (1.108), "Exp", lines: +21 -10 Fix an assertion failure when content inside a term causes an output line break. The solution isn't perfect: content from the <term> still leaks into the .It body, but fixing *that* is a much more complex task than merely fixing the assertion. 2019-04-12 09:01 schwarze Changed: macro.c (1.11), "Exp", lines: +3 -3 another case of incomplete escaping: element space dot 2019-04-12 08:48 schwarze Changed: docbook2mdoc.c (1.107), "Exp", lines: +17 -36 macro.c (1.10), "Exp", lines: +10 -3 Move escaping of control characters and backslashes on text lines to print_text() such that it works for all text lines. In pnode_printtext(), use macro_addarg() or print_text() to get the required escaping. On the other hand, there is no need to handle linefeed characters because these can no longer occur in text nodes. Stephen Gregoratto <dev at sgregoratto dot me> reported that escaping was incomplete in some cases. 2019-04-12 07:53 schwarze Changed: parse.c (1.37), "Exp", lines: +34 -8 If a text node precedes a non-text node without intervening whitespace, split out the last word for use with .Pf. 2019-04-12 07:05 schwarze Changed: docbook2mdoc.c (1.106), "Exp", lines: +4 -4 node.h (1.18), "Exp", lines: +2 -2 parse.c (1.36), "Exp", lines: +4 -2 statistics.c (1.19), "Exp", lines: +3 -1 handle <computeroutput> and <markup>; patch from Stephen Gregoratto <dev at sgregoratto dot me> who found that both are frequently used in the doclifter manpage 2019-04-12 06:46 schwarze Changed: parse.c (1.35), "Exp", lines: +65 -21 If a text node follows a non-text node without intervening whitespace, keep the text in it as short as possible. 2019-04-12 04:39 schwarze Changed: node.c (1.9), "Exp", lines: +15 -1 node.h (1.17), "Exp", lines: +2 -1 parse.c (1.34), "Exp", lines: +4 -19 New function pnode_alloc() to reduce code duplication. No functional change. 2019-04-12 04:17 schwarze Changed: docbook2mdoc.c (1.105), "Exp", lines: +8 -2 parse.c (1.33), "Exp", lines: +4 -2 Do not include literal linefeed characters in text nodes; instead, let the parser split them into two text nodes. For now, let the formatter start text nodes preceded by whitespace on new output lines, which is a crude way of preserving input line breaks and making sure output text lines are limited to reasonable length. 2019-04-12 03:38 schwarze Changed: docbook2mdoc.c (1.104), "Exp", lines: +4 -2 Outside <funcprototype>, format <paramdef> and <parameter> in-line rather than stand-alone. While many potential assertion failures remain, this patch fixes the last remaining assertion that actually occurs in Xenocara. 2019-04-11 04:23 schwarze Changed: README (1.5), "Exp", lines: +2 -4 docbook2mdoc.c (1.103), "Exp", lines: +80 -47 macro.c (1.9), "Exp", lines: +18 -76 macro.h (1.4), "Exp", lines: +6 -3 node.c (1.8), "Exp", lines: +2 -2 node.h (1.16), "Exp", lines: +1 -3 parse.c (1.32), "Exp", lines: +21 -19 Introduce FMT_* formatter flags to control what can be added to the current macro line. Move trailing punctuation handling to the text formatter, allowing elimination of the function macro_closepunct() and of the "real" and "bsz" members from struct node. Substantial functional improvements, yet minus 25 lines of code. 2019-04-10 14:37 schwarze Changed: docbook2mdoc.c (1.102), "Exp", lines: +9 -9 Last instance of conistent "struct pnode *nc, *nn" variable naming. While the previous commit caused no binary change, this one does, but only because one variable serving two different purposes is split into two. Still no functional change. 2019-04-10 14:34 schwarze Changed: parse.c (1.31), "Exp", lines: +24 -24 Last instance of consistent "struct parse *p" function argument naming. While the previous commit caused no binary change, this one does, but only because the argument is used in an assert(3). Still no functional change. 2019-04-10 14:22 schwarze Changed: docbook2mdoc.c (1.101), "Exp", lines: +282 -282 macro.c (1.8), "Exp", lines: +8 -8 node.c (1.7), "Exp", lines: +41 -41 parse.c (1.30), "Exp", lines: +103 -103 Consitently use for function arguments: struct parse *p, struct format *f, struct pnode *n, struct pattr *a Consistently use struct pnode *nc, *nn, *np for child, next, and previous nodes, respectively. I admit this makes commit history a bit harder to inspect, but i think seeing at once what variables mean is worth it. 2019-04-09 16:57 schwarze Changed: docbook2mdoc.1 (1.11), "Exp", lines: +48 -21 update content in many respects 2019-04-09 15:23 schwarze Changed: docbook2mdoc.1 (1.10), "Exp", lines: +55 -4 main.c (1.5), "Exp", lines: +6 -6 node.h (1.15), "Exp", lines: +5 -4 parse.c (1.29), "Exp", lines: +30 -37 switch to mandoc(1)-style EXIT STATUS and DIAGNOSTICS 2019-04-09 13:35 schwarze Changed: parse.c (1.28), "Exp", lines: +4 -2 Fix a logic bug causing tree corruption: When parsing an internal subset declaration, text does not extend beyond closing square brackets. 2019-04-09 12:23 schwarze Changed: parse.c (1.27), "Exp", lines: +2 -1 Fix a logic bug and a memory leak: After parsing an attribute value, clear the attribute flag, such that, if another attribute value follows, it gets ignored rather than clobbering the first value. 2019-04-09 01:39 schwarze Changed: node.c (1.6), "Exp", lines: +2 -1 node.h (1.14), "Exp", lines: +3 -1 parse.c (1.26), "Exp", lines: +16 -2 implement file inclusion via <xi:include> 2019-04-08 23:40 schwarze Changed: parse.c (1.25), "Exp", lines: +10 -3 implement file inclusion via the ENTITY SYSTEM mechanism 2019-04-08 22:47 schwarze Changed: main.c (1.4), "Exp", lines: +23 -30 parse.c (1.24), "Exp", lines: +82 -27 Make the function parse_file() fit for recursion: * Save and restore reporting data around the read loop. * Open the file inside the function, not before calling it. * On the top level, change directory on a best-effort basis. * Finalize the parse tree only on the top level. No new functionality yet. 2019-04-08 14:37 schwarze Changed: node.c (1.5), "Exp", lines: +5 -1 node.h (1.13), "Exp", lines: +7 -1 parse.c (1.23), "Exp", lines: +133 -32 Handle DOCTYPE declarations containing ENTITY definitions. Also make <sbr> self-closing even without a trailing slash. 2019-04-07 19:33 schwarze Changed: docbook2mdoc.c (1.100), "Exp", lines: +14 -5 node.h (1.12), "Exp", lines: +2 -2 parse.c (1.22), "Exp", lines: +5 -2 statistics.c (1.18), "Exp", lines: +6 -1 handle <appendix>, <article>, <book>, and <legalnotice> similar to <section> 2019-04-07 18:51 schwarze Changed: docbook2mdoc.c (1.99), "Exp", lines: +6 -3 parse.c (1.21), "Exp", lines: +6 -1 statistics.c (1.17), "Exp", lines: +10 -1 handle glossaries just like variablelists 2019-04-07 17:55 schwarze Changed: docbook2mdoc.c (1.98), "Exp", lines: +5 -1 parse.c (1.20), "Exp", lines: +2 -1 statistics.c (1.16), "Exp", lines: +2 -1 render <blockquote> as .Bd -ragged -offset indent 2019-04-07 17:42 schwarze Changed: docbook2mdoc.c (1.97), "Exp", lines: +9 -5 do not access null pointers when the document element is <title> 2019-04-07 17:39 schwarze Changed: parse.c (1.19), "Exp", lines: +3 -3 Discard attributes of ignored elements. As a side benefit, this avoids a null pointer access if the document element is ignored and has attributes. 2019-04-07 17:00 schwarze Changed: docbook2mdoc.c (1.96), "Exp", lines: +39 -7 node.c (1.4), "Exp", lines: +5 -2 node.h (1.11), "Exp", lines: +4 -1 parse.c (1.18), "Exp", lines: +2 -2 statistics.c (1.15), "Exp", lines: +3 -1 better handling of <link> and <ulink> elements including endterm=, linkend=, url=, and xlink:href= attributes 2019-04-07 15:06 schwarze Changed: docbook2mdoc.c (1.95), "Exp", lines: +7 -1 macro.c (1.7), "Exp", lines: +2 -1 some nodes never continue an existing macro line 2019-04-07 14:49 schwarze Changed: docbook2mdoc.c (1.94), "Exp", lines: +15 -1 parse.c (1.17), "Exp", lines: +45 -3 handle preceding a macro without intervening whitespace 2019-04-07 13:16 schwarze Changed: docbook2mdoc.c (1.93), "Exp", lines: +56 -51 Move printing of text nodes out of pnode_print() into a dedicated function, like for all other node types that require a substantial amount of code. No functional change. 2019-04-06 22:37 schwarze Changed: docbook2mdoc.c (1.92), "Exp", lines: +5 -3 macro.c (1.6), "Exp", lines: +62 -11 macro.h (1.3), "Exp", lines: +2 -1 node.h (1.10), "Exp", lines: +2 -1 parse.c (1.16), "Exp", lines: +34 -28 Store the information whether a node is preceded by whitespace into the node tree. Use that information in the formatter to suppress the insertion of whitespace in text-text, macro-text, and macro-macro node sequences. Text-macro sequences are not yet handled. They are more complicated because they require emitting a .Pf macro as part of a text node depending on the spacing properties of the *following* macro node. 2019-04-06 13:45 schwarze Changed: parse.c (1.15), "Exp", lines: +2 -1 statistics.c (1.14), "Exp", lines: +2 -1 treat <simpara> just like <para>; simplified version of a patch from Stephen Gregoratto <dev at sgregoratto dot me> 2019-04-06 13:30 schwarze Changed: README (1.4), "Exp", lines: +78 -8 update the instructions for adding elements; triggered by a smaller patch from Stephen Gregoratto <dev at sgregoratto dot me> 2019-04-05 14:37 schwarze Changed: parse.c (1.14), "Exp", lines: +193 -184 Split parse_file() into parse_file() to fill the parse buffer and parse_string() to handle it, to allow parsing from alternative sources in a subsequent step. Only advance line and column number when parsing from the main input file. Represent parsing state as an enum rather than with multiple flags. 2019-04-03 18:52 schwarze Changed: docbook2mdoc.c (1.91), "Exp", lines: +21 -2 statistics.c (1.13), "Exp", lines: +3 -1 rudimentary implementation of <simplelist> 2019-04-03 17:53 schwarze Changed: docbook2mdoc.c (1.90), "Exp", lines: +7 -15 node.h (1.9), "Exp", lines: +2 -4 parse.c (1.13), "Exp", lines: +6 -4 statistics.c (1.12), "Exp", lines: +14 -1 Various in-line elements: Translate <errorname> to .Er. Translate <sgmltag> to .Ic. Translate <literal> to .Ql, avoiding .Li. Map <code> and <userinput> to <literal>. Map <structname> to <type>. Map <structfield> to <parameter>. 2019-04-03 16:52 schwarze Changed: docbook2mdoc.c (1.89), "Exp", lines: +1 -4 statistics.c (1.11), "Exp", lines: +13 -1 do not abort(3) when there is more than one <refmeta> 2019-04-03 16:08 schwarze Changed: parse.c (1.12), "Exp", lines: +2 -1 statistics.c (1.10), "Exp", lines: +6 -1 introduce <symbol> as an alias for <constant> 2019-04-03 15:59 schwarze Changed: docbook2mdoc.c (1.88), "Exp", lines: +3 -1 treat <synopsis> as a literal display 2019-04-03 15:27 schwarze Changed: statistics.c (1.9), "Exp", lines: +16 -9 mark more relations involving parameters, indexterms, and sections as handled 2019-04-03 15:24 schwarze Changed: docbook2mdoc.c (1.87), "Exp", lines: +2 -1 translate <paramdef> to .Fa even outside <funcprototype> 2019-04-03 15:05 schwarze Changed: docbook2mdoc.c (1.86), "Exp", lines: +13 -21 statistics.c (1.8), "Exp", lines: +7 -1 Make <funcdef> more robust: If the first child is text, use it for .Ft, then use all remaining children for .Fo. Make <funcprototype> more robust: Use all children but the first <funcdef> for .Fa. 2019-04-03 15:04 schwarze Changed: macro.c (1.5), "Exp", lines: +10 -8 Make macro_addnode() more flexible: Iteratively descend singleton children to find a singleton text node. 2019-04-03 14:02 schwarze Changed: docbook2mdoc.c (1.85), "Exp", lines: +2 -5 statistics.c (1.7), "Exp", lines: +8 -1 Do not handle <varlistentry> in pnode_print() because it generates .It which must not occur outside .Bl. 2019-04-03 13:42 schwarze Changed: docbook2mdoc.c (1.84), "Exp", lines: +2 -3 macro.c (1.4), "Exp", lines: +3 -2 Improve robustness by allowing macro_close() in any state. This is relevant because pnode_print() may change state. 2019-04-03 12:29 schwarze Changed: docbook2mdoc.c (1.83), "Exp", lines: +36 -12 statistics.c (1.6), "Exp", lines: +20 -1 print tables containing two columns as .Bl -tag 2019-04-03 11:46 schwarze Changed: docbook2mdoc.c (1.82), "Exp", lines: +38 -12 node.c (1.3), "Exp", lines: +2 -1 node.h (1.8), "Exp", lines: +2 -2 parse.c (1.11), "Exp", lines: +2 -2 Prints tables containing only one column as .Bl -bullet -compact. The number of columns is taken from the "cols" attribute. No neat to treat <informaltable> separately from <table>; the only difference is whether or not it has a title. Treat <table> as transparent and handle <tgroup> instead. The advantages are that <title> gets a generic handler which also works in other contexts and that other children of <table> are now covered as well. 2019-04-03 11:23 schwarze Changed: parse.c (1.10), "Exp", lines: +6 -4 statistics.c (1.5), "Exp", lines: +6 -4 handle attributes in single quotes 2019-04-03 09:49 schwarze Changed: statistics.c (1.4), "Exp", lines: +55 -2 optional parent-child histogram for one relation 2019-04-03 08:39 schwarze Changed: statistics.c (1.3), "Exp", lines: +14 -1 merge parse.c rev. 1.8: skip XML comments containing greater-than characters 2019-04-03 08:36 schwarze Changed: Makefile (1.23), "Exp", lines: +3 -3 link with -g for easier debugging and clean statistics.core 2019-04-02 17:06 schwarze Changed: docbook2mdoc.c (1.81), "Exp", lines: +1 -2 handle trailing delimiters after <citerefentry>/.Xr; bug reported by Stephen Gregoratto <dev at sgregoratto dot me> 2019-04-02 16:24 schwarze Changed: docbook2mdoc.c (1.80), "Exp", lines: +11 -1 use the idiom ".An Name Aq Mt email" for author email addresses; issue reported by Stephen Gregoratto <dev at sgregoratto dot me> 2019-04-02 15:53 schwarze Changed: docbook2mdoc.c (1.79), "Exp", lines: +8 -1 macro.c (1.3), "Exp", lines: +5 -4 node.h (1.7), "Exp", lines: +2 -1 parse.c (1.9), "Exp", lines: +120 -7 Translate XML character entity references to roff character escape sequences. Missing feature reported by Stephen Gregoratto <dev at sgregoratto dot me>. Remaining known issues: * Whitespace handling isn't perfect yet. * Numeric character references aren't handled yet. * The list of entities is still very incomplete. * When it grows longer, we may have to switch to binary search. * Local entities declared in the DTD are not yet handled. 2019-04-02 13:11 schwarze Changed: parse.c (1.8), "Exp", lines: +25 -1 skip XML comments even if they contain greater-than characters; issue reported by Stephen Gregoratto <dev at sgregoratto dot me> 2019-03-29 18:09 schwarze Changed: statistics.c (1.2), "Exp", lines: +44 -12 allow excluding relations that are already fully implemented 2019-03-29 15:55 schwarze Added: statistics.c (1.1) Changed: Makefile (1.22), "Exp", lines: +4 -0 Add a utility for docbook2mdoc developers to collect element usage and parenting statistics, to help decide which nodes should be most urgently worked on. 2019-03-28 20:41 schwarze Changed: docbook2mdoc.c (1.78), "Exp", lines: +64 -21 macro.c (1.2), "Exp", lines: +44 -10 macro.h (1.2), "Exp", lines: +4 -1 node.h (1.6), "Exp", lines: +2 -1 parse.c (1.7), "Exp", lines: +5 -4 Implement a formatter for <author> elements, handling <contrib>, <personname>, <firstname>, <othername>, <surname>, as well as arbitrary children properly. This required minor work on the formatting infrastructure: Improve macro_addnode() such that it also handles text nodes. Add a companion function print_textnode(). Let print_text() optionally work without ARG_SPACE. Triggered by a report from Stephen Gregoratto <dev at sgregoratto dot me> that and how GTK documentation uses <contrib>. 2019-03-28 15:05 schwarze Changed: parse.c (1.6), "Exp", lines: +42 -33 Simple warn_msg() and error_msg() functions to avoid repetitive code. While here, drop the warning about unknown attributes. Those are just too abundant and hardly matter. 2019-03-28 12:21 schwarze Changed: Makefile (1.21), "Exp", lines: +1 -1 index.xml (1.13), "Exp", lines: +4 -6 main.c (1.3), "Exp", lines: +3 -3 node.c (1.2), "Exp", lines: +3 -3 node.h (1.5), "Exp", lines: +2 -1 parse.c (1.5), "Exp", lines: +322 -100 The expat library aborts parsing as soon as it encounters invalid input, and the basic design of the library practically precludes fixing it. However, whether the input is well-formed XML or not is totally irrelevant, and in fact, i have seen real-world documents from X.org that expat rejects as not well-formed. Kristaps reports the same from OpenGL. We really want to parse *ANYTHING* whatsoever without ever throwing a fatal error - after all, the point is to convert legacy documents to a better format, and nitpicking about the syntax merely alienates users (including myself). Consequently, ditch expat and write a parser from scratch, optimized for robustness on invalid input. Oh, and by the way, it only requires 200 lines of code, compared to 15,000 lines in expat - an economy of 98.5% at the sime time as being much more useful in practice. 2019-03-26 22:39 schwarze Changed: docbook2mdoc.c (1.77), "Exp", lines: +1 -3 node.h (1.4), "Exp", lines: +4 -6 parse.c (1.4), "Exp", lines: +40 -13 Provide a way to exclude elements including their children from the tree and use that for <anchor>, <indexterm>, <primary>, and <secondary>. 2019-03-26 21:52 schwarze Changed: docbook2mdoc.c (1.76), "Exp", lines: +1 -4 node.h (1.3), "Exp", lines: +1 -8 parse.c (1.3), "Exp", lines: +8 -8 mark the first seven elements as ignored, shortening enum nodeid, and in one case even pnode_print() 2019-03-26 21:47 schwarze Changed: Makefile (1.20), "Exp", lines: +2 -1 add forgotten macro.{c,h} dependency rules 2019-03-26 20:54 schwarze Changed: node.h (1.2), "Exp", lines: +3 -2 parse.c (1.2), "Exp", lines: +31 -11 Provide an easy way to parse an XML element without generating a node, either ignoring it outright or emitting a warning if -W was specified. Use this to handle <xi:include> more cleanly, fixing two FIXMEs. 2019-03-26 20:06 schwarze Changed: main.c (1.2), "Exp", lines: +8 -2 Parsing errors are too easy to miss because they typically emit a one-line error message followed by lengthy formatted output of what was parsed before the error occurred. Make parsing errors more conspicious by taking two steps: 1. If there was a parsing error, print a blank line to standard output before starting formatted output, for better separation. 2. After the formatted output, if there was a parsing error, print the following to standard error: a blank line, a message that output is incomplete, and another blank line. 2019-03-26 19:17 schwarze Added: macro.c (1.1) macro.h (1.1) Changed: Makefile (1.19), "Exp", lines: +3 -3 docbook2mdoc.c (1.75), "Exp", lines: +2 -202 The file docbook2mdoc.c is still large, so split out the macro line formatter, which is quite self-contained. 2019-03-26 18:32 schwarze Deleted: extern.h (1.34) Added: format.h (1.1) main.c (1.1) node.c (1.1) node.h (1.1) parse.c (1.1) parse.h (1.1) Changed: Makefile (1.18), "Exp", lines: +15 -6 docbook2mdoc.c (1.74), "Exp", lines: +56 -645 The program docbook2mdoc(1) has become large enough that splitting it into a number of logical components makes sense: node tree, parser, formatter, each with interface and implementation, and the main program. That way, it becomes easier to see what interacts with what, and what is independent of what. 2019-03-25 23:14 schwarze Changed: docbook2mdoc.c (1.73), "Exp", lines: +17 -33 extern.h (1.33), "Exp", lines: +2 -2 Various parser simplifications and improvements. Delete the redundant member "node" of struct parse. The same is already available from cur->node. No need to check in xml_char() whether an element is open. Text outside the document element results in expat errors "not well-formed (invalid token)" or "junk after document element" and the function xml_char() is not called. No need to check in xml_elem_end() whether an element is open. Bogus closing tags result in expat errors "not well-formed (invalid token)" or "mismatched tag" and the function xml_elem_end() is not called. In xml_elem_start(): no point in skipping the element name check for the document element; and the error error "multiple refentries" can no longer happen due to earlier cleanups. 2019-03-25 17:28 schwarze Changed: docbook2mdoc.c (1.72), "Exp", lines: +128 -139 For macro_addarg(), macro_addnode(), and macro_nodeline(), provide a flag ARG_SINGLE to request quoting of strings containing whitespace. Use it for .Dt, .Fa, .Fo, .Nm, and .Xr. Do not \&-escape macros in quoted strings. Escape quote characters in macro arguments. NUL-terminate the content of text nodes. Eliminate the awkward "bufappend()" global output buffer. Simplify and improve handling of <paramdef>. Substantial functional improvements, easier to read, yet minus 20 LOC. 2019-03-24 23:48 schwarze Changed: docbook2mdoc.c (1.71), "Exp", lines: +37 -44 To avoid use after free, use TAILQ_FOREACH_SAFE(3) rather than TAILQ_FOREACH(3) when deleting list elements during the iteration. Factor out some repeated code into a new function pnode_printtitle(). Where pnode_print() calls per-element pnode_print*() functions, call exactly one function per element and do everything that is required inside, making the huge function pnode_print() slightly smaller and the various pnode_print*() more self-contained. In particular, call pnode_unlinksub() as close as possible to the place where the processing justifying the deletion was done. 2019-03-24 21:00 schwarze Changed: docbook2mdoc.c (1.70), "Exp", lines: +24 -9 Avoid reckless use of low-level stdio output functions like putchar(3), puts(3), and fputs(3) in high-level formatting code. For clarity and robustness, be explicit whether we are printing to a text line with print_text() or to a macro line with macro_addarg(). While here, fix NODE_REFNAME formatting which i broke previously. For now, leave MathML to eqn(7) translation alone. Usually, that happens in .EQ blocks, i.e. writing text lines. But it can also happen in inline ($$) context on macro lines. That is certainly very fragile and will often fail especially for non-trivial formulae, but switching to print_text() would break it even more. So postpone repairs until i come round to work on equation formatting for real. 2019-03-24 16:45 schwarze Changed: docbook2mdoc.c (1.69), "Exp", lines: +260 -348 As usual, whitespace handling is the heart and soul of roff(7) processing, so overhaul it. Keep output line state and provide a set of output functions to open and close macro lines and to add arguments to them. Mostly avoid asserting output line state because elements can occur in any order and we should just deal with whatever comes in. This diff shortens the code by 60 lines, improves robustness and readability, and fixes some bugs. 2019-03-23 11:13 schwarze Changed: docbook2mdoc.c (1.68), "Exp", lines: +6 -1 translate <citetitle> to .%T 2019-03-23 10:53 schwarze Changed: docbook2mdoc.c (1.67), "Exp", lines: +6 -1 translate <keysym> to .Sy 2019-03-23 10:22 schwarze Changed: docbook2mdoc.c (1.66), "Exp", lines: +4 -4 the handlers for NODE_LITERALLAYOUT and NODE_PROGRAMLISTING were exchanged 2019-03-22 19:44 schwarze Changed: docbook2mdoc.c (1.65), "Exp", lines: +8 -1 extern.h (1.32), "Exp", lines: +3 -1 support <personname> and <email>; based on a patch from Stephen Gregoratto <dev at sgregoratto dot me> 2019-03-22 19:07 schwarze Changed: docbook2mdoc.c (1.64), "Exp", lines: +124 -138 KNF: eliminate Yoda notation, and also drop a few redundant assertions 2019-03-22 18:02 schwarze Changed: docbook2mdoc.c (1.63), "Exp", lines: +15 -15 * Fix the return value from main(). * Do not use the pointless constants EXIT_SUCCESS and EXIT_FAILURE. * KNF: remove parentheses from return statements. 2019-03-22 17:42 schwarze Changed: docbook2mdoc.c (1.62), "Exp", lines: +126 -130 KNF: remove parentheses from switch cases 2019-03-22 17:28 schwarze Changed: docbook2mdoc.c (1.61), "Exp", lines: +16 -8 no output for PARA right inside ENTRY, and fix the same in LISTITEM 2019-03-22 17:01 schwarze Changed: docbook2mdoc.c (1.60), "Exp", lines: +25 -5 extern.h (1.31), "Exp", lines: +3 -1 handle class="monospaced" in NODE_LITERALLAYOUT 2019-03-22 16:55 schwarze Changed: docbook2mdoc.c (1.59), "Exp", lines: +26 -34 factor out new function pnode_getattr_raw() 2019-03-22 16:50 schwarze Changed: docbook2mdoc.c (1.58), "Exp", lines: +13 -1 extern.h (1.30), "Exp", lines: +2 -1 translate NODE_LINK to .Sx 2019-03-22 16:47 schwarze Changed: docbook2mdoc.c (1.57), "Exp", lines: +3 -1 translate NODE_FIRSTTERM to .Em 2019-03-22 16:42 schwarze Changed: docbook2mdoc.c (1.56), "Exp", lines: +146 -181 extern.h (1.29), "Exp", lines: +1 -9 Work towards reducing the number of node IDs. Allow mapping several node names to the same node ID and use that for chapter, part, refsect*, sect* -> NODE_SECTION. Do not require the root to be of a specific type. Delete the useless NODE_IGNTEXT. 2019-03-22 16:35 schwarze Changed: docbook2mdoc.c (1.55), "Exp", lines: +3 -1 ignore NODE_INDEXTERM for now 2019-03-22 16:32 schwarze Changed: docbook2mdoc.c (1.54), "Exp", lines: +37 -10 new function pnode_printpara() to avoid printing redundant .Pp, for example after section headers 2019-03-22 16:25 schwarze Changed: docbook2mdoc.c (1.53), "Exp", lines: +2 -2 NODE_ITEMIZEDLIST is .Bl -bullet, not .Bl -enum 2019-03-22 16:21 schwarze Changed: docbook2mdoc.c (1.52), "Exp", lines: +67 -47 automatic assignment of header levels 2019-03-22 16:14 schwarze Changed: docbook2mdoc.c (1.51), "Exp", lines: +13 -8 get the .Dt name from the id attribute of the root node 2019-03-22 16:10 schwarze Changed: docbook2mdoc.c (1.50), "Exp", lines: +93 -4 extern.h (1.28), "Exp", lines: +52 -0 many new nodes found below /usr/xenocara/proto/xorgproto/specs/ 2019-03-22 15:54 schwarze Deleted: rules.c (1.27) Changed: Makefile (1.17), "Exp", lines: +5 -5 docbook2mdoc.c (1.49), "Exp", lines: +1 -20 extern.h (1.27), "Exp", lines: +0 -12 Delete the rest of rules.c. Just like validation of element nesting is pointless, validating attributes makes no sense either. 2019-03-22 15:38 schwarze Changed: README (1.3), "Exp", lines: +1 -20 docbook2mdoc.c (1.48), "Exp", lines: +2 -14 extern.h (1.26), "Exp", lines: +0 -1 rules.c (1.26), "Exp", lines: +0 -1331 Delete the isparent() validation function. The DocBook language is totally ill-designed, a gigantic accretion of arbitrary elements without any kind of discernible design or cohesion, with an absurdly large number of arbitrary and pointless rules of what is allowed to nest inside which other elements. So attempting to validate DocBook input against the totally crazy specification makes no sense whatsoever, and even less so because we are certainly not encouraging anybody to write new or maintain existing DocBook documents. The whole point of having a DocBook parser is to be able to parse legacy documents and convert them to a sane language, so it is utterly irrelevant whether the input is considered valid or invalid by some idiotic standard. This deletion allows substantial simplification of the code and will massively speed up development in the future. Kristaps@ says that i can move forward with development without asking for individual OKs. 2019-03-17 13:53 schwarze Changed: docbook2mdoc.1 (1.9), "Exp", lines: +5 -5 minor improvements from Stephen Gregoratto <dev at sgregoratto dot me> 2019-03-08 15:18 schwarze Changed: docbook2mdoc.c (1.47), "Exp", lines: +3 -3 for the null character '\0', use the standard shorthand NUL, not "nil" 2019-03-08 15:09 schwarze Changed: docbook2mdoc.c (1.46), "Exp", lines: +13 -13 fix systematically wrong (int) casts in character classification functions 2019-03-08 10:13 schwarze Changed: README (1.2), "Exp", lines: +10 -4 update links to the DocBook website and fix a typo in a function name 2019-03-08 10:04 schwarze Changed: docbook2mdoc.c (1.45), "Exp", lines: +6 -5 improve error handling and usage in main() --- docbook2mdoc/DESCR | 3 +++ docbook2mdoc/Makefile | 16 ++++++++++++++ docbook2mdoc/PLIST | 3 +++ docbook2mdoc/distinfo | 7 ++++++ docbook2mdoc/patches/patch-Makefile | 34 +++++++++++++++++++++++++++++ 5 files changed, 63 insertions(+) create mode 100644 docbook2mdoc/DESCR create mode 100644 docbook2mdoc/Makefile create mode 100644 docbook2mdoc/PLIST create mode 100644 docbook2mdoc/distinfo create mode 100644 docbook2mdoc/patches/patch-Makefile diff --git a/docbook2mdoc/DESCR b/docbook2mdoc/DESCR new file mode 100644 index 0000000000..b0c760d8c0 --- /dev/null +++ b/docbook2mdoc/DESCR @@ -0,0 +1,3 @@ +The docbook2mdoc utility is a converter from DocBook into mdoc. +Unlike most DocBook utilities, it's a standalone ISC-licensed ISO +C utility that should compile on any modern UNIX system. diff --git a/docbook2mdoc/Makefile b/docbook2mdoc/Makefile new file mode 100644 index 0000000000..9af43d15d5 --- /dev/null +++ b/docbook2mdoc/Makefile @@ -0,0 +1,16 @@ +# $NetBSD: Makefile,v 1.4 2014/04/30 13:57:15 wiz Exp $ + +DISTNAME= docbook2mdoc-1.0.0 +CATEGORIES= textproc +MASTER_SITES= http://mdocml.bsd.lv/docbook2mdoc/snapshots/ +EXTRACT_SUFX= .tgz + +MAINTAINER= ng0@n0.is +HOMEPAGE= http://mdocml.bsd.lv/docbook2mdoc/ +COMMENT= Convert DocBook documentation into man pages (mdoc) +LICENSE= isc + +BUILD_TARGET= docbook2mdoc +MAKE_FLAGS+= PREFIX=${PREFIX} + +.include "../../mk/bsd.pkg.mk" diff --git a/docbook2mdoc/PLIST b/docbook2mdoc/PLIST new file mode 100644 index 0000000000..fe6d8b4c6c --- /dev/null +++ b/docbook2mdoc/PLIST @@ -0,0 +1,3 @@ +@comment $NetBSD: PLIST,v 1.1 2014/03/31 08:13:32 wiz Exp $ +bin/docbook2mdoc +man/man1/docbook2mdoc.1 diff --git a/docbook2mdoc/distinfo b/docbook2mdoc/distinfo new file mode 100644 index 0000000000..d185e462fb --- /dev/null +++ b/docbook2mdoc/distinfo @@ -0,0 +1,7 @@ +$NetBSD: distinfo,v 1.7 2017/07/12 12:55:51 wiz Exp $ + +SHA1 (docbook2mdoc-1.0.0.tgz) = 292406f9e21ee75bc7ea30c1fa9b2b26c2f3335b +RMD160 (docbook2mdoc-1.0.0.tgz) = 505c1fd963897c44e9eca4423981610012aa5336 +SHA512 (docbook2mdoc-1.0.0.tgz) = 9c6b7ad894d4a52f4dbd081abb4a1b25d645a7520d0e36a7b86c90fc88095b197d26b8ea55d882880aee32389ef90fa23294160962a59bf02c5e33049b2de90a +Size (docbook2mdoc-1.0.0.tgz) = 24393 bytes +SHA1 (patch-Makefile) = 14e744c2b377fdcb6d52c1135e344eb1af6f89a5 diff --git a/docbook2mdoc/patches/patch-Makefile b/docbook2mdoc/patches/patch-Makefile new file mode 100644 index 0000000000..b4aeff6cd0 --- /dev/null +++ b/docbook2mdoc/patches/patch-Makefile @@ -0,0 +1,34 @@ +$NetBSD$ +Honor LDFLAGS, Support PKGMANDIR + +--- + Makefile | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/Makefile b/Makefile +index 9b8dc50..66b7a6d 100644 +--- Makefile.orig ++++ Makefile +@@ -11,18 +11,18 @@ DISTFILES = Makefile NEWS docbook2mdoc.1 + all: docbook2mdoc + + docbook2mdoc: $(OBJS) +- $(CC) -g -o $@ $(OBJS) ++ $(CC) $(LDFLAGS) -g -o $@ $(OBJS) + + statistics: statistics.o +- $(CC) -g -o $@ statistics.c ++ $(CC) $(LDFLAGS) -g -o $@ statistics.c + + www: docbook2mdoc.1.html docbook2mdoc-$(VERSION).tgz README.txt + + install: all + mkdir -p $(DESTDIR)$(PREFIX)/bin +- mkdir -p $(DESTDIR)$(PREFIX)/man/man1 ++ mkdir -p $(DESTDIR)$(PREFIX)/${PKGMANDIR}/man1 + install -m 0755 docbook2mdoc $(DESTDIR)$(PREFIX)/bin +- install -m 0444 docbook2mdoc.1 $(DESTDIR)$(PREFIX)/man/man1 ++ install -m 0444 docbook2mdoc.1 $(DESTDIR)$(PREFIX)/${PKGMANDIR}/man1 + + installwww: www + mkdir -p $(WWWPREFIX)/snapshots