summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc
AgeCommit message (Collapse)Author
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@
2019-11-10Add a Content-Security-Policy HTTP header that allows only CSS.Anthony J. Bentley
This ensures that in a modern browser that understands the header, mandoc rendering bugs cannot possibly be interpreted as JavaScript. ok schwarze@
2019-11-09In the past, generating comment nodes stopped at the .TH or .DdIngo Schwarze
macro, which is usually close to the beginning of the file, right after the Copyright header comments. But espie@ found horrible input files in the textproc/fstrcmp port that generate lots of parse nodes before even getting to the header macro. In some formatters, comment nodes after some kinds of real content triggered assertions. So make sure generation of comment nodes stops once real content is encountered.
2019-10-01For invalid queries and for valid queries returning no result,Ingo Schwarze
return the appropriate 40x status code rather than 200. Improvement suggested and diff tested by John Gardner <gardnerjohng at gmail dot com>.
2019-09-15Fix line breaking in no-fill mode (.Bd -unfilled/<pre>),Ingo Schwarze
which apparently didn't work since the .Pp/<p> reorg. The new logic is more similar to what the terminal formatter does: 1. Before a node that starts a new mdoc(7) input line, start a new HTML output line. 2. An empty input line or a .Pp causes an empty output line. 3. Nothing needs to be done at the end of a node. Severe misformatting was reported in table(5) by Edgar Pettijohn <edgar at pettijohn dash web dot com> on misc@.
2019-09-13Improve validation of function names:Ingo Schwarze
1. Relax checking to accept function types of the form "ret_type (fname)(args)" (suggested by Yuri Pankov <yuripv dot net>). 2. Tighten checking to require the closing parenthesis.
2019-09-05Do not clear HTML_NOSPACE in print_indent().Ingo Schwarze
I don't think there ever was a reason for doing so. Besides, there is a discrepacy with respect to the point in the document affected. That flag controls whitespace at the current formatting point. But when HTML_BUFFER is in effect, the line break and indentation is typically inserted one word further to the left. Anything happening at that point to the left can't reasonably influence spacing at the different point further to the right. Among other effects, this change avoids some spurious line breaks in HTML code at points where they weren't supposed to happen, line breaks that in some cases caused undesirable, visible whitespace when the resulting HTML was rendered.
2019-09-03Wrap text and phrasing elements in paragraphs unless alreadyIngo Schwarze
contained in flow containers; never put them directly into sections. This helps to format paragraphs with the CSS class selector .Pp. Suggested by bentley@ and also by Colin Watson <cjwatson at debian> via Michael Stapelberg <stapelberg at debian>, see https://github.com/Debian/debiman/issues/116
2019-09-03Format .Nd with more logically with <span> rather than <div>; after all,Ingo Schwarze
it is supposed to be a one-line description. For the case where .Nd generates flow content (which is very bad style but syntactically valid), rely on the new feature of html_close_paragraph() to close out the <span> prematurely, effectively moving the flow content out of the .Nd for HTML presentation. For the final closing, also rely on the new html_close_paragraph() functionality, this time triggered by the subsequent block, which will typically be .Sh SYNOPSIS.
2019-09-03oops, fix use after free in previousIngo Schwarze
2019-09-03Make html_close_paragraph() more versatile, more robust, lessIngo Schwarze
dependent on individual HTML elements, and simpler: don't just close <p>, <pre>, and <a>, but any element that establishes phrasing context. This doesn't change output for any OpenBSD manual page, but it will allow using this function more safely and at more places in the future.
2019-09-01delete the TAG_IDIV crutch, which is no longer usedIngo Schwarze
2019-08-29In the HTML formatter, assert(3) that no HTML nesting violation occurs.Ingo Schwarze
Tested on the complete manual page trees of Version 7 AT&T UNIX, 4.4BSD-Lite2, POSIX-2013, OpenBSD 2.2 to 6.5 and -current, FreeBSD 10.0 to 12.0, NetBSD 6.1.5 to 8.1, DragonFly 3.8.2 to 5.6.1, and Linux 4.05 to 5.02.
2019-08-02minor sync of the inline stylesheet with mandoc.css:Ingo Schwarze
delete unimportant .Pp rule and shorten overly specific selectors
2019-07-28Simplification, no functional change:Ingo Schwarze
Delete the "argc" argument from fs_search() which is now always 1, and move error reporting to the main() program where it is more logically placed and easier to see.
2019-07-28There is no point in pledge(2)ing literally the same list twice,Ingo Schwarze
so delete the second copy. No functional change.
2019-07-28In man(1) mode, do the search for each name independently, andIngo Schwarze
show the results in the order of the command line arguments. Implemented by separating the code for man(1) and apropos(1) in the main() program. Surprisingly, the number of lines of code remains unchanged. Issue reported by deraadt@, additional input from millert@.
2019-07-28Improve structure, no functional change:Ingo Schwarze
Unify code to process one single input file and move it into a dedicated new function.
2019-07-27Move two more output state variables into the new struct outstate.Ingo Schwarze
Also, move setting of tag_files.tagname into tag_init(). No functional change.
2019-07-26Cleanup, no functional change:Ingo Schwarze
For clarity, stop storing the same information (in this case, -O settings) in two structs. Give the local struct in main.c a more descriptive name (output state).
2019-07-26Structural cleanup, no functional change:Ingo Schwarze
Mixing parser and formatter state in the same struct was a bad idea, so pull the parser state and configuration out of it. This makes sure output options are not passed into parser functions and parser options are not passed into output functions. While here, add comments to the important local variables in main().
2019-07-26Structural cleanup, no functional change:Ingo Schwarze
Move process group management out of main() into its own function because it has its own, self-contained logic and its own local variables.
2019-07-23tagging support for .TP and .TQ; try e.g. man -O tag=commit cvsIngo Schwarze
2019-07-22Slowly start implementing tagging support for man(7) pages, evenIngo Schwarze
though it is obvious that this can never become as good as for mdoc(7) pages. As a first step, tag alphabetic arguments of .IP macros, which are often used for lists of options and keywords. Try "man -O tag=g as" to get the point. Thanks to Leah Neukirchen for recently reminding me that exploring how much can be done in this respect may be worthwhile: it is likely to slightly improve usability while adding only small amounts of relatively straightforward code.
2019-07-19#define a handful of constant strings to reduce the diff to -portable;Ingo Schwarze
now, the diff is about -30 +150 lines (about 0.4%)