summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* style improvement from jmc@, no output change;Ingo Schwarze2019-02-071-4/+2
| | | | | | | | | | original commit message: .Pp .Bd ... -compact is better written as .Bd ...
* Remove the misleading statement ".No takes no arguments".Ingo Schwarze2019-02-061-2/+2
| | | | | In facts, i works very similarly to .Em and .Sy. Triggered by a question from Kurt Mosiejczuk <kurt at cranky dot work>.
* Let roff_getname() end the roff identifier at a tab characterIngo Schwarze2019-02-0618-22/+217
| | | | | | | | | | | | | | | | | | | | | | and audit all its callers whether termination is handled correctly. Resulting improvements: * An escape or tab ending the macro name in a macro invocation is discarded, and argument processing is started after it. * An escape or tab ending a name in ".if d" and ".if r" is preserved. * An escape ending a name in ".ds" causes the whole request to be ignored. * A tab ending a name in ".ds" becomes part of the string. * An escape or tab ending a name in ".rm" causes the rest of the line to be ignored. * An escape or tab ending the first name in ".als", ".rn", or ".nr" causes the whole request to be ignored. Kurt Jaeger <pi at FreeBSD> made me aware of https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=235456#c0 and in that bug report, comment 0 item (3) is a special case of this class of issues. Yes, the "mh" manual pages are no doubt among the worst on the planet.
* adjust style and comments in roff_getname(); no functional changeIngo Schwarze2019-02-061-11/+14
|
* Relax overzealous PATH_INFO validation.Ingo Schwarze2019-01-311-1/+1
| | | | | | | URIs like https://man.openbsd.org/OpenBSD-2.2/cat1/cat.0 are still required to work because they result from apropos searches for old releases (up to 5.0) which used to install preformatted manual pages. Regression reported by jj@.
* Since resetting of offsets works quite differently in man(7) and mdoc(7),Ingo Schwarze2019-01-313-2/+29
| | | | | test table centering in an mdoc(7) document as well. Related to tbl_term.c rev. 1.67.
* Fix tbl(7) centering in mdoc(7) documents.Ingo Schwarze2019-01-311-3/+7
| | | | | | | | | | Since resetting of offsets works quite differently in the mdoc(7) and man(7) formatters, the tbl(7) formatter needs to save the global offset on entry and restore it on exit. The additional indentation needed for table centering has to be added to its own offset variable and applied to each line of the table, rather than only to the first. Bug found by bentley@ in emulators/fceux(6).
* The .UR and .MT blocks in man(7) are represented by <a> elementsIngo Schwarze2019-01-184-55/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | which establish phrasing context, but they can contain paragraph breaks (which is relevant for terminal formatting, so we can't just change the structure of the syntax tree), which are respresented by <p> elements and cannot occur inside <a>. Fix this by prematurely closing the <a> element in the HTML formatter. This menas that the clickable text in HTML output is shorter than what is represented as the link text in terminal output, but in HTML, it is frankly impossible to have the clickable area of a hyperlink extend across a paragraph break. The difference in presentation is not a major problem, and besides, paragraph breaks inside .UR are rather poor style in the first place. The implementation is quite tricky. Naively closing out the <a> prematurely would result in accessing a stale pointer when later reaching the physical end of the .UR block. So this commit separates visual and structural closing of "struct tag" stack items. Visual closing means that the HTML element is closed but the "struct tag" remains on the stack, to avoid later access to a stale pointer and to avoid closing the same HTML element a second time later. This also needs reference counting of pointers to "struct tag" stack items because often more than one child holds a pointer to the same parent item, and only the outermost child can safely do the physical closing. In the whole corpus of nearly half a million manual pages on man.openbsd.org, this problem occurs in exactly one page: the groff(1) version 1.20.1 manual contained in DragonFly-3.8.2, which contains a formatting error triggering the bug.
* Delete several entries that were already fixed.Ingo Schwarze2019-01-171-28/+1
| | | | | The two entries about dashes, hyphens, and minus signs are no longer relevant because we decided on a policy that is now documented.
* Test handling of escaped backslashes because the code related toIngo Schwarze2019-01-175-2/+97
| | | | copy mode is complicated and prone to regressions.
* In PostScript and PDF output, one AFM unit is not nearly enoughIngo Schwarze2019-01-151-2/+3
| | | | | | inter-word spacing, let's try again with 250 AFM units. Regression caused during my recent term_flushln() reorg in rev. 1.278, reported by brynet@ (sorry and many thanks for reporting).
* Improve error reporting when a file given on the command lineIngo Schwarze2019-01-112-3/+5
| | | | | | cannot be opened: * Mention the filename. * Report the errno for the file itself, not the one with .gz appended.
* do not access a NULL pointer when formatting a completely empty documentIngo Schwarze2019-01-112-3/+3
|
* Remove the HTML title= attributes which harmed accessibility andIngo Schwarze2019-01-1111-78/+140
| | | | | | | violated the principle of separation of content and presentation. Instead, implement the tooltips purely in CSS. Thanks to John Gardner <gardnerjohng at gmail dot com> for suggesting most of the styling in the new ::before rules.
* After years of gnashing of teeth, i finally found a way to avoidIngo Schwarze2019-01-102-13/+6
| | | | | | | | | | | | | | | | | | having to write empty list elements for non-compact .Bl -tag lists: 1. Add margin-bottom to the <dd>. Note that margin-top on the <dt> doesn't work because it would put a short <dt> lower than the <dd>; margin-bottom on the <dt> doesn't work because it would put vertical space before the <dd> for a long <dt>; and margin-top on the <dd> doesn't work because it would put a short <dt> higher than the <dd>. Only margin-bottom on the <dd> has none of these adverse effects. 2. Of course, margin-bottom on the <dd> fails to take care of the vertical spacing before the first list element, so implement that separately by margin-top on the <dl>. 3. For .Bl -tag -compact, reset both to zero.
* Initializers for file-scope static variables should be compile-timeIngo Schwarze2019-01-102-2/+3
| | | | | | | | constants, and while stderr is a compile-time constant in OpenBSD, Kelvin Sherlock <ksherlock at gmail dot com> reports that it isn't on some other systems, for example on FreeBSD or Linux. So do the initialization by calling mandoc_msg_setoutfile() from main() instead.
* Represent mdoc(7) .Pp (and .sp, and some SYNOPSIS and .Rs features)Ingo Schwarze2019-01-0741-181/+618
| | | | | | | | | | | | | | | | | | | by the <p> HTML element and use the html_fillmode() mechanism for .Bd -unfilled, just like it was done for man(7) earlier, finally getting rid both of the horrible <div class="Pp"></div> hack and of the worst HTML syntax violations caused by nested displays. Care is needed because in some situations, paragraphs have to remain open across several subsequent macros, whereas in other situations, they must get closed together with a block containing them. Some implementation details include: * Always close paragraphs before emitting HTML flow content. * Let html_close_paragraph() also close <pre> for extra safety. * Drop the old, now unused function print_paragraph(). * Minor adjustments in the top-level man(7) node formatter for symmetry. * Bugfix: .Ss heads suspend no-fill mode, even though .Ss doesn't end it. * Bugfix: give up on .Op semantic markup for now, see the comment.
* Finally, represent the man(7) .PP and .HP macros by the naturalIngo Schwarze2019-01-0633-117/+461
| | | | | | | | | | | choice, which is the <p> HTML element. On top of the previous fill-mode improvements, the key to making this possible is to automatically close the <p> when required: before headers, subsequent paragraphs, lists, indented blocks, synopsis blocks, tbl(7) blocks, and before blocks using no-fill mode. In man(7) documents, represent the .sp request by a blank line in no-fill mode and in the same way as .PP in fill mode.
* In no-fill mode, avoid bogus blank lines in two situations:Ingo Schwarze2019-01-053-3/+35
| | | | | 1. After the last child; the parent will take care of the line break. 2. At the .YS macro; the end of the preceding .SY already broke the line.
* In groff, when the .SY block macro occurs in no-fill mode,Ingo Schwarze2019-01-055-3/+69
| | | | the output line gets broken after the head. Do the same.
* Slowly start doing more HTML output tests, in this case for theIngo Schwarze2019-01-054-12/+44
| | | | | | | | | | | | | | | | | | | interaction of .nf and .RS, related to man_macro.c rev. 1.106. HTML regression testing is tricky because it is extremely prone to over-testing, i.e. unintentional testing for volatile formatting details which are irrelevant for deciding whether the HTML output is good or bad. Minor changes to the formatter - which is still heavily under development - might result in the necessity to repeatedly adjust many test cases. Then again, HTML syntax rules are so complicated that without regression testing, the risk is simply too high that later changes will re-introduce issues that were already fixed earlier. Let's just try to design the tests very carefully in such a way that the *.out_html files contain nothing that is likely to change, and defer testing in cases where the HTML output is not yet clean enough to allow designing tests in such a way.
* In HTML output, man(7) .RS blocks get formatted as <div class="Bd-indent">,Ingo Schwarze2019-01-051-1/+4
| | | | | | | | | and i can see no reasonable alternative: they do indeed represent indented displays. They certainly require flow context and make no sense in phrasing context. Consequently, they have to suspend no-fill mode during their head, in just the same way as other paragraph-type macros do it. This fixes HTML syntax errors that resulted from .nf followed by .RS.
* minor cleanup, no functional change:Ingo Schwarze2019-01-051-23/+15
| | | | | | | | * delete one irrelevant FIXME; no more fixed lengths in HTML, please * simplify some conditions * avoid testing pointers as truth values, use "!= NULL" * sort some declarations * delete some pointless blank lines
* Now that the NODE_NOFILL flag in the syntax tree is accurate,Ingo Schwarze2019-01-054-119/+70
| | | | | | | | | | use it in the man(7) HTML formatter rather than keeping fill mode state locally, resulting in massive simplification (minus 40 LOC). Move the html_fillmode() state handler function to the html.c module such that both the man(7) and the roff(7) formatter (and in the future, also the mdoc(7) formatter) can use it. Give it a query mode, to be invoked with TOKEN_NONE.
* no-fill mode has to be suspended during tbl(7) rendering, tooIngo Schwarze2019-01-051-0/+2
|
* minor cleanup, no functional change:Ingo Schwarze2019-01-051-81/+64
| | | | | | | | | | | * in node type switches, explicitly handle all types, sort them, and abort() on those that cannot occur * avoid testing pointers as truth values, use "!= NULL" * avoid testing "constant == variable", use "variable == constant" * prefer sizeof(var) over sizeof(type) * delete one duplicate function * sort some declarations * delete some useless blank lines
* Some high-level block macros have an effect similar to temporarilyIngo Schwarze2019-01-055-11/+17
| | | | | | | | | | | | suspending no-fill mode during their head. Model this with an additional roff parser state flag ROFF_NONOFILL. That is much simpler than it would be to save and restore the ROFF_NOFILL flag itself, in particular since the latter can be switched (with lasting effect) by the .nf and .fi requests even while its effect is temporarily suspended. This commit does not change formatting yet, but prepares for future formatting simplifications and improvements.
* Test interaction of low-level roff(7) filling requests with .Bd in generalIngo Schwarze2019-01-047-12/+97
| | | | and filling in .Bd -centered in particular; related to mdoc_term.c rev. 1.372.
* Two functional improvements to filling in terminal output.Ingo Schwarze2019-01-042-70/+43
| | | | | | | | | | | 1. Fully support no-fill mode in mdoc(7), even when invoked with low-level roff(7) .nf requests. As a side effect, this substantially simplifies the implementation of .Bd -unfilled and .Bd -literal. 2. Let .Bd -centered fill its text, using the new TERMP_CENTER flag. That finally fixes the long-standing bug that it used to operate in no-fill mode, which was known to be wrong for at least five years. This also simplifies the implementation of .Bd -centered considerably.
* Simplify the roff(7) .ce and .rj terminal formatter by using theIngo Schwarze2019-01-041-14/+3
| | | | new TERMP_CENTER and TERMP_RIGHT flags. No functional change.
* Implement centering and adjustment to the right margin directly inIngo Schwarze2019-01-042-2/+18
| | | | | | | the terminal filling routine, controlled by new flags TERMP_CENTER and TERMP_RIGHT. This became possible by the recent term_flushln() rewrite. No functional change yet, but to be used by upcoming commits.
* Oops, i forgot to adjust this file to the changes in roff.h rev. 1.67.Ingo Schwarze2019-01-041-9/+32
| | | | | | Provide a handler for the new .nf and .fi roff(7) request nodes, avoiding a potential crash, and correctly restore the former fill more at .Ed even when there was .nf or .fi inside the block.
* test the roff(7) .ce and .rj requests;Ingo Schwarze2019-01-044-2/+43
| | | | they were already supported in the past
* Rewrite the line filling function for terminal output yet again.Ingo Schwarze2019-01-031-178/+252
| | | | | | | | | | | | | | | | | | | | | | | | | | | This function has always been among the most complicated parts of mandoc, and it repeatedly needed substantial functional enhancements. The present rewrite is required to prepare for the implementation of simultaneous filling and centering of output lines. The previous implementation looked at each word in turn and printed it to the output stream as soon as it was found to still fit on the current output line. Obviously, that approach neither allows centering nor adjustment to the right margin. The new implementation first decides which part of the paragraph to put onto the current output line, also measuring the display width of that part, even if that part consists of multiple words including intervening whitespace. This will allow moving the whole output line to the right as desired before printing it, for example to center it or to adjust it to the right margin. The function is split into three parts, each much shorter, solving a better defined task, much easier to understand and better commented: 1. the steering function term_flushln() looping over output lines; 2. the calculation function term_fill() looping over input characters; 3. and the output function term_field() looping over printed characters. No functional change yet.
* Support taking the -O tag value from apropos(1) key=value search terms;Ingo Schwarze2019-01-012-9/+26
| | | | | | feature improvement suggested by kn@. While here, also make "-O value" work from standard input. OK kn@
* Correctly set the ROFF_NOFILL parser flag for .Bd .Ed .Sh, suchIngo Schwarze2019-01-012-42/+47
| | | | | | that children and later siblings get correct NODE_NOFILL assignments. This doesn't change rendering yet but prepares for future rendering improvements.
* display the NODE_NOFILL flag indicating no-fill modeIngo Schwarze2019-01-011-11/+15
|
* Now that .nf and .fi are implemented in the roff(7) parser and formattersIngo Schwarze2019-01-012-31/+43
| | | | | | | rather than in the man(7) parser and formatters, document them in the roff(7) manual, where they belong, rather than in the man(7) manual. Mention that they imply an output line break, and mention which macros imply these requests.
* drop flag HTML_LITERAL which is no longer usedIngo Schwarze2018-12-311-1/+0
|
* Cleanup, minus 25 LOC, no functional change:Ingo Schwarze2018-12-311-47/+6
| | | | | Delete the complicated mechanism keeping fill mode state locally in the man(7) HTML formatter. Instead, use the state stored in the nodes.
* Cleanup, no functional change:Ingo Schwarze2018-12-311-12/+3
| | | | | | | | | | Stop trying to keep fill mode state locally in the mdoc HTML formatter, rely on the state stored in the nodes instead. Note that the .Bd -literal code is buggy. Nested literal displays result in nested <pre> elements, which violates HTML syntax. But i'm not yet fixing bugs in this commit, i'm merely deleting code which has no effect.
* Cleanup, no functional change:Ingo Schwarze2018-12-314-23/+2
| | | | | | Since the man(7) and roff(7) validators no longer use the parser state flag ROFF_NOFILL, we can finally get rid of the function man_state(), resulting in a better separation of parsing and validation.
* oops, one change ROFF_NOFILL -> NODE_NOFILL was forgotten in rev. 1.17Ingo Schwarze2018-12-311-1/+1
|
* catch up with the changed order of warnings;Ingo Schwarze2018-12-312-2/+2
| | | | related to man_validate.c rev. 1.145
* Use the new flag NODE_NOFILL in the validators, which is sometimesIngo Schwarze2018-12-314-13/+22
| | | | | | simpler and always more robust. In particular, move the nesting warnings for .EX and .EE from man_state(), where they were misplaced, to the man(7) validator.
* Store the fill mode with a new flag NODE_NOFILL in every node,Ingo Schwarze2018-12-312-7/+12
| | | | | | like it is already done with NODE_SYNPRETTY, such that the fill mode becomes more directly available to the formatters. Not used yet, but will be used by upcoming commits.
* For .EX and .EE, set the fill mode parser state directly in theIngo Schwarze2018-12-311-0/+5
| | | | | | macro parsing function, in the same way as the roff parser already does it for the .nf and .fi requests. This is a preparation for getting rid of the ugly function man_state() later on.
* Cleanup, no functional change:Ingo Schwarze2018-12-314-8/+7
| | | | | | Use the new parser flag ROFF_NOFILL in the mdoc(7) parser, too, instead of the old MDOC_LITERAL, which was an alias for the former MAN_LITERAL.
* Move parsing of the .nf and .fi (fill mode) requests from the man(7)Ingo Schwarze2018-12-3111-80/+94
| | | | | | parser to the roff(7) parser. As a side effect, .nf and .fi are now also parsed in mdoc(7) input, though the mdoc(7) formatters still ignore most of their effect.
* Cleanup, minus 15 LOC, no functional change:Ingo Schwarze2018-12-3112-41/+18
| | | | | | | | | Simplify the way the man(7) and mdoc(7) validators are called. Reset the parser state with a common function before calling them. There is no need to again reset the parser state afterwards, the parsers are no longer used after validation. This allows getting rid of man_node_validate() and mdoc_node_validate() as separate functions.