summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc
AgeCommit message (Collapse)Author
2020-10-01add a missing .PpIngo Schwarze
2020-10-01add example to apropos.1 to list all manuals in a given sectionians
ok schwarze@
2020-09-09Element next-line scopes can nest. Consequently, even when closingIngo Schwarze
one element next-line scope, the MAN_ELINE flag must not yet be cleared if the parent macro is another element macro having next-line scope, or an assertion failure is caused if all this is wrapped in another macro that has block next-line scope, for example .TP. Bug found in an afl run performed by Jan Schreiber <jes at posteo dot de>.
2020-09-09Do not abuse assert(3) to react to absurd input; the purpose of assert(3)Ingo Schwarze
only is to catch internal inconsistencies in the program itself. Issue found in an afl run performed by Jan Schreiber <jes at posteo dot de>. Instead, just cut down unreasonably wide spacing requested by the document to a narrower width.
2020-09-06After .ti, there are many reasons why the offset may change, so settingIngo Schwarze
it back later requires a guard against underflow, or subsequent assertions may fail. Issue found in an afl run performed by Jan Schreiber <jes at posteo dot de>.
2020-09-03Fix two issues with .po (page offset) formatting:Ingo Schwarze
1. Truncate excessive offsets to a width reasonable in the context of manual pages instead of printing excessively long lines and sometimes causing assertion failures; found in an afl run performed by Jan Schreiber <jes at posteo dot de>. 2. Remember both the requested and the applied page offset; otherwise, subtracting an excessive width, then adding it again, would end up with an incorrectly large offset. While here, simplify the code by reverting the previous offset up front, and also add some comments to make the general ideas easier to understand.
2020-09-03If .ti had an excessive argument, using it was attempted, in someIngo Schwarze
cases resulting in an assertion failure. Instead, truncate the temporary indent to a width reasonable in a manual page. I found the issue in an afl run that was performed by Jan Schreiber <jes at posteo dot de>.
2020-09-02Do not indent by SIZE_MAX/2 when .ce occurs inside explicit no-fill mode.Ingo Schwarze
While here, drop two unused arguments from the function term_field(); the related work was already done by term_fill() before this commit. I found the bug in an afl run that was performed by Jan Schreiber <jes at posteo dot de>.
2020-09-01Ignore unreasonably large spacing modifiers in tbl layouts.Ingo Schwarze
Jan Schreiber <jes at posteo dot de> ran afl on mandoc and it turned out mandoc tried to use spacing modifiers so large that they would trigger assertion failures in term_ascii.c, function locale_advance().
2020-08-27Remove a lie reported by Jamie Landeg-Jones <jamie at catflap dot org>:Ingo Schwarze
The times when -T man may have expanded .so requests are long gone, nor would such a feature be useful. Use soelim(1) if you need that.
2020-08-27Fix a regression caused by the insertion of two new tokens,Ingo Schwarze
which unintentionally made the -O tag= argument mandatory, breaking commands like "man -akO tag Ic=ulimit". Noticed while answering questions from Ian Ropers.
2020-08-27Make it more explicit that the statement "-O tag does not work with less(1)"Ingo Schwarze
only applies to -T html output mode, and why. Of course, -O tag works just fine with less(1) in the -T ascii and -T utf8 output modes. Potential for confusion pointed out by Ian Ropers.
2020-08-27Avoid artifacts in the most common case of closing conditional blocksIngo Schwarze
when no arguments follow the closing brace, \}. For example, the line "'br\}" contained in the pod2man(1) preamble would throw a bogus "escaped character not allowed in a name" error. This issue was originally reported by Chris Bennett on ports@, and afresh1@ noticed it came from the pod2man(1) preamble.
2020-08-03Put the code handling \} into a new function roff_cond_checkend()Ingo Schwarze
and call that function not only from both places where copies existed - when processing text lines and when processing request/macro lines in conditional block scope - but also when closing a macro definition request, such that this construction works: .if n \{.de macroname macro content .. \} ignored arguments .macroname This fixes a bug reported by John Gardner <gardnerjohng at gmail dot com>. While here, avoid a confusing decrement of the line scope counter in roffnode_cleanscope() for conditional blocks that do not have line scope in the first place (no functional change for this part). Also improve validation of an internal invariant in roff_cblock() and polish some comments.
2020-07-21undocumented options -O outfilename and -O tagfilenameIngo Schwarze
to support regression testing without a tty; no user visible change intended
2020-07-20as jmc@ points out, i missed a few instances of .Xr more 1Ingo Schwarze
2020-07-20Switch the default pager from "more -s" to "less".Ingo Schwarze
POSIX explicitly allows using a different default pager if that is documented. The pager provided in the OpenBSD base system is less(1). It can merely be called as more(1) for compatibility. Our man(1) implementation uses less(1) features that traditional more(1) did not provide, in particular tagging. Besides, as noted by deraadt@, the user interface of less(1) is slightly more refined and preferable over the user inferface of more(1). This switch was originally suggested by Ian Ropers. As explained by jmc@ and deraadt@, the -s flag was added a very long time ago when an antique version of groff(1) had an annoying bug in terminal output that would randomly display blank lines in the middle of pages. Clearly, -s has no longer been needed for many years, so drop it from the default pager invocation. OK deraadt@ jmc@ martijn@ job@
2020-06-29Support the "powerpc64" architecture name.Ingo Schwarze
The first file using it in .Dt was just committed by kettenis@.
2020-06-17Manually tag the section option.Ingo Schwarze
Automatic tagging does not work because the [-s] flag is optional. Patch from Martin Vahlensieck.
2020-06-15document -T html -O tag as implemented in main.c rev. 1.253Ingo Schwarze
2020-06-15Support -T html -O tag by passing a file:// URI to the pager.Ingo Schwarze
Feature suggested by and implementation based on a patch from Abel Romero Perez <romeroperezabel at gmail dot com>.
2020-06-11Fix a regression in rev. 1.238 (2019/07/26):Otto Moerbeek
Pass the right object to html_reset() or it will crash when rendering more than one manual page to HTML in a row. Bug reported by Abel Romero Perez <romeroperezabel at gmail dot com>. Ingo came up with the same diff and I'm borrowing his draft commit message. ok schwarze@
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.