summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc (follow)
Commit message (Collapse)AuthorAgeFilesLines
* In HTML output, correctly render .Bd -unfilled in proportionally-spacedschwarze2021-03-302-4/+8
| | | | | | | | | | | font, rather than with the monospace font appropriate for .Bd -literal. This fixes a minibug reported by anton@. Implemented by no longer relying on the typical browser default of "pre { font-family: monospace }" but instead letting <pre> elements inherit the font family from their parent, then adding an explicit CSS .Li class only for those displays where the manual page author requested it by using the -literal option on the .Bd macro.
* Append .html suffix to temporary files enabling browsers to recognise itkn2021-02-193-8/+10
| | | | | | | | | | | | | Occasionally one might read a manual page in a webbrowser, e.g. "MANPAGER=firefox man -T html jq", however temporary files created for pagers lack file extensions and most web browsers are unable to detect a file's content without it. Special case mandoc(1)'s HTML output format by appending the ".html" suffix to file names such that browsers will actually render HTML as such instead of showing it as plain text. Input schwarze
* Finally get rid of the "overflow: auto" property of ".Bl-tag > dd"schwarze2020-10-301-3/+3
| | | | | | | | | | | | | | | | | | | | | | which has long been know to cause ugly and pointless scroll bars. Matthew Martin <phy1729 at gmail dot com> helpfully explained the following two points to me: 1. What we need to do here is establish a new block formatting context such that the first line of the <dd> content moves down rather than to the right if the preceding <dt> is wide. 2. A comprehensive list of methods to establish block formatting context is available in: https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context In that list, i found that "column-count: 1" does the job. It is part of CSS Multi-column Layout Level 1. While that is still in Working Draft status according to https://www.w3.org/Style/CSS/current-work , it is fully supported by all browsers according to https://developer.mozilla.org/en-US/docs/Web/CSS/column-count , probably because it was already part of the second draft of this standard almost 20 years ago: WD-css3-multicol-20010118.
* Promote section headers that can can be used unmodified as fragmentschwarze2020-10-302-4/+4
| | | | | | identifiers from TAG_WEAK to TAG_STRONG, such that for example ...#DESCRIPTION always works. Suggested by Aman Verma on the discuss@ list.
* The GNU tbl(1) program contained in the groff package internallyschwarze2020-10-251-12/+1
| | | | | | | | | | | | | | | | | | uses roff(7) tabulator settings to implement tables, and it used to leak the changed tabulator settings from tables to the subsequent roff(7) code. In mandoc/tbl_term.c rev. 1.42 (June 17, 2017), code was added to be bug-compatible with groff. In commit d0e03cf6 (Oct 20, 2020), GNU tbl(1) changed behaviour to save the tabulator settings before starting a table and restore them afterwards. Adjust mandoc for compatibility. Since mandoc implements tables without using roff(7) tabulator settings, saving and restoring tabulator settings is not needed in mandoc. Simply deleting the code that changed tabulator settings by reverting tbl_term.c rev. 1.42 is sufficient in mandoc. Also adjust the desired output of the regression tests to match the new behaviour of both groff and mandoc.
* Treat \*[.T] in the same way as \*(.T rather than calling abort(3).schwarze2020-10-241-9/+16
| | | | | Bug found because the groff-current manual pages started using the variant form of this predefined string.
* In HTML output, avoid printing a newline right after <pre>schwarze2020-10-163-17/+14
| | | | | | | | and right before </pre> because that resulted in vertical whitespace not requested by the manual page author. Formatting bug reported by Aman Verma <amanraoverma plus vim at gmail dot com> on discuss@.
* add a missing .Ppschwarze2020-10-011-2/+3
|
* add example to apropos.1 to list all manuals in a given sectionians2020-10-011-2/+5
| | | | ok schwarze@
* Element next-line scopes can nest. Consequently, even when closingschwarze2020-09-091-5/+7
| | | | | | | | 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>.
* Do not abuse assert(3) to react to absurd input; the purpose of assert(3)schwarze2020-09-091-3/+17
| | | | | | | | 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.
* After .ti, there are many reasons why the offset may change, so settingschwarze2020-09-062-7/+16
| | | | | | 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>.
* Fix two issues with .po (page offset) formatting:schwarze2020-09-031-5/+13
| | | | | | | | | | | | 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.
* If .ti had an excessive argument, using it was attempted, in someschwarze2020-09-031-12/+22
| | | | | | | | 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>.
* Do not indent by SIZE_MAX/2 when .ce occurs inside explicit no-fill mode.schwarze2020-09-021-12/+9
| | | | | | | | 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>.
* Ignore unreasonably large spacing modifiers in tbl layouts.schwarze2020-09-014-6/+17
| | | | | | 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().
* Remove a lie reported by Jamie Landeg-Jones <jamie at catflap dot org>:schwarze2020-08-271-5/+2
| | | | | 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.
* Fix a regression caused by the insertion of two new tokens,schwarze2020-08-271-10/+18
| | | | | | which unintentionally made the -O tag= argument mandatory, breaking commands like "man -akO tag Ic=ulimit". Noticed while answering questions from Ian Ropers.
* Make it more explicit that the statement "-O tag does not work with less(1)"schwarze2020-08-271-3/+10
| | | | | | 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.
* Avoid artifacts in the most common case of closing conditional blocksschwarze2020-08-271-2/+4
| | | | | | | | 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.
* Put the code handling \} into a new function roff_cond_checkend()schwarze2020-08-031-59/+64
| | | | | | | | | | | | | | | | | | | | 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.
* undocumented options -O outfilename and -O tagfilenameschwarze2020-07-215-39/+97
| | | | | to support regression testing without a tty; no user visible change intended
* as jmc@ points out, i missed a few instances of .Xr more 1schwarze2020-07-203-10/+7
|
* Switch the default pager from "more -s" to "less".schwarze2020-07-204-14/+14
| | | | | | | | | | | | | | | | | | | 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@
* Support the "powerpc64" architecture name.schwarze2020-06-292-7/+8
| | | | The first file using it in .Dt was just committed by kettenis@.
* Manually tag the section option.schwarze2020-06-171-2/+3
| | | | | Automatic tagging does not work because the [-s] flag is optional. Patch from Martin Vahlensieck.
* document -T html -O tag as implemented in main.c rev. 1.253schwarze2020-06-151-2/+19
|
* Support -T html -O tag by passing a file:// URI to the pager.schwarze2020-06-151-17/+24
| | | | | Feature suggested by and implementation based on a patch from Abel Romero Perez <romeroperezabel at gmail dot com>.
* Fix a regression in rev. 1.238 (2019/07/26):otto2020-06-111-2/+2
| | | | | | | | 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@
* While we do not recommend the idiom ".Fl Fl long" for long optionsschwarze2020-04-261-2/+26
| | | | | | | | | | | 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.
* provide a STYLE message when mandoc knows the file name and the extensionschwarze2020-04-247-16/+52
| | | | | disagrees with the section number given in the .Dt or .TH macro; feature suggested and patch tested by jmc@
* In fragment identifiers, use ~%d for ordinal suffixes,schwarze2020-04-201-3/+4
| | | | | | | | | 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 '~'.
* When .Bd, .D1, or .Dl is tagged, attach the permalinkschwarze2020-04-191-24/+41
| | | | to the first few letters, similar to what was earlier done for .Pp.
* Correctly handle non-unique tags even when NODE_ID and NODE_HREF fallschwarze2020-04-192-38/+49
| | | | apart, NODE_ID occurring earlier than NODE_HREF.
* When a .Tg is attached to a paragraph, attach the permalinkschwarze2020-04-189-24/+72
| | | | to the first word, or the first few words if they are short.
* Use a separate node->tag attribute rather than abusing the node->stringschwarze2020-04-087-71/+68
| | | | | attribute for the purpose. No functional change intended. The purpose is to make it possible to later attach tags to text nodes.
* Separate the place to put the <a href> permalink (now markedschwarze2020-04-075-12/+115
| | | | | | | 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.
* Support manual tagging of .Pp, .Bd, .D1, .Dl, .Bl, and .It.schwarze2020-04-067-44/+113
| | | | | | 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.
* automatically tag .SH and .SS in man(7) terminal outputschwarze2020-04-042-4/+26
| | | | in the same way as it was done for .Sh and .Ss in mdoc(7)
* Remove some stray argument names from function prototypes,schwarze2020-04-037-23/+37
| | | | | | for consistency with the dominant style used in mandoc. No functional change. Patch from Martin Vahlensieck <academicsolutions dot ch>.
* #include <stdint.h> because that is needed before #include <ohash.h>;schwarze2020-04-031-1/+2
| | | | | fixing a build failure of mandoc-portable on Arch Linux reported by Stephen Gregoratto <dev at sgregoratto dot me>.
* When the last file formatted yielded no tags, the tags file gotschwarze2020-04-026-85/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Copy tagged strings before marking hyphens as breakable.schwarze2020-04-021-4/+8
| | | | For example, this makes ":tCo-processes" work in ksh(1).
* Just like we are already doing it in HTML output, automatically tagschwarze2020-04-012-27/+39
| | | | | | | 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.
* Even though the HTML, man, markdown, PDF, PostScript, and tree formattersschwarze2020-03-281-13/+10
| | | | | | 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@.
* When setting automatic tags, skip initial hyphens and minus signs,schwarze2020-03-211-3/+19
| | | | | | | | 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@
* The tag file always needs to be closed before starting the pager,schwarze2020-03-191-2/+3
| | | | | | 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@.
* Properly reset the validation part of the tagging module between files.schwarze2020-03-132-2/+7
| | | | | This fixes a crash in makewhatis(8) encountered by naddy@. I'm very sorry for the disruption of the build.
* Split tagging into a validation part including prioritizationschwarze2020-03-1316-788/+823
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* The HTML standard does not allow self-closing syntax for non-void elements.schwarze2020-02-272-5/+5
| | | | Consequently, write an explicit end tag for <mark> elements.