summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/mdoc_term.c
AgeCommit message (Collapse)Author
2023-11-13Reduce the man(7) default global indentation from 7n, which was an oddityIngo Schwarze
in groff-1.01 to groff-1.22.4, to 5n for compatibility with Version 7 AT&T UNIX, 4.3BSD-Reno, groff-1.23.0, and all versions of mdoc(7). OK jmc@ millert@
2022-09-11Finally expand and delete the macro SCALE_VS_INIT().Ingo Schwarze
It's nothing but obfuscation and only used at three places in a single file. Removing it also makes the code three lines shorter. The ugliness was already pointed out six years ago by mmcc@.
2022-08-16When starting a new input line, even when continuing the same outputIngo Schwarze
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.
2020-04-06Support manual tagging of .Pp, .Bd, .D1, .Dl, .Bl, and .It.Ingo Schwarze
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.
2020-03-13Split tagging into a validation part including prioritizationIngo Schwarze
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.
2020-02-27Fully support explicit tagging of .Sh and .Ss.Ingo Schwarze
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.
2020-02-27Introduce the concept of nodes that are semantically transparent:Ingo Schwarze
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@.
2020-01-20Make the code more readable by introducingIngo Schwarze
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.
2020-01-19Introduce a new mdoc(7) macro .Tg ("tag") to explicitly mark a placeIngo Schwarze
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@.
2019-06-27Improve "man -h" output.Ingo Schwarze
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@.
2019-06-03Initialize the local variable "act" in print_mdoc_node().Ingo Schwarze
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.
2019-01-04Two functional improvements to filling in terminal output.Ingo Schwarze
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.
2018-12-30Cleanup, no functional change:Ingo Schwarze
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.
2018-12-13Cleanup, no functional change:Ingo Schwarze
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.
2018-12-03In the validators, translate obsolete macro aliases (Lp, Ot, LP, P)Ingo Schwarze
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.
2018-08-17Remove more pointer arithmetic passing via regions outside the arrayIngo Schwarze
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.
2018-04-11preserve comments before .Dd when converting mdoc(7) to man(7)Ingo Schwarze
with mandoc -Tman; suggested by Thomas Klausner <wiz at NetBSD>
2018-04-05use the portable \(lq and \(rq internally rather than \(Lq and \(RqIngo Schwarze
2018-01-13Remove the implicit display feature of .Lk because it was inconsistentIngo Schwarze
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>.
2017-06-14improve rounding rules for scaling unitsIngo Schwarze
in horizontal orientation in the terminal formatter
2017-06-08make the internal a2roffsu() interface more powerful by returningIngo Schwarze
a pointer to the end of the parsed data, making it easier to parse subsequent bytes
2017-06-07Prepare the terminal driver for filling multiple columns in parallel,Ingo Schwarze
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.
2017-06-04Implement the roff(7) .mc (right margin character) request.Ingo Schwarze
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.
2017-06-04Make term_flushln() simpler and more robust:Ingo Schwarze
Eliminate the "overstep" state variable. The information is already contained in "viscol". Minus 60 lines of code, no functional change intended.
2017-06-01Minimal implementation of the \h (horizontal motion) escape sequence.Ingo Schwarze
Good enough to cope with the average DocBook insanity.
2017-05-30fix formatting of intermediate punctuation in .LkIngo Schwarze
2017-05-09Trailing \c suppresses the output line break even ifIngo Schwarze
the next line is a text line starting with whitespace. Quirk found in the sysutils/rancid port.
2017-05-07Basic implementation of the roff(7) .ta (define tab stops) request.Ingo Schwarze
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@.
2017-05-05Move .sp to the roff modules. Enough infrastructure is in placeIngo Schwarze
now that this actually saves code: -70 LOC.
2017-05-05move .ll to the roff modulesIngo Schwarze
2017-05-05Move handling of the roff(7) .ft request from the man(7)Ingo Schwarze
modules to the new roff(7) modules. As a side effect, mdoc(7) now handles .ft, too. Of course, do not use that.
2017-05-04Start roff formatter modules for HTML and termininal output,Ingo Schwarze
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).
2017-05-04Parser reorg:Ingo Schwarze
Generate the first node on the roff level: .br Fix some column numbers in diagnostic messages while here.
2017-04-24Continue parser unification:Ingo Schwarze
* 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[].
2017-04-17Fix handling of trailing punctuation in .Lk.Ingo Schwarze
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).
2017-04-14Show long .Lk URIs in like an indented display, similar to groff.Ingo Schwarze
Suggested by bentley@.
2017-04-14Do not make the colon after the .Lk link text italic.Ingo Schwarze
I just pushed the same change to GNU troff.
2017-02-17Use typographic quotes rather than '"' for .Rs %T (no change for -TasciiIngo Schwarze
output, of course). Patch from bentley@ in November 2014. This can be committed now because groff merged Anthony's patch yesterday. Simply committing myself because asking Anthony to go search for his two-year-old patch and have him discover that it had accumulated an average of (felt) two or three conflicts per line by now would have been mean, even if hilarious.
2017-02-16Surprisingly, groff does not support scaling units in .Bl -columnIngo Schwarze
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
2017-02-16Remove the ENDBODY_NOSPACE flag, simplifying the code.Ingo Schwarze
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.
2017-02-06The .Nm macro does not only use the default name when it has noIngo Schwarze
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.
2017-02-04Do not fix the default indent for all subsequent files; some may useIngo Schwarze
a different macro language and hence require a different indent. You can see the effect with "man -a 1 host hostname".
2017-01-11Do text production for .Bt, .Ex, .Rv, .Ud at the validation stageIngo Schwarze
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@.
2017-01-10Use new NODE_NOSRC and NODE_NOPRT flags for .Bx and .At.Ingo Schwarze
More rigorous AST and 40 lines less code.
2017-01-10For the .Ux/.Ox family of macros, do text production at the validationIngo Schwarze
stage rather than in each and every individual formatter, using the new NODE_NOSRC flag. More rigorous and also ten lines less code.
2017-01-10unify names of AST node flags; no change of cpp outputIngo Schwarze
2017-01-10Introduce flags NODE_NOSRC and NODE_NOPRT for AST nodes.Ingo Schwarze
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.
2016-11-08use .Fn in custom sections for tagging, in addition to in DESCRIPTION;Ingo Schwarze
written on the TGV Paris-Strassbourg
2016-11-08tag leading .Dv, .Li, and .No in .It;Ingo Schwarze
written on the TGV Paris-Strassbourg
2016-11-08implement tag priority 0, which will tag only keys that appear asIngo Schwarze
tag candidates exactly once, and use it for .Em and .Sy; written on the TGV Toulouse-Paris