summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc
AgeCommit message (Collapse)Author
2020-04-26While we do not recommend the idiom ".Fl Fl long" for long optionsIngo Schwarze
because it is an abuse of semantic macros for device-specific presentational effects, this idiom is so widespread that it makes sense to convert it to the recommended ".Fl \-long" during the validation phase. For example, this improves HTML formatting in pages where authors have used the dubious .Fl Fl. Feature suggested by Steffen Nurpmeso <steffen at sdaoden dot eu> on freebsd-hackers.
2020-04-24provide a STYLE message when mandoc knows the file name and the extensionIngo Schwarze
disagrees with the section number given in the .Dt or .TH macro; feature suggested and patch tested by jmc@
2020-04-20In fragment identifiers, use ~%d for ordinal suffixes,Ingo Schwarze
and reserve the character '~' for that purpose. Bug found by validator.w3.org in openssl(1), which contains both a tag "tls1_2" and a second instance of a tag "tls1", which also resulted in "tls1_2", causing a clash. Now, the second instance of "tls1" is rendered as "tls1~2" instead, employing the newly reserved '~'.
2020-04-19When .Bd, .D1, or .Dl is tagged, attach the permalinkIngo Schwarze
to the first few letters, similar to what was earlier done for .Pp.
2020-04-19Correctly handle non-unique tags even when NODE_ID and NODE_HREF fallIngo Schwarze
apart, NODE_ID occurring earlier than NODE_HREF.
2020-04-18When a .Tg is attached to a paragraph, attach the permalinkIngo Schwarze
to the first word, or the first few words if they are short.
2020-04-08Use a separate node->tag attribute rather than abusing the node->stringIngo Schwarze
attribute for the purpose. No functional change intended. The purpose is to make it possible to later attach tags to text nodes.
2020-04-07Separate the place to put the <a href> permalink (now markedIngo Schwarze
with NODE_HREF) from the target element of the link (still marked with NODE_ID). In many cases, use this to move the target to the beginning of the paragraph, such that readers don't get dropped into the middle of a sentence.
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-04-04automatically tag .SH and .SS in man(7) terminal outputIngo Schwarze
in the same way as it was done for .Sh and .Ss in mdoc(7)
2020-04-03Remove some stray argument names from function prototypes,Ingo Schwarze
for consistency with the dominant style used in mandoc. No functional change. Patch from Martin Vahlensieck <academicsolutions dot ch>.
2020-04-03#include <stdint.h> because that is needed before #include <ohash.h>;Ingo Schwarze
fixing a build failure of mandoc-portable on Arch Linux reported by Stephen Gregoratto <dev at sgregoratto dot me>.
2020-04-02When the last file formatted yielded no tags, the tags file gotIngo Schwarze
deleted before starting the pager, even when earlier input files had written to it; thanks to weerd@ for reporting that bug. Since we now generate tags for section headers, we almost always generate at least some. Consequently, while fixing the above bug, simplify the code by never deleting the tags file before the pager exits, not even in the rare case that the file happens to be empty. Hence, this patch is -75 +63 LOC even though it fixes two bugs. While deleting the output files belongs after exit from the pager, closing them should be done before it is started. Collect the related code, which was scattered in various places, to where it belongs, in a dedicated function in the term_tag.c module. As a side benefit, never fclose(2) stdout, only dup2(2) to it. Similarly, when the -O tag argument wasn't found in the last file formatted, there was a complaint about "no such tag" even when the argument did occur in earlier files. Fix that by looking for a matching tag after every formatted file rather than just once at the very end. Given that command line arguments aren't properties of the file(s) being formatted, that check is a job for the main program, not for the formatters, so while fixing the check, move it from term_tag.c to main.c.
2020-04-02Copy tagged strings before marking hyphens as breakable.Ingo Schwarze
For example, this makes ":tCo-processes" work in ksh(1).
2020-04-01Just like we are already doing it in HTML output, automatically tagIngo Schwarze
section and subsection headers in terminal output, too. Even though admittedly, commands like "/SEE" and "/ Subsec" work, too, there is no downside, and besides, with the recent improvements in the tagging framework, implementation cost is negligible.
2020-03-28Even though the HTML, man, markdown, PDF, PostScript, and tree formattersIngo Schwarze
never write a ctags(1) file, using a pager still requires writing the main output file and passing the file name to the pager. Recent regression mentioned on IRC and reported by kn@.
2020-03-21When setting automatic tags, skip initial hyphens and minus signs,Ingo Schwarze
bringing the behaviour for mdoc(7) closer to what is already done for man(7). Triggered by the observation of kn@ that automatic tagging didn't work very well for find(1) primaries. OK kn@
2020-03-19The tag file always needs to be closed before starting the pager,Ingo Schwarze
even when no output formatter was allocated because all pages shown were preformatted. Regression in previous reported by <Andreas dot Kahari at abc dot se> on bugs@.
2020-03-13Properly reset the validation part of the tagging module between files.Ingo Schwarze
This fixes a crash in makewhatis(8) encountered by naddy@. I'm very sorry for the disruption of the build.
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-27The HTML standard does not allow self-closing syntax for non-void elements.Ingo Schwarze
Consequently, write an explicit end tag for <mark> elements.
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-02-24Marc Espie reported that "man p*ipc" displayed the perlipc(1) manual.Ingo Schwarze
The reason was that as a last resort when failing to find a page name in mandoc.db(5) or at a few well well-defined fully qualified file names, man(1) uses glob(3) to look for candidate files in relevant directories, because some operating systems have weird file name extensions, for example pcap.3pcap and BF_set_key.3ssl on Linux. But during that globbing, the metacharacters "*?[" need to be escaped in the name, section, and path supplied by the user, or you would get weird false positives and misleading warning messages and would be unable to use the fallback for path or file names that actually contain an opening bracket. Feedback and OK espie@.
2020-02-20bugfix: indented paragraph macros need a space characterIngo Schwarze
before the width argument
2020-02-20bugfix: .Tg must be ignored completely in these output modesIngo Schwarze
2020-02-15mention that -T man does not support eqn(7) and tbl(7);Ingo Schwarze
triggered by a question from Stephen Gregoratto <dev at sgregoratto dot me>
2020-02-13Digit-width and narrow spaces are non-breaking.Ingo Schwarze
Noticed because Branden Robinson worked on related documentation in groff.
2020-02-12In roff, a space character at the beginning of an input line requiresIngo Schwarze
starting a new output line, and merely starting a new line of HTML code isn't sufficient to achieve that. Solve this in the same way as mdoc_html.c already does it, by printing a <br/> element. Fixing a bug reported by Jason A. Donenfeld <Jason at zx2c4 dot com> in the wg-quick(8) manual page on manpages.debian.org.
2020-02-10Finally delete support for the "_whatdb" configuration directive,Ingo Schwarze
which has a misleading syntax. It was declared obsolete and superseded by the "manpath" directive five years ago.
2020-02-10For compatibility with the man(1) implementations of the man-1.6Ingo Schwarze
and man-db packages, print the manpath if the -w option is given without a following name argument. This quirk has been in man-1.6 since at least man-1.5e (1998) and in man-db since 2012. Using this feature in portable software is a dubious idea because the internal organization of manual page directories varies in about a dozen respects among operating systems, so even if you get the answer, there is no portable way to use it for looking up anything inside. However, Matej Cepl <mcepl at suse dot cz> made me aware that some software, for example the manual viewing functionality in the newest editors/neovim code, unwisely relies on this feature anyway. No objections were raised when this patch was shown on tech@.
2020-02-10briefly mention /etc/examples/ in the FILES section of all theIngo Schwarze
manual pages that document the corresponding configuration files; OK jmc@, and general direction discussed with many
2020-02-08correct Research Unix edition "appeared in" use in HISTORYJonathan Gray
Starting from "Combined Table of Contents" in Doug McIlroy's "A Research UNIX Reader" a table of which edition manuals appeared in. Checked against manuals from bitsavers/TUHS and source from TUHS where available. Ingo points out there are cases where something is included but not documented until a later release. bcd(6) v6 v7 printf(3) v2 v4 abort(3) v5 v6 system(3) v6 v7 fmod(3) v5 v6 ok schwarze@
2020-02-06Make sure that -l always causes -w to be ignored, as documentedIngo Schwarze
in the man(1) manual page. This bugfix is needed to prevent the command "man -lw" from dereferencing a NULL pointer.
2020-01-26Repair more of the issues that i found in filescan() while investigatingIngo Schwarze
the report from <Andreas dot Kahari at abc dot se> on ports@: For a symlink, use the first of the following names that is available: 1. In -t mode, the symlink itself (unchanged). 2. When the (unresolved) symlink already resides inside the manpath, just strip the manpath and use the rest (unchanged). 3. When prefix(es) of the unresolved symlink point to the manpath, strip the longest such prefix and use the rest (new); this fixes situations where the manpath or one of its parent directories is a symlink and at the same time contains symlinks to manual pages. 4. Fall back to the fully resolved symlink, with the manpath stripped (new); this may for example happen when the command line passes symlinks from outside the manpath that point to manual pages inside the manpath, or if manual page trees contain symlinks to symlinks and not all of them are given on the command line. The fallback (4) isn't perfect. You can construct symlink spaghetti in such a way that this algorithm will not enter all manual page names into the database that a human would be able to deduce. But i do not expect such spaghetti to actually occur in practice (not even in ports), and a full fix would require re-implementing realpath(3) in terms of step-by-step readlink(2) calls, repeating the complicated algorithm (3) after each step. While here, also stop using PATH_MAX as the size of a static buffer in filescan(); on some systems, it can be unreasonably large. Instead, allocate path strings dynamically.
2020-01-26Fix incorrect file type tests.Ingo Schwarze
This bug caused sockets and character special devices to be accepted as manual pages if they appeared inside manpaths, and it caused incorrect file names to be entered into the database when the manpath or one of its parent directories was a symbolic link. This fixes the issues reported by <Andreas dot Kahari at abc dot se> on ports@, but additional issues remain when symbolic links are contained in a manpath that involves another symbolic link.
2020-01-25Minor cleanup, no functional change:Ingo Schwarze
Do not abuse strstr(3) to check whether one long string starts with another long string. Instead, use strncmp(3) with the proper length. In set_basedir(), also reset *basedir in the error brances for extra safety. While here, invert some more Yoda conditions in the neighbourhood.
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@.
2020-01-19Align to the new, sane behaviour of the groff_mdoc(7) .Dd macro:Ingo Schwarze
without an argument, use the empty string, and always concatenate all arguments, no matter their number. This allows reducing the number of arguments of mandoc_normdate() and some other simplifications, at the same time polishing some error messages by adding the name of the macro in question.
2020-01-11When autogenerating one layout cell from a data cell just beyond theIngo Schwarze
last layout cell that was explicitly specified, properly initialize the spacing attribute to indicate that the default is to be used. Failing to do so and leaving the spacing at zero in this case caused misformatting when another row further down the table had even more explicitly specified cells. Bug found while trying to write regression tests for tbl_term.c rev. 1.61.
2020-01-11Fix a logic error:Ingo Schwarze
When both the first and the third column are spans, do not use the number of columns of the span starting in column two for the span starting in column zero. With afl, Jan Schreiber <jes at posteo dot de> found cases where this caused NULL pointer accesses because too many layout cells were consumed. While here, make the code more similar at the three places that iterate over data cells.
2020-01-11Print more tbl(7) details to help debugging:Ingo Schwarze
column numbers, options, layout rows, cell types, cell modifiers.
2020-01-10autocapitalize=none; also from Tim BaumgardIngo Schwarze
2020-01-10Switch off the useless and annoying "autocomplete" feature;Ingo Schwarze
issue reported by Tim Baumgard <at bmgrd dot com>. landry@ and florian@ agree with the general direction.
2020-01-08Skip whitespace before tokens, too.Ingo Schwarze
Bug found by bentley@ with input like "delim $$ delim off".
2020-01-07Improve the description of -m/-M/MANPATH/man.conf in multiple respectsIngo Schwarze
after kn@ reported that the descriptions were incomplete and somewhat inaccurate. OK jmc@ kn@
2019-12-31When all cells in a tbl(1) column are empty, set the column widthIngo Schwarze
to 1n rather than to 0n, in the same way as groff does. This fixes misformatting reported by bentley@ in xkeyboard-config(7).
2019-12-26Do not fail an assertion when a high level macro occurs in the bodyIngo Schwarze
of a conditional inside a .ce request block. Instead, abort the .ce block just like when there is no conditional in between. Bug found by espie@ working on the textproc/fstrcmp port.
2019-12-10In HTML, display straight quotes, not curly quotes, for Qq/Qo/Qc macros.Anthony J. Bentley
This is the intended behavior and already the case in terminal output. Incorrect output noticed by Eldred Habert. ok schwarze@