aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_html.c
Commit message (Collapse)AuthorAgeFilesLines
* Remove the ENDBODY_NOSPACE flag, simplifying the code.Ingo Schwarze2017-02-161-3/+1
| | | | | | | | Comparing to groff output, it appears that all cases where it was used and made a difference actually require the opposite, ENDBODY_SPACE. I have no idea why i added it back in 2010; maybe to compensate for some other bug that has long been fixed.
* The .Nm macro does not only use the default name when it has noIngo Schwarze2017-02-061-3/+1
| | | | | | | | | | argument, but also when the first argument is a child macro. Arcane issue found in the FreeBSD cxgbetool(8) manual that Baptiste Daroussin <bapt at FreeBSD> sent me long ago for a different reason. While solving this, switch to the new technique of doing text production in the validator, reducing code duplication in the formatters, which also makes -Ttree output clearer.
* Wrap .St content in a <span class="St">.Ingo Schwarze2017-02-051-3/+11
| | | | Also add forgotten <span class="Ux"> to .At rendering.
* fix font selection for .Bf without argumentIngo Schwarze2017-02-051-2/+2
|
* mark up .Ar, .Fa, .Va, .Ft, and .Vt with <var> rather than <i>;Ingo Schwarze2017-02-051-10/+10
| | | | suggested by bentley@ long ago, but needed lots of cleanup first
* for .Rs, use <cite>Ingo Schwarze2017-02-051-2/+2
|
* Improve <table> syntax:Ingo Schwarze2017-02-051-9/+13
| | | | | | | | The <col> element can only appear inside <colgroup>, so use <colgroup>. The <tbody> element is optional and useless, so don't use it. Even if we would ever need <thead> or <tfoot>, <tbody> would still be optional and useless; besides, we will likely never need <thead> or <tfoot>, simply because our languages don't support such functionality.
* eliminate one useless struct and one level of indirection;Ingo Schwarze2017-01-291-3/+3
| | | | no functional change
* Simplify usage of print_otag() even more:Ingo Schwarze2017-01-281-48/+21
| | | | accept NULL to skip the attribute or format.
* .Bl -column with zero columns is legal, so don't segfalt on it.Ingo Schwarze2017-01-281-17/+17
| | | | | | Bug introduced in rev. 1.248 triggered for example in gssapi(3), analyzed and reported by Michael <Stapelberg at debian dot org>. Simplify the code a bit more while here.
* Improve HTML formatting of .Bl -tag.Ingo Schwarze2017-01-251-4/+46
| | | | | | | | | | | | | | | | | | | | | In particular, when using the style sheet, put the body on the same line as the head for short heads, or on the next line for long heads, in a way that preserves both correct indentation and correct vertical spacing with and without -compact, and with one or more heads per body (hi, Zaphod) - eight use cases so far - and with and without -tag, and with and without -offset, 32 use cases grand total. Using many ideas from zhuk@, from <David dot Dahlberg at fkie dot fraunhofer dot de>, and from Benny Lofgren <bl dash lists at lofgren dot biz>, and a few of my own. This is an excellent demonstration that CSS is an extremely hostile language, much more trapful and much harder to use than, say, C. When matthew@ reported this in July 2014 (!), it was already a known issue, and i no longer remember for how long. My first serious attempt at fixing it (in November 2015) failed miserably. I'd love to see simplifications of both the generated HTML code and of the style sheet, but without breaking any of the 32 use cases, please.
* Avoid writing constant style attributes over and over again.Ingo Schwarze2017-01-211-10/+15
| | | | Move them to the style sheet.
* clean up the remaining class attributesIngo Schwarze2017-01-211-8/+8
|
* Standardize class attributes for semantic macros.Ingo Schwarze2017-01-201-43/+44
| | | | Correct markup for .Va and iprove markup for .Dv, .Er, .Ev while here.
* standardize .Rs class attributesIngo Schwarze2017-01-201-24/+18
|
* standardize .Bl and .It class attributesIngo Schwarze2017-01-201-72/+104
|
* clean up markup of .Bd, .D1, .Dl, .Li, and .Ql;Ingo Schwarze2017-01-191-14/+10
| | | | in particular, stop abuse of <blockquote>
* clean up .Sx and .Xr HTML markupIngo Schwarze2017-01-191-7/+7
|
* Clean up CSS rules for sections and paragraphs.Ingo Schwarze2017-01-191-10/+8
| | | | Start using real macro names for CSS classes.
* Start cleanup: trim useless HTML comments, <div> elements,Ingo Schwarze2017-01-191-10/+8
| | | | and CSS rules on the <html> and <body> levels.
* Implement line breaking of the generated HTML code at space charactersIngo Schwarze2017-01-191-3/+1
| | | | | | | | | in filled text. This does not affect HTML semantics, but makes the HTML code even more humanly readable. While here, - collapse multiple consecutive space characters in filled text - and insert a blank between style entries.
* Make HTML output more human readable by overhauling line break logicIngo Schwarze2017-01-181-2/+1
| | | | | around tags and by introducing some simple indentation. No change of HTML semantics intended.
* Completely delete the buf field of struct html and all the buf*()Ingo Schwarze2017-01-171-74/+78
| | | | | | | | | interfaces. Such a static buffer was a bad idea in the first place, causing unfixable truncation that was only prevented by triggering an assertion failure. Instead, let the small number of remaining users allocate and free their own, temporary dynamic buffers, or for the case of .Xr and .In, pass the original data to be assembled in print_otag().
* Simplify the usage of print_otag() by making it accept a variableIngo Schwarze2017-01-171-403/+159
| | | | | | | | | | number of arguments. Delete struct htmlpair and all the PAIR_*() macros. Delete enum htmlattr, handle that in print_otag() instead. Minus 190 lines of code; no functional change except better ordering of attributes (class before style) in three cases.
* Do text production for .Bt, .Ex, .Rv, .Ud at the validation stageIngo Schwarze2017-01-111-113/+5
| | | | | | | | | rather than in the formatters. Use NODE_NOSRC flag for .Lb and NODE_NOSRC and NODE_NOPRT for .St. Results in a more rigorous syntax tree and in 135 lines less code. This work was triggered by a question from Abhinav Upadhyay <er dot abhinav dot upadhyay at gmail dot com> (NetBSD) on discuss@.
* Use new NODE_NOSRC and NODE_NOPRT flags for .Bx and .At.Ingo Schwarze2017-01-101-30/+2
| | | | More rigorous AST and 40 lines less code.
* For the .Ux/.Ox family of macros, do text production at the validationIngo Schwarze2017-01-101-35/+2
| | | | | stage rather than in each and every individual formatter, using the new NODE_NOSRC flag. More rigorous and also ten lines less code.
* unify names of AST node flags; no change of cpp outputIngo Schwarze2017-01-101-19/+19
|
* Introduce flags NODE_NOSRC and NODE_NOPRT for AST nodes.Ingo Schwarze2017-01-101-1/+4
| | | | | | | | | Use them to mark generated nodes and nodes that shall not produce output. Let -Ttree output mode display these new flags. Use NODE_NOSRC for .Ar, .Mt, and .Pa default arguments. Use NODE_NOPRT for .Dd, .Dt, and .Os. These will help to make handling of text production macros more rigorous.
* The .No macro is not supposed to produce fixed-width font, it is notIngo Schwarze2017-01-091-2/+2
| | | | | the same as .Li, so don't use <code>. Bug reported by <Anton dot Lindqvist at gmail dot com> on tech@.
* Indentation must be measured in units of the surrounding text,Ingo Schwarze2017-01-081-9/+9
| | | | | | | | | | not in units of the contained text. Consequently, "display" and "lit" class tags must not be on the same element: First, "display" must set up the indentation, still using the outer units, and only after that, "lit" may change the font. This fixes .Bd -literal which got the wrong indentation. Bug reported by tb@.
* Delete the redundant "nchild" member of struct roff_node, replacingIngo Schwarze2016-01-081-25/+26
| | | | | | | | most uses by one, a few by two pointer checks, and only one by a tiny loop - not only making data smaller, but code shorter as well. This gets rid of an implicit invariant that confused both static analysis tools and human auditors. No functional change.
* Generate simpler in-page links: just replace spaces with underscores.Ingo Schwarze2016-01-041-4/+2
| | | | Patch from bentley@.
* To make the code more readable, delete 283 /* FALLTHROUGH */ commentsIngo Schwarze2015-10-121-55/+1
| | | | | | that were right between two adjacent case statement. Keep only those 24 where the first case actually executes some code before falling through to the next case.
* modernize style: "return" is not a functionIngo Schwarze2015-10-061-96/+96
|
* /* NOTREACHED */ after abort() is silly, delete itIngo Schwarze2015-09-261-6/+1
|
* resolve code duplication and do style cleanup in mdoc_nm_pre(),Ingo Schwarze2015-09-261-9/+5
| | | | no functional change
* Fix multiple aspects of SYNOPSIS .Nm formatting:Ingo Schwarze2015-09-261-3/+4
| | | | | | * Don't break lines before non-block .Nm elements. * Use proper <b> markup for the heads of .Nm blocks. * Make the width measurements work by doing them on the head children.
* If an .Fo macro lacks its mandatory argument, don't die on an assertion.Ingo Schwarze2015-08-301-4/+3
| | | | Bug found by jsg@ with afl.
* Delete the wrapper functions mdoc_meta(), man_meta(), mdoc_node(),Ingo Schwarze2015-04-181-18/+11
| | | | | | man_node() from the mandoc(3) semi-public interface and the internal wrapper functions print_mdoc() and print_man() from the HTML formatters. Minus 60 lines of code, no functional change.
* Replace the structs mdoc and man by a unified struct roff_man.Ingo Schwarze2015-04-181-2/+2
| | | | | Almost completely mechanical, no functional change. Written on the train from Exeter to London returning from p2k15.
* Restore the page headers and page footers that accidentally got lostIngo Schwarze2015-04-161-7/+3
| | | | in rev. 1.225. Regression reported by florian@.
* Third step towards parser unification:Ingo Schwarze2015-04-021-2/+2
| | | | | Replace struct mdoc_meta and struct man_meta by a unified struct roff_meta. Written of the train from London to Exeter on the way to p2k15.
* Second step towards parser unification:Ingo Schwarze2015-04-021-7/+7
| | | | | | | | | Replace struct mdoc_node and struct man_node by a unified struct roff_node. To be able to use the tok member for both mdoc(7) and man(7) without defining all the macros in roff.h, sacrifice a tiny bit of type safety and make tok an int rather than an enum. Almost mechanical, no functional change. Written on the Eurostar from Bruxelles to London on the way to p2k15.
* First step towards parser unification:Ingo Schwarze2015-04-021-54/+55
| | | | | | Replace enum mdoc_type and enum man_type by a unified enum roff_type. Almost mechanical, no functional change. Written on the ICE train from Frankfurt to Bruxelles on the way to p2k15.
* If an eqn(7) starts on a new input line, be sure to output whitespaceIngo Schwarze2015-03-031-1/+3
| | | | | | | in front of it. Issue found by tedu@ in glOrtho(3). There are also cases of excessive whitespace before and after equations. This patch neither fixes them nor makes them worse.
* Delete the mdoc_node.pending pointer and the function calculatingIngo Schwarze2015-02-121-5/+6
| | | | | | | | | | | | | | | | | | | | | | | it, make_pending(), which was the most difficult function of the whole mdoc(7) parser. After almost five years of maintaining this hellhole, i just noticed the pointer isn't needed after all. Blocks are always rewound in the reverse order they were opened; that even holds for broken blocks. Consequently, it is sufficient to just mark broken blogs with the flag MDOC_BROKEN and breaking blocks with the flag MDOC_ENDED. When rewinding, instead of iterating the pending pointers, just iterate from each broken block to its parents, rewinding all that are MDOC_ENDED and stopping after processing the first ancestor that it not MDOC_BROKEN. For ENDBODY markers, use the mdoc_node.body pointer in place of the former mdoc_node.pending. This also fixes an assertion failure found by jsg@ with afl, test case #467 (Bo Bl It Bd Bc It), where (surprise surprise) the pending pointer got corrupted. Improved functionality, minus one function, minus one struct field, minus 50 lines of code.
* do not access a NULL pointer if an .Eo block lacks a tail;Ingo Schwarze2015-02-111-4/+3
| | | | found by jsg@ with afl, test case #16
* fix handling of empty .An macrosIngo Schwarze2015-02-051-4/+1
|
* Simplify by deleting the "lastline" member of struct mdoc_node.Ingo Schwarze2015-02-051-7/+4
| | | | Minus one struct member, minus 17 lines of code, no functional change.