aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_term.c
Commit message (Collapse)AuthorAgeFilesLines
* Support manual tagging of .Pp, .Bd, .D1, .Dl, .Bl, and .It.Ingo Schwarze2020-04-061-7/+16
| | | | | | In HTML output, improve the logic for writing inside permalinks: skip them when there is no child content or when there is a risk that the children might contain flow content.
* Split tagging into a validation part including prioritizationIngo Schwarze2020-03-131-202/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fully support explicit tagging of .Sh and .Ss.Ingo Schwarze2020-02-271-10/+6
| | | | | | | | | | | | | | | | | | | | | | | | | This fixes the offset of two lines in terminal output and this improves HTML output by putting the id= attribute and <a> element into the respective <h1> or <h2> element rather than writing an additional <mark> element. To that end, introduce node flags NODE_ID (to make the node a link target, for example by writing an HTML id= attribute or by calling tag_put()) and NODE_HREF (to make the node a link source, used only in HTML output, used only to write an <a class="permalink"> element). In particular: * In the validator, generalize the concept of the "next node" such that it also works before .Sh and .Ss. * If the first argument of .Tg is empty, don't forget to complain if there are additional arguments, which will be ignored. * In the terminal formatter, support writing of explicit tags for all kinds of nodes, not just for .Tg. * In deroff(), allow nodes to have an explicit string representation even when they aren't text nodes. Use this for explicitly tagged section headers. Suprisingly, this is sufficient to make HTML output work, without explicit code changes in the HTML formatter. * In syntax tree output, display NODE_ID and NODE_HREF.
* Introduce the concept of nodes that are semantically transparent:Ingo Schwarze2020-02-271-79/+61
| | | | | | | | | | | | | | 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-10/+10
| | | | | | 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.
* Introduce a new mdoc(7) macro .Tg ("tag") to explicitly mark a placeIngo Schwarze2020-01-191-2/+11
| | | | | | | | | | | | | | | as defining a term. Please only use it when automatic tagging does not work. Manual page authors will not be required to add the new macro; using it remains optional. HTML output is still rudimentary in this version and will be polished later. Thanks to kn@ for reminding me that i have been considering since BSDCan 2014 whether something like this might be useful. Given that possibilities of making automatic tagging better are running out and there are still several situations where automatic tagging cannot do the job, i think the time is now ripe. Feedback and no objection from millert@; OK espie@ inoguchi@ kn@.
* Improve "man -h" output.Ingo Schwarze2019-06-271-10/+14
| | | | | | 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@.
* Initialize the local variable "act" in print_mdoc_node().Ingo Schwarze2019-06-031-1/+2
| | | | | | | | | While there is no bug, it helps clarity, and it is also safer in this particular code because in case a bug gets introduced later, accessing a NULL pointer is less dangerous than accessing an uninitialized pointer. Michal Nowak <mnowak at startmail dot com> reported that gcc 4.4.4 and 7.4.0 on illumos throw -Wuninitialized false positives.
* Two functional improvements to filling in terminal output.Ingo Schwarze2019-01-041-64/+44
| | | | | | | | | | | 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.
* Cleanup, no functional change:Ingo Schwarze2018-12-301-7/+5
| | | | | | | | | | | | | | 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-2/+1
| | | | | | | | | | 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-4/+10
| | | | | | 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.
* Remove more pointer arithmetic passing via regions outside the arrayIngo Schwarze2018-08-171-10/+10
| | | | | 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.
* preserve comments before .Dd when converting mdoc(7) to man(7)Ingo Schwarze2018-04-111-6/+11
| | | | with mandoc -Tman; suggested by Thomas Klausner <wiz at NetBSD>
* use the portable \(lq and \(rq internally rather than \(Lq and \(RqIngo Schwarze2018-04-051-3/+3
|
* Remove the implicit display feature of .Lk because it was inconsistentIngo Schwarze2018-01-131-9/+1
| | | | | | | | | across output devices, counter-intuitive, and resulted in ugly output for many real-world manual pages. Always format even long links in-line. I already committed a similar change to groff. OK jmc@, bentley@, and the original author of the feature, Werner Lemberg <wl@gnu.org>.
* improve rounding rules for scaling unitsIngo Schwarze2017-06-141-4/+4
| | | | in horizontal orientation in the terminal formatter
* make the internal a2roffsu() interface more powerful by returningIngo Schwarze2017-06-081-2/+4
| | | | | 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-74/+76
| | | | | | 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-23/+9
| | | | | | 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-41/+12
| | | | | | Eliminate the "overstep" state variable. The information is already contained in "viscol". Minus 60 lines of code, no functional change intended.
* Minimal implementation of the \h (horizontal motion) escape sequence.Ingo Schwarze2017-06-011-2/+3
| | | | Good enough to cope with the average DocBook insanity.
* fix formatting of intermediate punctuation in .LkIngo Schwarze2017-05-301-7/+15
|
* 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.
* Basic implementation of the roff(7) .ta (define tab stops) request.Ingo Schwarze2017-05-071-11/+29
| | | | | | 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-37/+9
| | | | now that this actually saves code: -70 LOC.
* move .ll to the roff modulesIngo Schwarze2017-05-051-20/+5
|
* Move handling of the roff(7) .ft request from the man(7)Ingo Schwarze2017-05-051-1/+2
| | | | | 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-8/+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-5/+17
| | | | | Generate the first node on the roff level: .br Fix some column numbers in diagnostic messages while here.
* Continue parser unification:Ingo Schwarze2017-04-241-5/+7
| | | | | | | | * Make enum rofft an internal interface as enum roff_tok in "roff.h". * Represent mdoc and man macros in enum roff_tok. * Make TOKEN_NONE a proper enum value and use it throughout. * Put the prologue macros first in the macro tables. * Unify mdoc_macroname[] and man_macroname[] into roff_name[].
* Fix handling of trailing punctuation in .Lk.Ingo Schwarze2017-04-171-6/+12
| | | | | | | | | This macro is unusual in so far as trailing punction needs to remain inside the scope because it must be inside, not after the display of long URIs in terminal output mode. Improves formatting of fw_update(1), help(1), less(1), sendbug(1), acx(4), inet6(4), ipsec(4), oce(4), isakmpd.conf(5), afterboot(8), release(8), traceroute(8).
* Show long .Lk URIs in like an indented display, similar to groff.Ingo Schwarze2017-04-141-1/+11
| | | | Suggested by bentley@.
* Do not make the colon after the .Lk link text italic.Ingo Schwarze2017-04-141-2/+2
| | | | I just pushed the same change to GNU troff.
* Use typographic quotes rather than '"' for .Rs %T (no change for -TasciiIngo Schwarze2017-02-171-3/+5
| | | | | output, of course). Patch from bentley@ in November 2014. This can be committed now because groff merged Anthony's patch yesterday.
* Surprisingly, groff does not support scaling units in .Bl -columnIngo Schwarze2017-02-161-5/+11
| | | | | | column width specifiers, so stop supporting them, too. As a side effect, this fixes an assertion failure that tb@ found with afl(1), triggered by: .Bl -column -4n
* Remove the ENDBODY_NOSPACE flag, simplifying the code.Ingo Schwarze2017-02-161-9/+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-4/+2
| | | | | | | | | | 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.
* Do not fix the default indent for all subsequent files; some may useIngo Schwarze2017-02-041-1/+4
| | | | | a different macro language and hence require a different indent. You can see the effect with "man -a 1 host hostname".
* Do text production for .Bt, .Ex, .Rv, .Ud at the validation stageIngo Schwarze2017-01-111-107/+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-26/+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-42/+18
| | | | | 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-24/+24
|
* Introduce flags NODE_NOSRC and NODE_NOPRT for AST nodes.Ingo Schwarze2017-01-101-2/+13
| | | | | | | | | 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.
* use .Fn in custom sections for tagging, in addition to in DESCRIPTION;Ingo Schwarze2016-11-081-2/+2
| | | | written on the TGV Paris-Strassbourg
* tag leading .Dv, .Li, and .No in .It;Ingo Schwarze2016-11-081-1/+2
| | | | written on the TGV Paris-Strassbourg
* implement tag priority 0, which will tag only keys that appear asIngo Schwarze2016-11-081-3/+25
| | | | | tag candidates exactly once, and use it for .Em and .Sy; written on the TGV Toulouse-Paris
* generate two tag entries from list entries of the formIngo Schwarze2016-11-081-2/+4
| | | | | .It Macro tag1 ... | Macro tag2 ... written on the TGV Toulouse-Paris
* Delete complicated code dealing with .Bl -tag without -width,Ingo Schwarze2016-10-091-2/+2
| | | | | | | | | | | | and just let it default to -width 6n, which agrees with the traditional -width Ds that is still in widespread use. I just pushed a patch upstream to GNU roff that does the same for groff_mdoc(7). Before, groff contained code that was even more complicated than mandoc, but both resulted in quite different user-visible output. Now, both agree, and output is nicer for both. Useless complication noticed by Carsten Kunze (Heirloom roff).
* 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.