summaryrefslogtreecommitdiffstats
path: root/tree.c
Commit message (Collapse)AuthorAgeFilesLines
* do not crash when a tbl(7) cell uses roman fontIngo Schwarze2021-09-071-0/+2
|
* Support two-character font names (BI, CW, CR, CB, CI)Ingo Schwarze2021-08-101-3/+21
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* Use a separate node->tag attribute rather than abusing the node->stringIngo Schwarze2020-04-081-48/+38
| | | | | attribute for the purpose. No functional change intended. The purpose is to make it possible to later attach tags to text nodes.
* Separate the place to put the <a href> permalink (now markedIngo Schwarze2020-04-071-1/+4
| | | | | | | with NODE_HREF) from the target element of the link (still marked with NODE_ID). In many cases, use this to move the target to the beginning of the paragraph, such that readers don't get dropped into the middle of a sentence.
* Split tagging into a validation part including prioritizationIngo Schwarze2020-03-131-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fully support explicit tagging of .Sh and .Ss.Ingo Schwarze2020-02-271-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | This fixes the offset of two lines in terminal output and this improves HTML output by putting the id= attribute and <a> element into the respective <h1> or <h2> element rather than writing an additional <mark> element. To that end, introduce node flags NODE_ID (to make the node a link target, for example by writing an HTML id= attribute or by calling tag_put()) and NODE_HREF (to make the node a link source, used only in HTML output, used only to write an <a class="permalink"> element). In particular: * In the validator, generalize the concept of the "next node" such that it also works before .Sh and .Ss. * If the first argument of .Tg is empty, don't forget to complain if there are additional arguments, which will be ignored. * In the terminal formatter, support writing of explicit tags for all kinds of nodes, not just for .Tg. * In deroff(), allow nodes to have an explicit string representation even when they aren't text nodes. Use this for explicitly tagged section headers. Suprisingly, this is sufficient to make HTML output work, without explicit code changes in the HTML formatter. * In syntax tree output, display NODE_ID and NODE_HREF.
* Print more tbl(7) details to help debugging:Ingo Schwarze2020-01-111-11/+94
| | | | column numbers, options, layout rows, cell types, cell modifiers.
* display the NODE_NOFILL flag indicating no-fill modeIngo Schwarze2019-01-011-11/+15
|
* 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.
* Cleanup, no functional change:Ingo Schwarze2018-12-131-0/+1
| | | | | | No need to expose the eqn(7) syntax tree data structures everywhere. Move them to their own include file, "eqn.h". While here, delete the unused enum eqn_pilet.
* Cleanup, no functional change:Ingo Schwarze2018-12-121-0/+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.
* In tbl(7) -T html output,Ingo Schwarze2018-11-251-25/+31
| | | | | | | | | | 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.
* support tail arguments on the .ME and .UE macros,Ingo Schwarze2018-08-141-0/+2
| | | | used for example in the ditroff(7) manual of the groff package
* preserve comments before .Dd when converting mdoc(7) to man(7)Ingo Schwarze2018-04-111-1/+9
| | | | with mandoc -Tman; suggested by Thomas Klausner <wiz at NetBSD>
* 1. Eliminate struct eqn, instead use the existing membersIngo Schwarze2017-07-081-2/+2
| | | | | | of struct roff_node which is allocated for each equation anyway. 2. Do not keep a list of equation parsers, one parser is enough. Minus fifty lines of code, no functional change.
* garbage collect unused enum member EQN_ROOTIngo Schwarze2017-07-071-3/+0
|
* The EQN_LISTONE box type is pointless.Ingo Schwarze2017-07-051-1/+0
| | | | | | Simplify by just using EQN_LIST with expectargs = 1. Noticed while investigating a bug report from bentley@. No functional change.
* Continue parser unification:Ingo Schwarze2017-04-241-6/+6
| | | | | | | | * 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[].
* In -Ttree output mode, show the BROKEN node flag andIngo Schwarze2017-02-101-0/+2
| | | | provide a -Onoval output option to show the unvalidated tree.
* show meta data for -Ttree outputIngo Schwarze2017-01-121-3/+27
|
* unify names of AST node flags; no change of cpp outputIngo Schwarze2017-01-101-6/+6
|
* Introduce flags NODE_NOSRC and NODE_NOPRT for AST nodes.Ingo Schwarze2017-01-101-0/+4
| | | | | | | | | Use them to mark generated nodes and nodes that shall not produce output. Let -Ttree output mode display these new flags. Use NODE_NOSRC for .Ar, .Mt, and .Pa default arguments. Use NODE_NOPRT for .Dd, .Dt, and .Os. These will help to make handling of text production macros more rigorous.
* To make the code more readable, delete 283 /* FALLTHROUGH */ commentsIngo Schwarze2015-10-121-5/+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.
* Show the flags MDOC_DELIMO, MDOC_DELIMC, MDOC_EOS, and MAN_EOS.Ingo Schwarze2015-09-261-7/+17
| | | | Drop the "block-" prefixes from the node type names.
* /* NOTREACHED */ after abort() is silly, delete itIngo Schwarze2015-09-261-4/+0
|
* Delete the wrapper functions mdoc_meta(), man_meta(), mdoc_node(),Ingo Schwarze2015-04-181-2/+2
| | | | | | man_node() from the mandoc(3) semi-public interface and the internal wrapper functions print_mdoc() and print_man() from the HTML formatters. Minus 60 lines of code, no functional change.
* Replace the structs mdoc and man by a unified struct roff_man.Ingo Schwarze2015-04-181-2/+2
| | | | | Almost completely mechanical, no functional change. Written on the train from Exeter to London returning from p2k15.
* Second step towards parser unification:Ingo Schwarze2015-04-021-4/+4
| | | | | | | | | Replace struct mdoc_node and struct man_node by a unified struct roff_node. To be able to use the tok member for both mdoc(7) and man(7) without defining all the macros in roff.h, sacrifice a tiny bit of type safety and make tok an int rather than an enum. Almost mechanical, no functional change. Written on the Eurostar from Bruxelles to London on the way to p2k15.
* First step towards parser unification:Ingo Schwarze2015-04-021-38/+39
| | | | | | Replace enum mdoc_type and enum man_type by a unified enum roff_type. Almost mechanical, no functional change. Written on the ICE train from Frankfurt to Bruxelles on the way to p2k15.
* Simplify by deleting the "lastline" member of struct mdoc_node.Ingo Schwarze2015-02-051-4/+1
| | | | Minus one struct member, minus 17 lines of code, no functional change.
* reduce indentation for better readabilityIngo Schwarze2015-02-031-12/+20
|
* Simplify by making many functions in the man(7) parser void,Ingo Schwarze2014-11-281-5/+0
| | | | and some cleanup; no functional change, minus 70 lines.
* show the {MDOC,MAN}_EQN node, it contains interesting information,Ingo Schwarze2014-10-201-10/+12
| | | | | in particular line and column numbers and flags; but hide the uninteresting EQN_ROOT box
* sync Copyright years after merge to OpenBSD; no code changeIngo Schwarze2014-10-101-1/+1
|
* Make eqn(7) -Ttree output more useful:Ingo Schwarze2014-10-101-8/+27
| | | | | | | * Reduce noise by not printing default attributes. * Print missing "top" and "bottom" attributes. * Print mnemonics, not code numbers for expression positions. * Do not print unused "pile" attribute.
* Re-write of eqn(7) parser and MathML output.Kristaps Dzonsons2014-10-101-2/+7
| | | | | | | | | | This adds parser-level support for the grammar described by the eqn second-edition technical paper, "Typesetting Mathematics — User's Guide" (Kernighan, Cherry). The reason for this re-write is the grouping rules, which were not possible given the existing implementation. The re-write has also considerably simplified the HTML (and, if it ever is completed, terminal) front-end.
* Make eqn tree output a bit more useful.Kristaps Dzonsons2014-09-281-2/+2
|
* 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.
* Change column display in -Ttree to be 1-based instead of 0-basedIngo Schwarze2014-07-021-3/+3
| | | | such that column numbers agree between messages and -Ttree.
* KNF: case (FOO): -> case FOO:, remove /* LINTED */ and /* ARGSUSED */,Ingo Schwarze2014-04-201-58/+53
| | | | | remove trailing whitespace and blanks before tabs, improve some indenting; no functional change
* To find out whether .TP head arguments are same-line or next-line arguments,Ingo Schwarze2014-03-081-2/+5
| | | | | | | | use the MAN_LINE flag instead of the man_node line member. This is required such that user-defined macros wrapping .TP work correctly. Issue found by Havard Eidnes in Tcl_NewStringObj(3), reported via the NetBSD bug tracking system and Thomas Klausner <wiz at NetBSD>.
* When deciding whether two consecutive macros are on the same input line,Ingo Schwarze2013-12-241-1/+5
| | | | | | | | 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.
* For some mdoc(7) macros, it is (unfortunately) semantically significantIngo Schwarze2013-09-151-2/+5
| | | | | | whether they are the first macro on the line or called by another macro. To help debugging, indicate this property "first macro on a new input line" by prefixing an asterisk to the line number in -Ttree output.
* Remove the variable sz because it's invariantly == 0,Ingo Schwarze2013-05-181-7/+2
| | | | | | | | | along with the dead code testing whether it's positive. Reported by Ulrich Spoerlein <uqs@spoerlein.net>, found by Coverity Scan CID 975717. While here, remove the now unused **params array as well, which Coverity apparently missed, at least it wasn't reported...
* forgotten Copyright bumps; no code changeIngo Schwarze2011-09-181-1/+1
| | | | found while syncing to OpenBSD
* Add matrix support. Also remove "above" notion, as all elements in aKristaps Dzonsons2011-07-231-22/+17
| | | | list are delimited by their "aboveness" and it's superfluous.
* Give lists their own eqn function.Kristaps Dzonsons2011-07-221-0/+9
|
* Complete eqn.7 parsing. Features all productions from the original 1975Kristaps Dzonsons2011-07-211-4/+7
| | | | | | | | CACM paper in an LR(1) parse (1 -> eqn_rewind()). Right now the code is a little jungly, but will clear up as I consolidate parse components. The AST structure will also be cleaned up, as right now it's pretty ad hoc (this won't change the parse itself). I added the mandoc_strndup() function will here.
* Support `size' constructs in eqn.7. Generalise mandoc_strontou to thisKristaps Dzonsons2011-07-211-3/+7
| | | | effect.
* Full support for eqn positionals (above, over, sup, sub, etc.).Kristaps Dzonsons2011-07-211-6/+6
|