summaryrefslogtreecommitdiffstats
path: root/mdoc_html.c
Commit message (Collapse)AuthorAgeFilesLines
* https://www.w3.org/WAI/ARIA/apg/practices/names-and-descriptions/ says:Ingo Schwarze2022-07-061-2/+2
| | | | | | | "Start names with a capital letter; it helps some screen readers speak them with appropriate inflection." Anna Vyalkova already did that correctly when sending patches, but i ruined it when committing, so fix it now.
* assign the ARIA role "doc-subtitle" to the .Nd element;Ingo Schwarze2022-07-061-1/+1
| | | | discussed with Anna Vyalkova <cyber at sysrq dot in>
* While the HTML standard allows multiple <h1> elements in the sameIngo Schwarze2022-07-061-3/+3
| | | | | | | | | | | | document, <h1> is intended for top level headers, and most of the sections in a manual page can hardly be considered top-level. It is more usual to use <h1> only for the main title of the document of for the site name. Consequently, move .Sh/.SH from <h1> to <h2> and .Ss/.SS from <h2> to <h3>, freeing <h1> for use by header.html in man.cgi(8). Discussed with Anna Vyalkova <cyber at sysrq dot in>.
* Finally get rid of the archaic <table> markup for header and footer linesIngo Schwarze2022-07-051-14/+17
| | | | | | | | | | | and use flexbox CSS instead. Improve accessibility by adding role and aria-label attributes to these header and footer lines. Using ideas from both Anna Vyalkova <cyber at sysrq dot in> and myself. As a welcome side effect, this also resolves the long-standing issue that the rendering was always 65em wide, requiring horizontal scrolling when the window was narrower. Now, rendering nicely adapts to browser windows of arbitrary narrowness.
* Put the HTML comment containing the Copyright header (if any)Ingo Schwarze2022-07-041-2/+2
| | | | | | | between the <head> and the <body> rather than before the <head> because the <meta charset="utf-8"/> element ought to be within the first 1024 bytes of the HTML code. Issue found with validator.w3.org.
* Instead of the custom <div class="manual-text">, use the standardIngo Schwarze2022-07-031-1/+1
| | | | | | | | | | HTML <main> element. The benefit is that it has the ARIA landmark role "main" by default. To ease the transition for people using their own CSS file instead of mandoc.css, retain the custom class for now. I had this idea in a discussion with Anna Vyalkova <cyber at sysrq dot in>. Patch from Anna, slightly tweaked by me.
* If an .Xr macro contains a section argument, write an aria-label attributeIngo Schwarze2022-06-251-10/+19
| | | | | | | | such that users of screen readers aren't forced to listen to lengthy and distracting readings like "mdoc, left parenthesis, 7, right parenthesis". Based on a patch from Anna Vyalkova <cyber at sysrq dot in>, significantly tweaked by me.
* Improve accessibility of -T html -O toc output by using the <nav> elementIngo Schwarze2022-06-241-2/+3
| | | | | | | | | | | | | in the DPUB-ARIA doc-toc role. Patch from Anna Vyalkova <cyber at sysrq dot in> slightly tweaked by me. This is hopefully the start of a collaboration to improve accessibility of Unix manual pages using the WAI-ARIA, HTML-ARIA, and DPUB-ARIA standards. Progress appears to be possible without changing *anything* with respect to the way manual pages are written. Instead, it seems sufficient to properly translate semantic cues already implied by existing mdoc(7) markup into the appropriate HTML elements and ARIA attributes. Overall, the total length of HTML output is likely to increase slightly, but not much.
* In HTML output, correctly render .Bd -unfilled in proportionally-spacedIngo Schwarze2021-03-301-2/+5
| | | | | | | | | | | 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-5/+4
| | | | | | | | 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-3/+8
| | | | apart, NODE_ID occurring earlier than NODE_HREF.
* When a .Tg is attached to a paragraph, attach the permalinkIngo Schwarze2020-04-181-3/+6
| | | | 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-14/+19
| | | | | | 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-2/+0
| | | | | | | 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-1/+1
| | | | Consequently, write an explicit end tag for <mark> elements.
* Introduce the concept of nodes that are semantically transparent:Ingo Schwarze2020-02-271-31/+37
| | | | | | | | | | | | | | 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-1/+13
| | | | | | | | | | | | | | | 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-3/+7
| | | | | | 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-20/+26
| | | | | | | | | | | | | 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-3/+1
| | | | | | | | | | 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-1/+1
|
* Wrap .Sh/.SH sections and .Ss/.SS subsections in HTML <section> elementsIngo Schwarze2019-03-011-1/+5
| | | | | | 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-7/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-2/+2
|
* Remove the HTML title= attributes which harmed accessibility andIngo Schwarze2019-01-111-42/+42
| | | | | | | 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-12/+0
| | | | | | | | | | | | | | | | | | 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-93/+131
| | | | | | | | | | | | | | | | | | | 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-12/+3
| | | | | | | | | | 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-5/+5
| | | | | | | | | | | | | | 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-1/+1
| | | | for .Bl -bullet -compact -offset indent
* In the TOC, close <a> before opening <ul>.Ingo Schwarze2018-12-221-1/+2
| | | | Simplified version of a bugfix patch from rapha@.
* Yet another round of improvements to manual font selection.Ingo Schwarze2018-12-161-0/+1
| | | | | | | | | 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-1/+0
| | | | | | | | | | 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-3/+9
| | | | | | 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-1/+3
| | | | characters, skip the TOC entry. Issue reported by kristaps@.
* add DESCRIPTION and .Ss to the toc; suggested by espie@Ingo Schwarze2018-10-021-6/+22
|
* Add an option -T html -O toc to add a brief table of contents nearIngo Schwarze2018-10-021-1/+31
| | | | | 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-1/+1
| | | | | | 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-7/+7
| | | | | 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-2/+0
|
* Delete substantial amounts of codeIngo Schwarze2018-06-251-3/+2
| | | | now that we no longer use variable style= attributes.
* Drop explicit, constant style=margin-left attribute on .Bf blocks.Ingo Schwarze2018-06-251-1/+1
| | | | Since <div> uses HTML_NLAROUND, it is no longer needed.
* Do not write <colgroup> elements. Their only purpose is to enforceIngo Schwarze2018-06-251-21/+1
| | | | | | 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-16/+9
| | | | | | | | | | | | | 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-6/+5
| | | | | | | | | | | | | | | 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-16/+5
| | | | | 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-1/+1
|
* Use <span> for .Ad rather than <i>; also suggested by John Gardner.Ingo Schwarze2018-05-211-1/+1
|
* Use <span> rather than abusing <i> for .Pa;Ingo Schwarze2018-05-211-1/+1
| | | | suggested by John Gardner <gardnerjohng at gmail dot com>.