summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/mdoc_html.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* The .No macro is not supposed to produce fixed-width font, it is notschwarze2017-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,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, replacingschwarze2016-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.bentley2015-12-251-4/+2
| | | | | | | | | So http://example.com/OpenBSD-current/man1/ls.1#x546865204c6f6e6720466f726d6174 becomes http://example.com/OpenBSD-current/man1/ls.1#The_Long_Format ok schwarze@
* To make the code more readable, delete 283 /* FALLTHROUGH */ commentsschwarze2015-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 function; ok cmp(1)schwarze2015-10-061-96/+96
|
* /* NOTREACHED */ after abort() is silly, delete itschwarze2015-09-261-6/+1
|
* resolve code duplication and do style cleanup in mdoc_nm_pre(),schwarze2015-09-261-9/+5
| | | | no functional change
* Fix multiple aspects of SYNOPSIS .Nm formatting: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.schwarze2015-08-301-4/+3
| | | | Bug found by jsg@ with afl.
* Delete the wrapper functions mdoc_meta(), man_meta(), mdoc_node(),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.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 lostschwarze2015-04-161-7/+3
| | | | in rev. 1.225. Regression reported by florian@.
* Third step towards parser unification: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: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: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 whitespaceschwarze2015-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 calculatingschwarze2015-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;schwarze2015-02-111-4/+3
| | | | found by jsg@ with afl, test case #16
* fix handling of empty .An macrosschwarze2015-02-051-4/+1
|
* Simplify by deleting the "lastline" member of struct mdoc_node.schwarze2015-02-051-7/+4
| | | | Minus one struct member, minus 17 lines of code, no functional change.
* fix .Eo/.Ec spacingschwarze2015-02-011-14/+52
|
* Have pity on the poor stack.schwarze2015-01-301-4/+5
| | | | | Replace tail recursion by iteration when walking the syntax trees. No functional change.
* Let .Aq/.Ao/.Ac print "<>" instead of the normal "\(la\(ra"schwarze2015-01-231-6/+6
| | | | | | when the only child is .Mt, not when the preceding node is .An, to improve robustness. Triggered by a question from Svyatoslav Mishyn <juef at openmailbox dot org> (Crux Linux).
* support negative horizontal widths in man(7);schwarze2014-12-231-3/+7
| | | | minus twenty lines of code in spite of enhanced functionality
* some scaling unit fixes:schwarze2014-12-231-3/+3
| | | | | - .sp with an invalid argument is .sp 1v, not .sp 0v - in man(1), trailing garbage doesn't make scaling units invalid
* Fix the implementation and documentation of \c (continue text input line).schwarze2014-12-021-2/+3
| | | | | In particular, make it work in no-fill mode, too. Reminded by Carsten dot Kunze at arcor dot de (Heirloom roff).
* header cleanup:schwarze2014-12-011-3/+2
| | | | | | * add missing forward declarations * remove needless header inclusions * some style unification
* Multiple fixes with respect to .Pf:schwarze2014-11-301-2/+3
| | | | | | | * The first argument of .Pf is not parsed. * Normal delimiter handling does not apply to the first argument of .Pf. * Warn if nothing follows a prefix (inspired by groff_mdoc(7)). * In that case, do not suppress spacing.
* Multiple fixes with respect to .Eo:schwarze2014-11-271-9/+14
| | | | | | | | 1. Correctly parse stray .Ec without preceding .Eo, avoiding an assertion violation found by jsg@ with afl. 2. Correctly parse .Ec arguments when breaking another block. 3. Correct spacing around closing delimiter when breaking another block. 4. Sync some related formatting control from -Tascii to -Thtml.
* Fix the obsolete .Db (toggle debug mode) macro to ignore its argumentsschwarze2014-11-271-2/+2
| | | | | and not trigger an assertion when there is more than one argument; the latter found by jsg@ with afl.
* Let .Ao and .Aq render as "<>" after .An and as "\(la\(ra" elsewhere,schwarze2014-11-191-3/+5
| | | | just like groff; minibug noticed by bentley@.
* Multiple fixes with respect to in-line macros:schwarze2014-11-171-2/+13
| | | | | | | | | | * .No selects the default font; relevant e.g. in .Bf blocks * no need to force empty .Li elements * closing delimiters as leading macro arguments do not suppress space * opening delimiters at the end of a macro line do not suppress space * correctly handle delimiter spacing in -Tman As a side effect, these fixes let mandoc warn about empty .No macros as requested by bentley@.
* Major bugsquashing with respect to -offset and -width:schwarze2014-10-301-28/+14
| | | | | | | | | 1. Support specifying the .Bd and .Bl -offset as a macro default width; while here, simplify the code handling the same for .Bl -width. 2. Correct handling of .Bl -offset arguments: unlike .Bd -offset, the arguments "left", "indent", and "indent-two" have no special meaning. 3. Fix the scaling of string length -offset and -width arguments in -Thtml. Triggered by an incomplete documentation patch from bentley@.
* Switch HTML output to polyglot HTML5; have only one single -Thml mode.schwarze2014-10-071-37/+23
| | | | | | | | Replace hard-coded widths and alignments with a minimal embedded stylesheet. Do not use <p> because it cannot appear inside block macros. Remove the "summary" attribute because it is not HTML5. Written by kristaps@ some months ago, finished during EuroBSDCon.
* implement .An -[no]split for -Thtmlschwarze2014-09-171-4/+28
|
* Right after .Fl, a middle delimiter triggers an empty scope,schwarze2014-08-211-4/+5
| | | | | | | | | | | | just like a closing delimiter. This didn't work in groff-1.15, but it now works in groff-1.22. After being closed by delimiters, .Nm scopes do not reopen. Do not suppress white space after .Fl if the next node is a text node on the same input line; that can happen for middle delimiters. Fixing an issue reported by jmc@.
* Revert previous, as requested by kristaps@.schwarze2014-08-141-5/+7
| | | | | | | | | | | | | The .Bf block can contain subblocks, so it has to render as an element that can contain flow content. But <em> cannot contain flow content, only phrasing content. Rendering .Em and .Bf differently would by unfortunate, and closing out .Bf before subblocks and re-opening it afterwards would merely complicate both the C code of the program and the generated HTML code. Besides, converting .Em to semantic HTML markup would require some content to be put into <em> and some into <i>, but we cannot automatically distinguish which is which, so strictly speaking, we can't use semantic HTML here but have to fall back to physical markup. Wonders of HTML...
* Use <em> for .Em and .Bf -emphasis.schwarze2014-08-131-7/+5
| | | | | | | | | | | | | | | | | The vast majority of .Em in real-world manuals is stress emphasis, for which <em> is the correct markup. Admittedly, there are some instances of .Em usage for alternate quality, for which <i> would be a better match. Most of these are technical terms that neither allow semantic markup nor are keywords - for the latter, .Sy would be preferable. A typical example is that the shell breaks input into .Em words . Alternate voice or mood, which would also require <i>, is almost absent from manuals. We cannot satisfy both stress emphasis and alternate quality, so pick the one that fits more often and looks less wrong when off. Patch from Guy Harris <guy at alum dot mit dot edu>. ok bentley@ joerg@NetBSD
* Bring the handling of defective prologues even closer to groff,schwarze2014-08-081-4/+9
| | | | | | | | | | | | in particular relaxing the distinction between prologue and body and further improving messages. * The last .Dd wins and the last .Os wins, even in the body. * The last .Dt before the first body macro wins. * Missing title in .Dt defaults to UNTITLED. Warn about it. * Missing section in .Dt does not default to 1. But warn about it. * Do not warn multiple times about the same mdoc(7) prologue macro. * Warn about missing .Os. * Incomplete .TH defaults to empty strings. Warn about it.
* Clarity with respect to floating point handling:schwarze2014-08-081-3/+3
| | | | | | Write double constants as double rather than integer literals. Remove useless explicit (double) cast done at one place and nowhere else. No functional change.
* Various improvements related to .Ex and .Rv:schwarze2014-08-081-25/+31
| | | | | | | | | | * let .Nm fall back to the empty string, not to UNKNOWN * never let .Rv copy an argument from .Nm * avoid spurious \fR after empty .Nm in -Tman * correct handling of .Ex and .Rv in -Tman * correct the wording of the output for .Rv without arguments * use non-breaking spaces in .Ex and .Rv output where required * split MANDOCERR_NONAME into a warning for .Ex and an error for .Nm
* When .Sm is called without an argument, groff toggles the spacing mode,schwarze2014-07-021-15/+8
| | | | | so let us do the same for compatibility. Using this feature is of course not recommended except in manual page obfuscation contests.
* Implement the obsolete macros .En .Es .Fr .Ot for backward compatibility,schwarze2014-07-021-9/+24
| | | | | since this is hardly more complicated than explicitly ignoring them as we did in the past. Of course, do not use them!
* Audit strlcpy(3)/strlcat(3) usage.schwarze2014-04-231-17/+22
| | | | | | | | | | | | | * Repair three instances of silent truncation, use asprintf(3). * Change two instances of strlen(3)+malloc(3)+strlcpy(3)+strlcat(3)+... to use asprintf(3) instead to make them less error prone. * Cast the return value of four instances where the destination buffer is known to be large enough to (void). * Completely remove three useless instances of strlcpy(3)/strlcat(3). * Mark two places in -Thtml with XXX that can cause information loss and crashes but are not easy to fix, requiring design changes of some internal interfaces. * The file mandocdb.c remains to be audited.
* fix unchecked snprintf(3) in page header printing:schwarze2014-04-201-3/+7
| | | | | the length of the title is unknown, and speed doesn't matter here, so use asprintf/free rather than a static buffer
* KNF: case (FOO): -> case FOO, remove /* LINTED */ and /* ARGSUSED */,schwarze2014-04-201-305/+185
| | | | | remove trailing whitespace and blanks before tabs, improve some indenting; no functional change
* Implement the roff(7) .ll (line length) request.schwarze2014-03-301-2/+12
| | | | | Found by naddy@ in the textproc/enchant(1) port. Of course, do not use this in new manuals.
* It turns out SYNOPSIS mode does not imply .Bk in general,schwarze2013-12-241-2/+2
| | | | | | | but only within .Nm blocks. Simplify the code accordingly. This reduces groff-mandoc differences in base by about 2%. Triggered by research done by Franco Fichtner.
* When deciding whether two consecutive macros are on the same input line,schwarze2013-12-241-8/+4
| | | | | | | | we have to compare the line where the first one *ends* (not where it begins) to the line where the second one starts. This fixes the bug that .Bk allowed output line breaks right after block macros spanning more than one input line, even when the next macro follows on the same line.