summaryrefslogtreecommitdiffstats
path: root/man_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.
* While the HTML standard allows multiple <h1> elements in the sameIngo Schwarze2022-07-061-2/+2
| | | | | | | | | | | | 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-15/+18
| | | | | | | | | | | 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.
* In HTML output, avoid printing a newline right after <pre>Ingo Schwarze2020-10-161-8/+6
| | | | | | | | 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@.
* automatically tag .SH and .SS in man(7) terminal outputIngo Schwarze2020-04-041-1/+0
| | | | in the same way as it was done for .Sh and .Ss in mdoc(7)
* Split tagging into a validation part including prioritizationIngo Schwarze2020-03-131-9/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Introduce the concept of nodes that are semantically transparent:Ingo Schwarze2020-02-271-5/+7
| | | | | | | | | | | | | | 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@.
* In roff, a space character at the beginning of an input line requiresIngo Schwarze2020-02-121-2/+2
| | | | | | | | 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.
* In HTML output, allow switching the desired font for subsequentIngo Schwarze2019-04-301-2/+2
| | | | | | | | text without printing an opening tag right away, and use that in the .ft request handler. While here, garbage collect redundant enum htmlfont and reduce code duplication in print_text(). Fixing an assertion failure reported by Michael <Stapelberg at Debian> in pmRegisterDerived(3) from libpcp3-dev.
* Represent multiple subsequent .IP blocks having a consistentIngo Schwarze2019-03-021-15/+67
| | | | | | | | | head argument of *, \-, or \(bu as <ul> rather than as <dl>, using a bit of heuristics. Basic idea suggested by Dagfinn Ilmari Mannsaker <ilmari at github> in https://github.com/Debian/debiman/issues/67 and independently by <Pali dot Rohar at gmail dot com> on <discuss at mandoc dot bsd dot lv>.
* Wrap .Sh/.SH sections and .Ss/.SS subsections in HTML <section> elementsIngo Schwarze2019-03-011-6/+13
| | | | | | 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>.
* Format multiple subsequent .IP or multiple subsequent .TP/.TQIngo Schwarze2019-02-281-2/+28
| | | | | as a single <dl> list rather than opening a new list for each item; feature suggested by Pali dot Rohar at gmail dot com.
* The .UR and .MT blocks in man(7) are represented by <a> elementsIngo Schwarze2019-01-181-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-1/+1
|
* Remove the HTML title= attributes which harmed accessibility andIngo Schwarze2019-01-111-5/+5
| | | | | | | 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.
* Represent mdoc(7) .Pp (and .sp, and some SYNOPSIS and .Rs features)Ingo Schwarze2019-01-071-10/+11
| | | | | | | | | | | | | | | | | | | 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.
* Finally, represent the man(7) .PP and .HP macros by the naturalIngo Schwarze2019-01-061-69/+54
| | | | | | | | | | | choice, which is the <p> HTML element. On top of the previous fill-mode improvements, the key to making this possible is to automatically close the <p> when required: before headers, subsequent paragraphs, lists, indented blocks, synopsis blocks, tbl(7) blocks, and before blocks using no-fill mode. In man(7) documents, represent the .sp request by a blank line in no-fill mode and in the same way as .PP in fill mode.
* In no-fill mode, avoid bogus blank lines in two situations:Ingo Schwarze2019-01-051-2/+2
| | | | | 1. After the last child; the parent will take care of the line break. 2. At the .YS macro; the end of the preceding .SY already broke the line.
* minor cleanup, no functional change:Ingo Schwarze2019-01-051-23/+15
| | | | | | | | * delete one irrelevant FIXME; no more fixed lengths in HTML, please * simplify some conditions * avoid testing pointers as truth values, use "!= NULL" * sort some declarations * delete some pointless blank lines
* Now that the NODE_NOFILL flag in the syntax tree is accurate,Ingo Schwarze2019-01-051-116/+17
| | | | | | | | | | use it in the man(7) HTML formatter rather than keeping fill mode state locally, resulting in massive simplification (minus 40 LOC). Move the html_fillmode() state handler function to the html.c module such that both the man(7) and the roff(7) formatter (and in the future, also the mdoc(7) formatter) can use it. Give it a query mode, to be invoked with TOKEN_NONE.
* Move parsing of the .nf and .fi (fill mode) requests from the man(7)Ingo Schwarze2018-12-311-18/+16
| | | | | | parser to the roff(7) parser. As a side effect, .nf and .fi are now also parsed in mdoc(7) input, though the mdoc(7) formatters still ignore most of their 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.
* 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-6/+11
| | | | | | 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.
* Input lines that are not blank but generate no output,Ingo Schwarze2018-10-231-2/+5
| | | | | | | | | | | for example lines containing nothing but "\&", are significant in no-fill mode and can be represented by blank lines inside <pre>. Fixing a bug that Pali dot Rohar at gmail dot com found in pod2man(1) output, for example Email::Address::XS(3p). While here, inside no-fill mode, there is no need to encode totally blank input lines by emulating .PP - just let them through as we are inside <pre> anyway.
* implement the GNU man-ext .SY/.YS (synopsis block) macro in man(7),Ingo Schwarze2018-08-181-0/+24
| | | | used in most manual pages of the groff package
* Remove more pointer arithmetic passing via regions outside the arrayIngo Schwarze2018-08-171-5/+5
| | | | | 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.
* implement the GNU man-ext .TQ macro in man(7),Ingo Schwarze2018-08-161-12/+13
| | | | used for example by groff_diff(7)
* garbage collect the unused "#define INDENT"Ingo Schwarze2018-07-271-2/+0
|
* Ignore author-specified indentation for .RS; it harms responsiveIngo Schwarze2018-06-251-20/+2
| | | | | design. Use the existing @media-dependent indent instead. This removes the last style= attribute from man(7) output.
* For -man -Thtml, ignore author-specified .HP widths because theyIngo Schwarze2018-06-251-15/+4
| | | | harm responsive design; use @media-dependent defaults instead.
* Do not write duplicate id= attributes, they violate HTML syntax.Ingo Schwarze2018-05-251-4/+2
| | | | | Append suffixes for disambiguation. Issue first reported by Jakub Klinkovsky <j dot l dot k at gmx dot com> (Arch Linux).
* Eliminate the class=It-* attributes.Ingo Schwarze2018-05-081-2/+2
| | | | | Cleaner HTML, more idiomatic CSS, and minus 30 lines of C code. Suggested by John Gardner <gardnerjohng at gmail dot com>.
* replace my vague and idiosyncratic term "selflink"Ingo Schwarze2018-04-241-2/+2
| | | | | 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-0/+2
| | | | with mandoc -Tman; suggested by Thomas Klausner <wiz at NetBSD>
* add support for the MT and ME mailto macros, used for example in wg(8);Ingo Schwarze2017-06-251-1/+10
| | | | patch from bentley@
* Split -Wstyle into -Wstyle and the even lower -Wbase, and addIngo Schwarze2017-06-241-0/+1
| | | | | | | | | | | | | | | -Wopenbsd and -Wnetbsd to check conventions for the base system of a specific operating system. Mark operating system specific messages with "(OpenBSD)" at the end. Please use just "-Tlint" to check base system manuals (defaulting to -Wall, which is now -Wbase), but prefer "-Tlint -Wstyle" for the manuals of portable software projects you maintain that are not part of OpenBSD base, to avoid bogus recommendations about base system conventions that do not apply. Issue originally reported by semarie@, solution using an idea from tedu@, discussed with jmc@ and jca@.
* make the internal a2roffsu() interface more powerful by returningIngo Schwarze2017-06-081-5/+1
| | | | | a pointer to the end of the parsed data, making it easier to parse subsequent bytes
* Trailing \c suppresses the output line break even ifIngo Schwarze2017-05-091-1/+2
| | | | | the next line is a text line starting with whitespace. Quirk found in the sysutils/rancid port.
* Move .sp to the roff modules. Enough infrastructure is in placeIngo Schwarze2017-05-051-21/+1
| | | | now that this actually saves code: -70 LOC.
* move .ll to the roff modulesIngo Schwarze2017-05-051-1/+0
|
* Move handling of the roff(7) .ft request from the man(7)Ingo Schwarze2017-05-051-1/+0
| | | | | modules to the new roff(7) modules. As a side effect, mdoc(7) now handles .ft, too. Of course, do not use that.
* Start roff formatter modules for HTML and termininal output,Ingo Schwarze2017-05-041-17/+7
| | | | | | | used by both the mdoc and man formatters, with the ultimate goal of reducing code duplication between the two macro formatters. Made possible by the parser unification. Add the first formatting function (for the .br request).
* Parser reorg:Ingo Schwarze2017-05-041-1/+12
| | | | | Generate the first node on the roff level: .br Fix some column numbers in diagnostic messages while here.
* Continue parser unification:Ingo Schwarze2017-04-241-2/+3
| | | | | | | | * Make enum rofft an internal interface as enum roff_tok in "roff.h". * Represent mdoc and man macros in enum roff_tok. * Make TOKEN_NONE a proper enum value and use it throughout. * Put the prologue macros first in the macro tables. * Unify mdoc_macroname[] and man_macroname[] into roff_name[].
* Fix regression in mdoc_html.c 1.275, man_html 1.134:Ingo Schwarze2017-03-171-2/+4
| | | | | | For .Sh, .Ss, .SH, .SS, only write selflink if an id could be constructed. Crash reported by Raf Czlonka <rczlonka at gmail dot com>, analysis of root cause by natano@