summaryrefslogtreecommitdiffstats
path: root/tbl_html.c
Commit message (Collapse)AuthorAgeFilesLines
* If the last data row of a tbl(7) contains nothing but a horizontal line,Ingo Schwarze2022-04-231-2/+4
| | | | | | | | | | | | | | | | | | | | | | | do not skip closing the table and cleaning up memory at the end of the table in the HTML output module. This bug resulted in skipping the tblcalc() function and reusing the existing roffcol array for the next tbl(7) processed. If the next table had more columns than the one ending with a horizontal line in the last data row, uninitialized memory was read, potentially resulting in near-infinite output. The bug was introduced in rev. 1.29 (2018/11/26) but only fully exposed by rev. 1.38 (2021/09/09). Until rev. 1.37, it could only cause misformatting and invalid HTML output syntax but not huge output because up to that point, the function did not use the roffcol array. Nasty bug found the hard way by Michael Stapelberg on the production server manpages.debian.org. Michael also supplied example files and excellent instructions how to reproduce the bug, which was very difficult because no real-world manual page is known that triggers the bug by itself, so to reproduce the bug, mandoc(1) had to be invoked with at least two file name arguments.
* support for hunting memory leaks;Ingo Schwarze2022-04-141-1/+4
| | | | designed and written last autumn, polished today
* According to the tbl(7) manual, if a data cell contains only theIngo Schwarze2022-01-121-2/+4
| | | | | | | | | | | | | | two character sequence "\_" or "\=", a single or double horizontal line is supposed to be drawn inside the cell, not joining its neighbours. I am not aware of any way to do that with HTML and/or CSS. Still, it seems closer to the intent of the document author to draw a horizontal line with <hr/>, even though that line will join the neighbour cells, rather than printing a literal '_' or '=' character. Formatting tweak inspired by a related question from Ted Bullock <tbullock at comlore dot com>.
* In HTML output, in cells with an "n" (number) layout, pad numbersIngo Schwarze2021-09-091-0/+24
| | | | | | | | | on the right side with UTF-8 punctuation and figure spaces such that numbers in different tbl(7) rows align at the decimal point. The exact HTML output format was suggested by <Oliver dot Corff at email dot de>; the implementation in C is mine.
* If the layout or data of an individual cell in a tbl(7) containsIngo Schwarze2021-09-091-1/+6
| | | | | | | | | | | | | | only "_", "-", or "=", requesting a horizontal line to be drawn across the middle of the cell, print <hr/> in that cell in HTML output. That is arguably slightly ugly because HTML 5 regards <hr/> as semantic markup, meaning "thematic break". If somebody knowns a better way to render a horizontal line across the middle of a table cell with pure HTML and CSS, and without implying a specific meaning, please tell me. Missing feature reported by <Oliver dot Corff at email dot de>.
* Support two-character font names (BI, CW, CR, CB, CI)Ingo Schwarze2021-08-101-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | in the tbl(7) layout font modifier. Get rid of the TBL_CELL_BOLD and TBL_CELL_ITALIC flags and use the usual ESCAPE_FONT* enum mandoc_esc members from mandoc.h instead, which simplifies and unifies some code. While here, also support CB and CI in roff(7) \f escape sequences and in roff(7) .ft requests for all output modes. Using those is certainly not recommended because portability is limited even with groff, but supporting them makes some existing third-party manual pages look better, in particular in HTML output mode. Bug-compatible with groff as far as i'm aware, except that i consider font names starting with the '\n' (ASCII 0x0a line feed) character so insane that i decided to not support them. Missing feature reported by nabijaczleweli dot xyz in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=992002. I used none of the code from the initial patch submitted by nabijaczleweli, but some of their ideas. Final patch tested by them, too.
* Implement the layout specification "a" (left justify with 1em indentation)Ingo Schwarze2021-05-161-0/+2
| | | | | | in HTML output mode; before this patch, the indentation was missing. Terminal output already supported the "a" specifier since 2010. Issue reported and patch tested by Oliver dot Corff at email dot de.
* implement the tbl(7) layout modifiers "b" (bold) and "i" (italic)Ingo Schwarze2021-05-161-2/+10
| | | | | in HTML output mode, similar to tbl_term.c, function tbl_word(); issue reported by Oliver dot Corff at email dot de
* The header file "html.h" uses enum roff_tok,Ingo Schwarze2019-03-171-0/+1
| | | | | | so "roff.h" must be included before it. Diff from bcallah@ tweaked by me; he found the bug by compiling with pcc.
* Finally, represent the man(7) .PP and .HP macros by the naturalIngo Schwarze2019-01-061-0/+1
| | | | | | | | | | | 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.
* 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-121-1/+1
| | | | | No need to expose the tbl(7) syntax tree data structures everywhere. Move them to their own include file, "tbl.h", and improve comments.
* Implement tbl(7) lines in -T html output,Ingo Schwarze2018-11-261-67/+123
| | | | | | | | | | | | as far as they are on the edges of table cells rather than going through the middle of cells: * the box, doublebox, and allbox options; * the | and || layout modifiers; * and the _ and = data lines; - but not yet _ and = in individual layout and data cells. Missing feature reported by Pali dot Rohar at gmail dot com.
* Simplify writing of tbl(7) cells by using the new feature of passingIngo Schwarze2018-11-261-16/+4
| | | | | | a NULL pointer for the value of a style attribute, in which case the attribute is omitted from the HTML element. Minus 12 lines of ugly and repetitive code, no functional change.
* Let cells containing nothing but \^ extend the cell above.Ingo Schwarze2018-11-251-6/+11
| | | | Missing feature reported by Pali dot Rohar at gmail dot com.
* In tbl(7) -T html output,Ingo Schwarze2018-11-251-16/+39
| | | | | | | | | | span cells horizontally and vertically as requested by the layout. Does not handle spans requested in the data section yet. To be able to do this, record the number of rows spanned in the first data cell (struct tbl_dat) of a vertical span. Missing feature reported by Pali dot Rohar at gmail dot com.
* Implement horizontal and vertical alignment of tbl(7) cell contentIngo Schwarze2018-11-241-5/+35
| | | | | in -T html output. This does not handle spanned cells yet. Missing feature reported by Pali dot Rohar at gmail dot com.
* Do not write <colgroup> elements. Their only purpose is to enforceIngo Schwarze2018-06-251-9/+0
| | | | | | 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.
* Ignore explicitly specified negative column widths rather thanIngo Schwarze2017-07-311-0/+3
| | | | | wrapping around to huge numbers and risking memory exhaustion; fixes Debian ps(1). Bug reported by Dr. Markus Waldeck.
* fix column width calculation for text block cellsIngo Schwarze2017-06-121-1/+1
|
* Implement w layout specifier (minimum column width).Ingo Schwarze2017-06-081-2/+29
| | | | | Improve width calculation of text blocks. Reduces the groff/mandoc diff in Base+Xenocara by about 800 lines.
* Improve <table> syntax:Ingo Schwarze2017-02-051-2/+3
| | | | | | | | The <col> element can only appear inside <colgroup>, so use <colgroup>. The <tbody> element is optional and useless, so don't use it. Even if we would ever need <thead> or <tfoot>, <tbody> would still be optional and useless; besides, we will likely never need <thead> or <tfoot>, simply because our languages don't support such functionality.
* Simplify the usage of print_otag() by making it accept a variableIngo Schwarze2017-01-171-21/+9
| | | | | | | | | | number of arguments. Delete struct htmlpair and all the PAIR_*() macros. Delete enum htmlattr, handle that in print_otag() instead. Minus 190 lines of code; no functional change except better ordering of attributes (class before style) in three cases.
* To make the code more readable, delete 283 /* FALLTHROUGH */ commentsIngo Schwarze2015-10-121-1/+0
| | | | | | that were right between two adjacent case statement. Keep only those 24 where the first case actually executes some code before falling through to the next case.
* modernize style: "return" is not a functionIngo Schwarze2015-10-061-2/+3
|
* Delete the redundant tbl span flags, just inspect the actual dataIngo Schwarze2015-01-301-2/+2
| | | | | | | | where needed, which is less fragile. This fixes a subtle NULL pointer access to tp->tbl.cols: Due to a bug in the man(7) parser, the first span of a table can end up in a .TP head, in which case tblcalc() was never called. Found by jsg@ with afl.
* Abolish struct tbl_head and replace it by an "int col" member inIngo Schwarze2015-01-301-7/+7
| | | | struct tbl_cell. No functional change, minus 40 lines of code.
* Auditing the tbl(7) code for more NULL pointer accesses, i came outIngo Schwarze2015-01-301-6/+6
| | | | | empty-handed; so this is just KNF and some code simplifications, no functional change.
* Rudimentary implementation of the e, x, and z table layout modifiersIngo Schwarze2014-10-141-1/+1
| | | | | | | to equalize, maximize, and ignore the width of columns. Does not yet take vertical rulers into account, and does not do line breaks within table cells. Considerably improves the lftp(1) manual; issue noticed by sthen@.
* Get rid of HAVE_CONFIG_H, it is always defined; idea from libnbcompat.Ingo Schwarze2014-08-101-2/+2
| | | | | | Include <sys/types.h> where needed, it does not belong in config.h. Remove <stdio.h> from config.h; if it is missing somewhere, it should be added, but i cannot find a *.c file where it is missing.
* KNF: case (FOO): -> case FOO:, remove /* LINTED */ and /* ARGSUSED */,Ingo Schwarze2014-04-201-5/+4
| | | | | remove trailing whitespace and blanks before tabs, improve some indenting; no functional change
* Do not handle vertical lines as additional tbl(7) columns,Ingo Schwarze2012-05-271-13/+5
| | | | | | | | | | | | | | | | instead save their properties with the following column. This simplifies layout parsing and saves a lot of code related to column handling. At output time, print all white space and vertical lines separating columns before printing the following column, and none after printing the preceding column, considerably simplifying white space handling and width calculations. No functional change, but it saves 150 lines of code, and it allows the next patch to tbl_term.c, tbl_literal(). "Please check them in and I'll look into them later!" kristaps@
* forgotten Copyright bumps; no code changeIngo Schwarze2011-09-181-1/+1
| | | | found while syncing to OpenBSD
* Fix copyright email.Kristaps Dzonsons2011-07-171-1/+1
|
* Change how -Thtml behaves with tables: use multiple rows, with widthsKristaps Dzonsons2011-01-131-44/+61
| | | | | | | | | 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@.
* Add support for "^" vertical spanners. Unlike GNU tbl, raiseKristaps Dzonsons2011-01-111-3/+11
| | | | | | | error-class messages when data is being ignored by specifying it in "^" cells (either as-is or in blocks). Also note again that horizontal spanners aren't really supported...
* Restructured tbl_html() function so that we always clean up our columns.Kristaps Dzonsons2011-01-061-39/+42
|
* Make -T[x]html for tables structure cells with a width. I don'tKristaps Dzonsons2011-01-061-1/+48
| | | | | | | anticipate doing much more than this for the coming release. Also, remove "base" part of struct html (not used anywhere) and put some comments in struct html.h.
* Give tables an HTML class.Kristaps Dzonsons2011-01-051-2/+5
|
* Support `T{' and `T}' data blocks. When a standalone `T{' isKristaps Dzonsons2011-01-041-1/+2
| | | | | | | encountered as a line's last data cell, move into TBL_PART_CDATA mode whilst leaving the cell's designation as TBL_DATA_NONE. When new data arrives that's not a standalone `T}', append it to the cell contends. Close out and warn appropriately.
* Add skeleton for -T[x]html tbl stuff. Also start to put in some bits aboutKristaps Dzonsons2011-01-041-0/+72
the up-coming version, although we're not quite there yet.