summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/mdoc_html.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Let .Aq/.Ao/.Ac print "<>" instead of the normal "\(la\(ra"schwarze2015-01-231-6/+6
| | | | | | when the only child is .Mt, not when the preceding node is .An, to improve robustness. Triggered by a question from Svyatoslav Mishyn <juef at openmailbox dot org> (Crux Linux).
* support negative horizontal widths in man(7);schwarze2014-12-231-3/+7
| | | | minus twenty lines of code in spite of enhanced functionality
* some scaling unit fixes:schwarze2014-12-231-3/+3
| | | | | - .sp with an invalid argument is .sp 1v, not .sp 0v - in man(1), trailing garbage doesn't make scaling units invalid
* Fix the implementation and documentation of \c (continue text input line).schwarze2014-12-021-2/+3
| | | | | In particular, make it work in no-fill mode, too. Reminded by Carsten dot Kunze at arcor dot de (Heirloom roff).
* header cleanup:schwarze2014-12-011-3/+2
| | | | | | * add missing forward declarations * remove needless header inclusions * some style unification
* Multiple fixes with respect to .Pf:schwarze2014-11-301-2/+3
| | | | | | | * The first argument of .Pf is not parsed. * Normal delimiter handling does not apply to the first argument of .Pf. * Warn if nothing follows a prefix (inspired by groff_mdoc(7)). * In that case, do not suppress spacing.
* Multiple fixes with respect to .Eo:schwarze2014-11-271-9/+14
| | | | | | | | 1. Correctly parse stray .Ec without preceding .Eo, avoiding an assertion violation found by jsg@ with afl. 2. Correctly parse .Ec arguments when breaking another block. 3. Correct spacing around closing delimiter when breaking another block. 4. Sync some related formatting control from -Tascii to -Thtml.
* Fix the obsolete .Db (toggle debug mode) macro to ignore its argumentsschwarze2014-11-271-2/+2
| | | | | and not trigger an assertion when there is more than one argument; the latter found by jsg@ with afl.
* Let .Ao and .Aq render as "<>" after .An and as "\(la\(ra" elsewhere,schwarze2014-11-191-3/+5
| | | | just like groff; minibug noticed by bentley@.
* Multiple fixes with respect to in-line macros:schwarze2014-11-171-2/+13
| | | | | | | | | | * .No selects the default font; relevant e.g. in .Bf blocks * no need to force empty .Li elements * closing delimiters as leading macro arguments do not suppress space * opening delimiters at the end of a macro line do not suppress space * correctly handle delimiter spacing in -Tman As a side effect, these fixes let mandoc warn about empty .No macros as requested by bentley@.
* Major bugsquashing with respect to -offset and -width:schwarze2014-10-301-28/+14
| | | | | | | | | 1. Support specifying the .Bd and .Bl -offset as a macro default width; while here, simplify the code handling the same for .Bl -width. 2. Correct handling of .Bl -offset arguments: unlike .Bd -offset, the arguments "left", "indent", and "indent-two" have no special meaning. 3. Fix the scaling of string length -offset and -width arguments in -Thtml. Triggered by an incomplete documentation patch from bentley@.
* Switch HTML output to polyglot HTML5; have only one single -Thml mode.schwarze2014-10-071-37/+23
| | | | | | | | Replace hard-coded widths and alignments with a minimal embedded stylesheet. Do not use <p> because it cannot appear inside block macros. Remove the "summary" attribute because it is not HTML5. Written by kristaps@ some months ago, finished during EuroBSDCon.
* implement .An -[no]split for -Thtmlschwarze2014-09-171-4/+28
|
* Right after .Fl, a middle delimiter triggers an empty scope,schwarze2014-08-211-4/+5
| | | | | | | | | | | | just like a closing delimiter. This didn't work in groff-1.15, but it now works in groff-1.22. After being closed by delimiters, .Nm scopes do not reopen. Do not suppress white space after .Fl if the next node is a text node on the same input line; that can happen for middle delimiters. Fixing an issue reported by jmc@.
* Revert previous, as requested by kristaps@.schwarze2014-08-141-5/+7
| | | | | | | | | | | | | The .Bf block can contain subblocks, so it has to render as an element that can contain flow content. But <em> cannot contain flow content, only phrasing content. Rendering .Em and .Bf differently would by unfortunate, and closing out .Bf before subblocks and re-opening it afterwards would merely complicate both the C code of the program and the generated HTML code. Besides, converting .Em to semantic HTML markup would require some content to be put into <em> and some into <i>, but we cannot automatically distinguish which is which, so strictly speaking, we can't use semantic HTML here but have to fall back to physical markup. Wonders of HTML...
* Use <em> for .Em and .Bf -emphasis.schwarze2014-08-131-7/+5
| | | | | | | | | | | | | | | | | The vast majority of .Em in real-world manuals is stress emphasis, for which <em> is the correct markup. Admittedly, there are some instances of .Em usage for alternate quality, for which <i> would be a better match. Most of these are technical terms that neither allow semantic markup nor are keywords - for the latter, .Sy would be preferable. A typical example is that the shell breaks input into .Em words . Alternate voice or mood, which would also require <i>, is almost absent from manuals. We cannot satisfy both stress emphasis and alternate quality, so pick the one that fits more often and looks less wrong when off. Patch from Guy Harris <guy at alum dot mit dot edu>. ok bentley@ joerg@NetBSD
* Bring the handling of defective prologues even closer to groff,schwarze2014-08-081-4/+9
| | | | | | | | | | | | in particular relaxing the distinction between prologue and body and further improving messages. * The last .Dd wins and the last .Os wins, even in the body. * The last .Dt before the first body macro wins. * Missing title in .Dt defaults to UNTITLED. Warn about it. * Missing section in .Dt does not default to 1. But warn about it. * Do not warn multiple times about the same mdoc(7) prologue macro. * Warn about missing .Os. * Incomplete .TH defaults to empty strings. Warn about it.
* Clarity with respect to floating point handling:schwarze2014-08-081-3/+3
| | | | | | Write double constants as double rather than integer literals. Remove useless explicit (double) cast done at one place and nowhere else. No functional change.
* Various improvements related to .Ex and .Rv:schwarze2014-08-081-25/+31
| | | | | | | | | | * let .Nm fall back to the empty string, not to UNKNOWN * never let .Rv copy an argument from .Nm * avoid spurious \fR after empty .Nm in -Tman * correct handling of .Ex and .Rv in -Tman * correct the wording of the output for .Rv without arguments * use non-breaking spaces in .Ex and .Rv output where required * split MANDOCERR_NONAME into a warning for .Ex and an error for .Nm
* When .Sm is called without an argument, groff toggles the spacing mode,schwarze2014-07-021-15/+8
| | | | | so let us do the same for compatibility. Using this feature is of course not recommended except in manual page obfuscation contests.
* Implement the obsolete macros .En .Es .Fr .Ot for backward compatibility,schwarze2014-07-021-9/+24
| | | | | since this is hardly more complicated than explicitly ignoring them as we did in the past. Of course, do not use them!
* Audit strlcpy(3)/strlcat(3) usage.schwarze2014-04-231-17/+22
| | | | | | | | | | | | | * Repair three instances of silent truncation, use asprintf(3). * Change two instances of strlen(3)+malloc(3)+strlcpy(3)+strlcat(3)+... to use asprintf(3) instead to make them less error prone. * Cast the return value of four instances where the destination buffer is known to be large enough to (void). * Completely remove three useless instances of strlcpy(3)/strlcat(3). * Mark two places in -Thtml with XXX that can cause information loss and crashes but are not easy to fix, requiring design changes of some internal interfaces. * The file mandocdb.c remains to be audited.
* fix unchecked snprintf(3) in page header printing:schwarze2014-04-201-3/+7
| | | | | the length of the title is unknown, and speed doesn't matter here, so use asprintf/free rather than a static buffer
* KNF: case (FOO): -> case FOO, remove /* LINTED */ and /* ARGSUSED */,schwarze2014-04-201-305/+185
| | | | | remove trailing whitespace and blanks before tabs, improve some indenting; no functional change
* Implement the roff(7) .ll (line length) request.schwarze2014-03-301-2/+12
| | | | | Found by naddy@ in the textproc/enchant(1) port. Of course, do not use this in new manuals.
* It turns out SYNOPSIS mode does not imply .Bk in general,schwarze2013-12-241-2/+2
| | | | | | | but only within .Nm blocks. Simplify the code accordingly. This reduces groff-mandoc differences in base by about 2%. Triggered by research done by Franco Fichtner.
* When deciding whether two consecutive macros are on the same input line,schwarze2013-12-241-8/+4
| | | | | | | | we have to compare the line where the first one *ends* (not where it begins) to the line where the second one starts. This fixes the bug that .Bk allowed output line breaks right after block macros spanning more than one input line, even when the next macro follows on the same line.
* Cleanup naming of local variables to make the code easier on the eye:schwarze2012-11-171-29/+30
| | | | | | | | Settle for "struct man *man", "struct mdoc *mdoc", "struct meta *meta" and avoid the confusing "*m" which was sometimes this, sometimes that. No functional change. ok kristaps@ some time ago
* .Sq should use curly right quotes in HTML output to match its curlymatthew2012-08-121-4/+4
| | | | | | | | | left quotes. Also, properly reinitialize the styles attribute string buffer for each column in a table so that the attributes don't accumulate. tweak and ok schwarze
* Correct .Eo spacing:schwarze2011-11-031-2/+6
| | | | | no space between the delimiters and the enclosed text. The mdoc_html.c part was added by kristaps; ok kristaps@.
* Remove a bunch of useless assignments,schwarze2011-10-161-2/+2
| | | | | | | and assert that print_bvspace cannot be called on NULL pointers. No change in behaviour, none of these were bugs, but the code becomes easier to understand. Based on a clang report posted by joerg@; ok kristaps@.
* Always print <table> column widths in -T[x]html;schwarze2011-10-091-38/+18
| | | | | if desired, they can be overridden in the CSS file. Suggested by kristaps@, and i always like to simplify code.
* Sync to version 1.12.0; all code by kristaps@:schwarze2011-10-091-16/+17
| | | | | | | | Implement .Rv in -Tman. Let -man -Tman work a bit like cat(1). Add the -Ofragment option to -T[x]html. Minor fixes in -T[x]html. Lots of apropos(1) and -Tman code cleanup.
* sync to version 1.11.7 from kristaps@schwarze2011-09-181-19/+30
| | | | | | | | main new feature: support the roff(7) .tr request plus various bugfixes and some refactoring regressions are so minor that it's better to get this in and fix them in the tree
* sync to version 1.11.5:schwarze2011-09-181-5/+2
| | | | | | | | adding an implementation of the eqn(7) language by kristaps@ So far, only .EQ/.EN blocks are handled, in-line equations are not, and rendering is not yet very pretty, but the parser is fairly complete.
* Sync to bsd.lv (all coded by kristaps@):schwarze2011-07-051-3/+6
| | | | | | | | | | - mdoc(7): fix an assertion if the first line after .Bd -column starts with a blank, and some simplifications in mdoc_argv.c - man(7): literal mode ends at .SH and .SS (bug reported by naddy@) - allow .RS/.RE blocks to nest (bug reported by dcoppa@ and gsoares@) - improve vertical spacing of man(7) blocks - roff(7): clear user-defined strings when starting a new file - correct ID tags in -T[x]html
* Have -T[x]html print out the link target for `Lk'schwarze2011-06-181-4/+5
| | | | | if no link title is provided. Based on a patch by Tim van der Molen, tweaked by kristaps@.
* Merge release 1.11.3, almost all code by kristaps@:schwarze2011-05-291-35/+33
| | | | | | | | | * Unicode output support (no Unicode input yet, though). * Refactoring: completely handle predefined strings in roff.c. - New function mandoc_escape() replaces a2roffdeco() and mandoc_special(). - Start using mandoc_getarg() in mdoc_argv.c. - Clean up parsing of delimiters in mdoc(7). * And many minor fixes and lots of cleanup.
* Merge version 1.11.1:schwarze2011-04-241-79/+175
| | | | | | | | | | | | | | Again lots of cleanup and maintenance work by kristaps@. - simplify error reporting: less function pointers, more mandoc_[v]msg - main: split document parsing out of main.c into read.c - roff, mdoc, man: improved recognition of control characters - roff: better handling of if/else stack overflows - roff: add some predefined strings for backward compatibility - mdoc, man: empty sections are not errors - mdoc: move delimiter handling to libmdoc - some header restructuring and some minor features and fixes This merge causes two minor regressions that i will fix in separate commits right afterwards.
* Merge version 1.10.10:schwarze2011-04-211-2/+7
| | | | | | | | | | lots of cleanup and maintenance work by kristaps@. - move some main.c globals into struct curparse - move mandoc_*alloc to mandoc.h such that all code can use them - make mandoc_isdelim available to formatting frontends - dissolve mdoc_strings.c, move the code where it is used - make all error reporting functions void, their return values were useless - and various minor cleanups and fixes
* Import the foundation for eqn(7) support.schwarze2011-03-201-1/+4
| | | | | | | | Written by kristaps@. For now, i'm adding one line to each of the four frontends to just pass the input text through to the output, not yet interpreting any of then eqn keywords.
* Clean up date handling,schwarze2011-03-071-5/+2
| | | | | | | | | | | | as a first step to get rid of the frequent petty warnings in this area: - always store dates as strings, not as seconds since the Epoch - for input, try the three most common formats everywhere - for unrecognized format, just pass the date though verbatim - when there is no date at all, still use the current date Originally triggered by a one-line patch from Tim van der Molen, <tbvdm at xs4all dot nl>, which is included here. Feedback and OK on manual parts from jmc@. "please check this in" kristaps@
* Do not break the line between the arguments of .Bsx .Dx .Fx .Nx .Ox .Ux.schwarze2011-02-061-2/+10
| | | | Original patch from kristaps@, but i fixed a regression regarding .Bk.
* If .Ns is specified on its own line, ignore it, like groff does;schwarze2011-02-061-2/+3
| | | | from kristaps@.
* When in a <PRE>, don't print out the <BR> before lines that haveschwarze2011-01-311-3/+17
| | | | leading whitespace; from kristaps@.
* Make .Bx accept not more than two arguments.schwarze2011-01-301-7/+15
| | | | | | | Convert the first character of the second argument to uppercase. Append the second argument with a hyphen. Improves chpass(1), column(1), fstat(1), ... from kristaps@
* Merge from bsd.lv, original commit message by kristaps@:schwarze2011-01-161-5/+21
| | | | | | | | | | Change how -Thtml behaves with tables: use multiple rows, with widths set by COL, until an external macro is encountered. At this point in time, close out the table and process the macro. When the first table row is again re-encountered, re-start the table. This requires a bit of tracking added to "struct html", but the change is very small and follows the logic of meta-fonts. This all follows a bug-report by joerg@.
* If the first character of a free-form text input line is whitespace,schwarze2011-01-161-1/+3
| | | | | then it will start a new output line; from kristaps@.
* Remove an unused variable, and use int for array indices (not size_t);schwarze2011-01-091-4/+5
| | | | found by lint(1), fixed by kristaps@, no functional change.
* Merge kristaps@' cleaner tbl integration, removing mine;schwarze2011-01-041-3/+6
| | | | there are still a few bugs, but fixing these will be easier in tree.