aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_html.c
Commit message (Collapse)AuthorAgeFilesLines
* In HTML output, correctly render .Bd -unfilled in proportionally-spacedIngo Schwarze2021-03-301-3/+6
| | | | | | | | | | | 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.
* In HTML output, avoid printing a newline right after <pre>Ingo Schwarze2020-10-161-6/+5
| | | | | | | | 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@.
* Correctly handle non-unique tags even when NODE_ID and NODE_HREF fallIngo Schwarze2020-04-191-4/+9
| | | | apart, NODE_ID occurring earlier than NODE_HREF.
* When a .Tg is attached to a paragraph, attach the permalinkIngo Schwarze2020-04-181-4/+7
| | | | to the first word, or the first few words if they are short.
* Support manual tagging of .Pp, .Bd, .D1, .Dl, .Bl, and .It.Ingo Schwarze2020-04-061-15/+20
| | | | | | 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.
* Just like we are already doing it in HTML output, automatically tagIngo Schwarze2020-04-011-3/+1
| | | | | | | 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.
* Split tagging into a validation part including prioritizationIngo Schwarze2020-03-131-159/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.Ingo Schwarze2020-02-271-2/+2
| | | | Consequently, write an explicit end tag for <mark> elements.
* Introduce the concept of nodes that are semantically transparent:Ingo Schwarze2020-02-271-32/+38
| | | | | | | | | | | | | | 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@.
* Introduce a new mdoc(7) macro .Tg ("tag") to explicitly mark a placeIngo Schwarze2020-01-191-2/+14
| | | | | | | | | | | | | | | 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@.
* In HTML, display straight quotes, not curly quotes, for Qq/Qo/Qc macros.Ingo Schwarze2019-12-111-4/+8
| | | | | | This is the intended behavior and already the case in terminal output. Incorrect output noticed by Eldred Habert. Patch from bentley@.
* Fix line breaking in no-fill mode (.Bd -unfilled/<pre>),Ingo Schwarze2019-09-151-21/+27
| | | | | | | | | | | | | 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@.
* Format .Nd with more logically with <span> rather than <div>; after all,Ingo Schwarze2019-09-031-4/+2
| | | | | | | | | | 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.
* delete the TAG_IDIV crutch, which is no longer usedIngo Schwarze2019-09-011-2/+2
|
* Wrap .Sh/.SH sections and .Ss/.SS subsections in HTML <section> elementsIngo Schwarze2019-03-011-2/+6
| | | | | | as recommended for accessibility by the HTML 5 standard. Triggered by a similar, but slightly different suggestion from Laura Morales <lauretas at mail dot com>.
* The .UR and .MT blocks in man(7) are represented by <a> elementsIngo Schwarze2019-01-181-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | which establish phrasing context, but they can contain paragraph breaks (which is relevant for terminal formatting, so we can't just change the structure of the syntax tree), which are respresented by <p> elements and cannot occur inside <a>. Fix this by prematurely closing the <a> element in the HTML formatter. This menas that the clickable text in HTML output is shorter than what is represented as the link text in terminal output, but in HTML, it is frankly impossible to have the clickable area of a hyperlink extend across a paragraph break. The difference in presentation is not a major problem, and besides, paragraph breaks inside .UR are rather poor style in the first place. The implementation is quite tricky. Naively closing out the <a> prematurely would result in accessing a stale pointer when later reaching the physical end of the .UR block. So this commit separates visual and structural closing of "struct tag" stack items. Visual closing means that the HTML element is closed but the "struct tag" remains on the stack, to avoid later access to a stale pointer and to avoid closing the same HTML element a second time later. This also needs reference counting of pointers to "struct tag" stack items because often more than one child holds a pointer to the same parent item, and only the outermost child can safely do the physical closing. In the whole corpus of nearly half a million manual pages on man.openbsd.org, this problem occurs in exactly one page: the groff(1) version 1.20.1 manual contained in DragonFly-3.8.2, which contains a formatting error triggering the bug.
* do not access a NULL pointer when formatting a completely empty documentIngo Schwarze2019-01-111-3/+3
|
* Remove the HTML title= attributes which harmed accessibility andIngo Schwarze2019-01-111-43/+43
| | | | | | | violated the principle of separation of content and presentation. Instead, implement the tooltips purely in CSS. Thanks to John Gardner <gardnerjohng at gmail dot com> for suggesting most of the styling in the new ::before rules.
* After years of gnashing of teeth, i finally found a way to avoidIngo Schwarze2019-01-101-13/+1
| | | | | | | | | | | | | | | | | | having to write empty list elements for non-compact .Bl -tag lists: 1. Add margin-bottom to the <dd>. Note that margin-top on the <dt> doesn't work because it would put a short <dt> lower than the <dd>; margin-bottom on the <dt> doesn't work because it would put vertical space before the <dd> for a long <dt>; and margin-top on the <dd> doesn't work because it would put a short <dt> higher than the <dd>. Only margin-bottom on the <dd> has none of these adverse effects. 2. Of course, margin-bottom on the <dd> fails to take care of the vertical spacing before the first list element, so implement that separately by margin-top on the <dl>. 3. For .Bl -tag -compact, reset both to zero.
* Represent mdoc(7) .Pp (and .sp, and some SYNOPSIS and .Rs features)Ingo Schwarze2019-01-071-94/+132
| | | | | | | | | | | | | | | | | | | by the <p> HTML element and use the html_fillmode() mechanism for .Bd -unfilled, just like it was done for man(7) earlier, finally getting rid both of the horrible <div class="Pp"></div> hack and of the worst HTML syntax violations caused by nested displays. Care is needed because in some situations, paragraphs have to remain open across several subsequent macros, whereas in other situations, they must get closed together with a block containing them. Some implementation details include: * Always close paragraphs before emitting HTML flow content. * Let html_close_paragraph() also close <pre> for extra safety. * Drop the old, now unused function print_paragraph(). * Minor adjustments in the top-level man(7) node formatter for symmetry. * Bugfix: .Ss heads suspend no-fill mode, even though .Ss doesn't end it. * Bugfix: give up on .Op semantic markup for now, see the comment.
* Cleanup, no functional change:Ingo Schwarze2018-12-311-13/+4
| | | | | | | | | | Stop trying to keep fill mode state locally in the mdoc HTML formatter, rely on the state stored in the nodes instead. Note that the .Bd -literal code is buggy. Nested literal displays result in nested <pre> elements, which violates HTML syntax. But i'm not yet fixing bugs in this commit, i'm merely deleting code which has no effect.
* Cleanup, no functional change:Ingo Schwarze2018-12-301-6/+6
| | | | | | | | | | | | | | The struct roff_man used to be a bad mixture of internal parser state and public parsing results. Move the public results to the parsing result struct roff_meta, which is already public. Move the rest of struct roff_man to the parser-internal header roff_int.h. Since the validators need access to the parser state, call them from the top level parser during mparse_result() rather than from the main programs, also reducing code duplication. This keeps parser internal state out of thee main programs (five in mandoc portable) and out of eight formatters.
* bugfix: make the static class buffer long enoughIngo Schwarze2018-12-251-2/+2
| | | | for .Bl -bullet -compact -offset indent
* In the TOC, close <a> before opening <ul>.Ingo Schwarze2018-12-221-2/+3
| | | | Simplified version of a bugfix patch from rapha@.
* Yet another round of improvements to manual font selection.Ingo Schwarze2018-12-161-1/+2
| | | | | | | | | Unify handling of \f and .ft. Support \f4 (bold+italic). Support ".ft BI" and ".ft CW" for terminal output. Support the .ft request in HTML output. Reject the bogus fonts \f(C1, \f(C2, \f(C3, and \f(CP. In regress.pl, only strip leading whitespace in math mode.
* Cleanup, no functional change:Ingo Schwarze2018-12-131-2/+1
| | | | | | | | | | Split the top level parser interface out of the utility header mandoc.h, into a new header mandoc_parse.h, for use in the main program and in the main parser only. Move enum mandoc_os into roff.h because struct roff_man is the place where it is stored. This allows removal of mandoc.h from seven files in low-level parsers and in formatters.
* In the validators, translate obsolete macro aliases (Lp, Ot, LP, P)Ingo Schwarze2018-12-031-4/+10
| | | | | | to the standard forms (Pp, Ft, PP) up front, such that later code does not need to look for the obsolete versions. This reduces the risk of incomplete handling.
* When a subsection header contains no letters but only specialIngo Schwarze2018-10-041-2/+4
| | | | characters, skip the TOC entry. Issue reported by kristaps@.
* add DESCRIPTION and .Ss to the toc; suggested by espie@Ingo Schwarze2018-10-021-7/+23
|
* Add an option -T html -O toc to add a brief table of contents nearIngo Schwarze2018-10-021-2/+32
| | | | | the top of HTML pages containing at least two non-standard sections. Suggested by Adam Kalisz and discussed with kristaps@ during EuroBSDCon 2018.
* Support a second argument to -O man,Ingo Schwarze2018-10-021-2/+2
| | | | | | selecting the format according to local existence of the file. Suggested by kristaps@ during EuroBSDCon 2018. Written on the train Frankfurt-Karlsruhe returning from EuroBSDCon.
* Remove more pointer arithmetic passing via regions outside the arrayIngo Schwarze2018-08-171-8/+8
| | | | | that is undefined according to the C standard. Robert Elz <kre at munnari dot oz dot au> pointed out i wasn't quite done yet.
* garbage collect the unused "#define INDENT"Ingo Schwarze2018-07-271-3/+1
|
* Delete substantial amounts of codeIngo Schwarze2018-06-251-4/+3
| | | | now that we no longer use variable style= attributes.
* Drop explicit, constant style=margin-left attribute on .Bf blocks.Ingo Schwarze2018-06-251-2/+2
| | | | Since <div> uses HTML_NLAROUND, it is no longer needed.
* Do not write <colgroup> elements. Their only purpose is to enforceIngo Schwarze2018-06-251-22/+2
| | | | | | author-specified column widths, which can harm responsive design and provide no real benefit: HTML rendering engines usually do just fine automatically selecting appropriate column widths.
* In HTML output, for lists that have an -indent argument, just useIngo Schwarze2018-06-101-17/+10
| | | | | | | | | | | | | a uniform indentation in CSS adapted to the viewport width and ignore the value of the argument taken from mdoc(7). While author-specified widths somewhat work as a micro-optimization in terminal and typeset output, they are nothing but harmful in HTML style= attributes because they break responsive design, whereas using a reasonable default indent almost never results in ugly output. Admittedly, the author-specified width might occasionally look even better, but only slightly so, and only for some viewport sizes. Based on guidance provided by John Gardner.
* Ignore author-specified -width arguments for -tag and -hang listsIngo Schwarze2018-05-291-7/+6
| | | | | | | | | | | | | | | in HTML output. For terminal and typeset output, such arguments kind of work to achieve presentational micro-optimization. But for HTML, they only do harm. Large increases usually look ugly. Large reductions are impossible since the default is not large in the first place. Small tweaks in either direction are not important; at least not important enough to justify making responsive design impossible. Triggered by John Gardner's suggestion to further reduce style= attributes in the HTML code, in particular those containing hard-coded lengths.
* Do not write duplicate id= attributes, they violate HTML syntax.Ingo Schwarze2018-05-251-17/+6
| | | | | Append suffixes for disambiguation. Issue first reported by Jakub Klinkovsky <j dot l dot k at gmx dot com> (Arch Linux).
* Use <span> for .Ms rather than <b>; discussed with John Gardner.Ingo Schwarze2018-05-211-2/+2
|
* Use <span> for .Ad rather than <i>; also suggested by John Gardner.Ingo Schwarze2018-05-211-2/+2
|
* Use <span> rather than abusing <i> for .Pa;Ingo Schwarze2018-05-211-2/+2
| | | | suggested by John Gardner <gardnerjohng at gmail dot com>.
* Fix a long-standing issue:Ingo Schwarze2018-05-091-15/+11
| | | | | | | | | Some macros (Nd, Oo) can contain blocks but rendered as elements that can only contain phrasing content, resulting in invalid HTML nesting. Switch them to <div>. Also move the related "display: inline" style from the HTML to the CSS. Reminded during a conversation with John Gardner.
* Eliminate the class=It-* attributes.Ingo Schwarze2018-05-081-54/+13
| | | | | Cleaner HTML, more idiomatic CSS, and minus 30 lines of C code. Suggested by John Gardner <gardnerjohng at gmail dot com>.
* Switch the emitted HTML element from <b> to <code> for the fixedIngo Schwarze2018-05-081-11/+11
| | | | | | | | syntax element macros .Nm, .Fl, .Cm, .Ic, .In, .Fd, .Fn, and .Cd. Adjust both the internal and external style sheets such that rendering remains unchanged in typical browsers. Based on feedback from John Gardner <gardnerjohng at gmail dot com>.
* replace my vague and idiosyncratic term "selflink"Ingo Schwarze2018-04-241-12/+12
| | | | | with the clearer and more usual "permalink"; suggested by John Gardner <gardnerjohng at gmail dot com>
* preserve comments before .Dd and .TH (typically Copyright and license)Ingo Schwarze2018-04-131-13/+20
| | | | | in full HTML output, but not with -Ofragment, e.g. in man.cgi(8); suggested by Thomas Klausner <wiz at NetBSD>
* preserve comments before .Dd when converting mdoc(7) to man(7)Ingo Schwarze2018-04-111-2/+2
| | | | with mandoc -Tman; suggested by Thomas Klausner <wiz at NetBSD>
* In .Bl -tag and -hang, do not print a margin-left style attributeIngo Schwarze2017-07-151-5/+5
| | | | | | for each individual item if the -width argument matches the default of 6n. Suggested by Steffen Nurpmeso <steffen at sdaoden dot eu> on <groff at GNU dot org> in April 2017.
* use the same width increase logic for .Bl -hang as for .Bl -tagIngo Schwarze2017-07-151-2/+2
|