summaryrefslogtreecommitdiffstats
path: root/man_term.c
Commit message (Collapse)AuthorAgeFilesLines
* Do not rewrite MAN_LP and MAN_P to MAN_PP because doing that causesIngo Schwarze2023-04-281-10/+2
| | | | | | | | | confusing warning messages complaining about macros that don't even appear in the input file. As a welcome side effect, this also shortens the code... Fixing a minibug reported by Alejandro Colomar <alx dot manpages at gmail dot com>.
* Stop unconditionally emitting vertical space before .TS (table start).Ingo Schwarze2022-08-281-1/+1
| | | | | | | | | | | | | | | Same change as in groff commit 7ec36dc9 Jul 30 2022 gbranden@ For more details, see https://savannah.gnu.org/bugs/index.php?62841 This change makes sense because: * It improves the formatting of more pages than it degrades. * Existing manual pages are wildly inconsistent in which behaviour they expect: apparently few manual page authors understood the old rules. * It simplifies the rules of how .TS behaves in man(7) and makes them more similar to how it behaves in mdoc(7). * It improves flexibility, making it possible for a table to immediately follow preceding text without a blank line, which some existing pages want to use, for example XCreateWindow(3).
* When starting a new input line, even when continuing the same outputIngo Schwarze2022-08-161-1/+4
| | | | | | line, use the current output position as the reference position for tabs on that input line. This brings mandoc in line with the behaviour of GNU, Heirloom, and Plan 9 roff.
* Simplify handling of no-fill mode in man(7) by inspecting NODE_NOFILLIngo Schwarze2022-08-151-24/+20
| | | | | | | | | | | | | at the beginning of the node handler, in the same way as it is done in the mdoc(7) node handler. As a side effect, this also fixes a bug: if an input line contained nothing but an escape sequence producing no output whatsoever (for example, \fR), the old code incorrectly emitted a blank line anyway, whereas the new code only emits such a blank link if the input line actually produces output (even invisible zero-width output). To make the distinction, the ASCII_NBRZW -> lastcol -> term_newln() mechanism established in term.c rev. 1.289 is used.
* In GNU, Heirloom, and Plan 9 roff, tab positions apply to *input* lines,Ingo Schwarze2022-08-151-0/+1
| | | | | | | | | | | | | not to *output* lines. In particular, if an input line gets broken in fill mode and a tab occurs in the second output line, it advances to a position of at least (width of the first output line) + (width of a space character even though this is never printed) + (width of the part of the second output line that precedes the tab). Implement the same logic in mandoc. Again, do not use tabs in filled text: they have surprising effects, including this one.
* The .AT, .DT, and .UC macros are allowed inside next-line scopeIngo Schwarze2022-04-271-3/+3
| | | | | | and never produce output at the place of their invocation. Minibugs found while investigating unrelated afl(1) reports from tb@.
* In terminal output of man(7) documents, stop printing two extra blankIngo Schwarze2021-06-281-8/+0
| | | | | | | | | | | lines before the NAME section and before the page footer. While these blank lines had a long tradition, they didn't really serve any purpose and merely wasted screen real estate. Besides, this makes output from man(7) more similar to output from mdoc(7). This commit keeps mandoc compatible with groff-current, where G. Branden Robinson committed the same change on June 16 (groff commit 2278d6ed).
* Split tagging into a validation part including prioritizationIngo Schwarze2020-03-131-77/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in tag.{h,c} and {mdoc,man}_validate.c and into a formatting part including command line argument checking in term_tag.{h,c}, html.c, and {mdoc|man}_{term|html}.c. Immediate functional benefits include: * Improved prioritization of automatic tags for .Em and .Sy. * Avoiding bogus automatic tags when .Em, .Fn, or .Sy are explicitly tagged. * Explicit tagging of .Er and .Fl now works in HTML output. * Automatic tagging of .IP and .TP now works in HTML output. But mainly, this patch provides clean earth to build further improvements on. Technical changes: * Main program: Write a tag file for ASCII and UTF-8 output only. * All formatters: There is no more need to delay writing the tags. * mdoc(7)+man(7) formatters: No more need for elaborate syntax tree inspection. * HTML formatter: If available, use the "string" attribute as the tag. * HTML formatter: New function to write permalinks, to reduce code duplication. Style cleanup in the vicinity while here: * mdoc(7) terminal formatter: To set up bold font for children, defer to termp_bold_pre() rather than calling term_fontpush() manually. * mdoc(7) terminal formatter: Garbage collect some duplicate functions. * mdoc(7) HTML formatter: Unify <code> handling, delete redundant functions. * Where possible, use switch statements rather than if cascades. * Get rid of some more Yoda notation. The necessity for such changes was first discussed with kn@, but i didn't bother him with a request to review the resulting -673/+782 line patch.
* Introduce the concept of nodes that are semantically transparent:Ingo Schwarze2020-02-271-22/+15
| | | | | | | | | | | | | | they are skipped when looking for previous or following high-level macros. Examples include roff(7) .ft, .ll, and .ta, mdoc(7) .Sm and .Tg, and man(7) .DT and .PD. Use this concept for a variety of improved decisions in various validators and formatters. While here, * remove a few const qualifiers on struct arguments that caused trouble; * get rid of some more Yoda notation in the vicinity; * and apply some other stylistic improvements in the vicinity. I found this class of issues while considering .Tg patches from kn@.
* Make the code more readable by introducingIngo Schwarze2020-01-201-3/+3
| | | | | | symbolic constants for tagging priorities. This review also made me find a minor bug: do not upgrade TAG_FALLBACK to TAG_WEAK when there is trailing whitespace.
* tagging support for .TP and .TQ; try e.g. man -O tag=commit cvsIngo Schwarze2019-07-231-0/+12
|
* Slowly start implementing tagging support for man(7) pages, evenIngo Schwarze2019-07-221-1/+64
| | | | | | | | | | | | | though it is obvious that this can never become as good as for mdoc(7) pages. As a first step, tag alphabetic arguments of .IP macros, which are often used for lists of options and keywords. Try "man -O tag=g as" to get the point. Thanks to Leah Neukirchen for recently reminding me that exploring how much can be done in this respect may be worthwhile: it is likely to slightly improve usability while adding only small amounts of relatively straightforward code.
* delete trailing whitespace and space-tab sequences; no code change;Ingo Schwarze2019-07-011-1/+1
| | | | | patch from Michal Nowak <mnowak at startmail dot com> who found these with git pbchk in the illumos tree
* Improve "man -h" output.Ingo Schwarze2019-06-271-11/+16
| | | | | | 1. For pages lacking a SYNOPSIS, show the NAME section rather than nothing. 2. Do not print a stray blank before the beginning of a SYNOPSIS. Both issues reported by, and patch OK'ed by, tb@.
* In groff, when the .SY block macro occurs in no-fill mode,Ingo Schwarze2019-01-051-1/+3
| | | | the output line gets broken after the head. Do the same.
* 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-051-2/+5
| | | | | | | | | | | | 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.
* 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.
* Move parsing of the .nf and .fi (fill mode) requests from the man(7)Ingo Schwarze2018-12-311-3/+6
| | | | | | 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, no functional change:Ingo Schwarze2018-12-301-5/+4
| | | | | | | | | | | | | | The struct roff_man used to be a bad mixture of internal parser state and public parsing results. Move the public results to the parsing result struct roff_meta, which is already public. Move the rest of struct roff_man to the parser-internal header roff_int.h. Since the validators need access to the parser state, call them from the top level parser during mparse_result() rather than from the main programs, also reducing code duplication. This keeps parser internal state out of thee main programs (five in mandoc portable) and out of eight formatters.
* Cleanup, no functional change:Ingo Schwarze2018-12-131-1/+0
| | | | | | | | | | Split the top level parser interface out of the utility header mandoc.h, into a new header mandoc_parse.h, for use in the main program and in the main parser only. Move enum mandoc_os into roff.h because struct roff_man is the place where it is stored. This allows removal of mandoc.h from seven files in low-level parsers and in formatters.
* In the validators, translate obsolete macro aliases (Lp, Ot, LP, P)Ingo Schwarze2018-12-031-2/+9
| | | | | | to the standard forms (Pp, Ft, PP) up front, such that later code does not need to look for the obsolete versions. This reduces the risk of incomplete handling.
* Support nesting of elements with next-line scope.Ingo Schwarze2018-08-261-2/+2
| | | | For example, ksh93(1) needs this for .B\n.SM.
* .SY causes a one-column indentation even without any argumentIngo Schwarze2018-08-181-1/+1
|
* The .nf/.fi (fill mode) requests never have text childrenIngo Schwarze2018-08-181-2/+2
| | | | and in particular do not reset font mode.
* Two consecutive .SY blocks only get a blank line in betweenIngo Schwarze2018-08-181-1/+2
| | | | if the first one is explicitly closed with .YS.
* prevent line breaks in the middle of .OPIngo Schwarze2018-08-181-1/+2
|
* implement the GNU man-ext .SY/.YS (synopsis block) macro in man(7),Ingo Schwarze2018-08-181-0/+60
| | | | used in most manual pages of the groff package
* Remove more pointer arithmetic passing via regions outside the arrayIngo Schwarze2018-08-171-13/+21
| | | | | that is undefined according to the C standard. Robert Elz <kre at munnari dot oz dot au> pointed out i wasn't quite done yet.
* implement the GNU man-ext .TQ macro in man(7),Ingo Schwarze2018-08-161-1/+3
| | | | used for example by groff_diff(7)
* support tail arguments on the .ME and .UE macros,Ingo Schwarze2018-08-141-0/+2
| | | | used for example in the ditroff(7) manual of the groff package
* When formatting man(7) documents that do not contain .SH macrosIngo Schwarze2018-06-101-0/+12
| | | | | with -Tps or -Tpdf, do not squeeze the whole text beyond the right margin. Bug reported by Will Backman during BSDCan.
* preserve comments before .Dd when converting mdoc(7) to man(7)Ingo Schwarze2018-04-111-4/+7
| | | | with mandoc -Tman; suggested by Thomas Klausner <wiz at NetBSD>
* Fix an out of bounds read access to a constant array that causedIngo Schwarze2017-07-311-2/+2
| | | | | | | segfaults on certain hardened versions of glibc. Triggered by .sp or blank lines right before .SS or .SH, or before the first .Sh. Found the hard way by Dr. Markus Waldner on Debian and by Leah Neukirchen on Void Linux.
* add support for the MT and ME mailto macros, used for example in wg(8);Ingo Schwarze2017-06-251-0/+2
| | | | patch from bentley@
* correct handling of blank lines after \cIngo Schwarze2017-06-171-1/+4
|
* properly set the default indentationIngo Schwarze2017-06-171-4/+4
| | | | such that even pages without any .SH macros get it
* improve rounding rules for scaling unitsIngo Schwarze2017-06-141-5/+5
| | | | in horizontal orientation in the terminal formatter
* make the internal a2roffsu() interface more powerful by returningIngo Schwarze2017-06-081-6/+6
| | | | | a pointer to the end of the parsed data, making it easier to parse subsequent bytes
* Prepare the terminal driver for filling multiple columns in parallel,Ingo Schwarze2017-06-071-58/+60
| | | | | | first step: split column data out of the terminal state struct into a new column state struct and use an array of such column state structs. No functional change.
* Implement the roff(7) .mc (right margin character) request.Ingo Schwarze2017-06-041-11/+6
| | | | | | The Tcl/Tk manual pages use this extensively. Delete the TERM_MAXMARGIN hack, it breaks .mc inside .nf; instead, implement a proper TERMP_BRNEVER flag.
* Make term_flushln() simpler and more robust:Ingo Schwarze2017-06-041-1/+0
| | | | | | Eliminate the "overstep" state variable. The information is already contained in "viscol". Minus 60 lines of code, no functional change intended.
* Trailing \c suppresses the output line break even ifIngo Schwarze2017-05-091-2/+3
| | | | | the next line is a text line starting with whitespace. Quirk found in the sysutils/rancid port.
* implement .DT in terms of .ta; needed for print/ghostview, for exampleIngo Schwarze2017-05-071-1/+11
|
* Basic implementation of the roff(7) .ta (define tab stops) request.Ingo Schwarze2017-05-071-1/+3
| | | | | | This is the first feature made possible by the parser reorganization. Improves the formatting of the SYNOPSIS in many Xenocara GL manuals. Also important for ports, as reported by many, including naddy@.
* Move .sp to the roff modules. Enough infrastructure is in placeIngo Schwarze2017-05-051-51/+0
| | | | now that this actually saves code: -70 LOC.
* move .ll to the roff modulesIngo Schwarze2017-05-051-10/+0
|
* Move handling of the roff(7) .ft request from the man(7)Ingo Schwarze2017-05-051-37/+0
| | | | | modules to the new roff(7) modules. As a side effect, mdoc(7) now handles .ft, too. Of course, do not use that.
* Start roff formatter modules for HTML and termininal output,Ingo Schwarze2017-05-041-10/+2
| | | | | | | used by both the mdoc and man formatters, with the ultimate goal of reducing code duplication between the two macro formatters. Made possible by the parser unification. Add the first formatting function (for the .br request).
* Parser reorg:Ingo Schwarze2017-05-041-2/+13
| | | | | Generate the first node on the roff level: .br Fix some column numbers in diagnostic messages while here.