1 /* $Id: roff.h,v 1.58 2017/07/08 14:51:05 schwarze Exp $ */
3 * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2013, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
36 SEC_IMPLEMENTATION
, /* IMPLEMENTATION NOTES */
158 /* MAN_fi; ignored in mdoc(7) */
188 /* MAN_in; ignored in mdoc(7) */
218 /* MAN_nf; ignored in mdoc(7) */
476 ROFF_NEXT_SIBLING
= 0,
481 * Indicates that a BODY's formatting has ended, but
482 * the scope is still open. Used for badly nested blocks.
486 ENDBODY_SPACE
/* Is broken: append a space. */
490 struct roff_node
*parent
; /* Parent AST node. */
491 struct roff_node
*child
; /* First child AST node. */
492 struct roff_node
*last
; /* Last child AST node. */
493 struct roff_node
*next
; /* Sibling AST node. */
494 struct roff_node
*prev
; /* Prior sibling AST node. */
495 struct roff_node
*head
; /* BLOCK */
496 struct roff_node
*body
; /* BLOCK/ENDBODY */
497 struct roff_node
*tail
; /* BLOCK */
498 struct mdoc_arg
*args
; /* BLOCK/ELEM */
499 union mdoc_data
*norm
; /* Normalized arguments. */
500 char *string
; /* TEXT */
501 const struct tbl_span
*span
; /* TBL */
502 struct eqn_box
*eqn
; /* EQN */
503 int line
; /* Input file line number. */
504 int pos
; /* Input file column number. */
506 #define NODE_VALID (1 << 0) /* Has been validated. */
507 #define NODE_ENDED (1 << 1) /* Gone past body end mark. */
508 #define NODE_EOS (1 << 2) /* At sentence boundary. */
509 #define NODE_LINE (1 << 3) /* First macro/text on line. */
510 #define NODE_SYNPRETTY (1 << 4) /* SYNOPSIS-style formatting. */
511 #define NODE_BROKEN (1 << 5) /* Must validate parent when ending. */
512 #define NODE_DELIMO (1 << 6)
513 #define NODE_DELIMC (1 << 7)
514 #define NODE_NOSRC (1 << 8) /* Generated node, not in input file. */
515 #define NODE_NOPRT (1 << 9) /* Shall not print anything. */
516 int prev_font
; /* Before entering this node. */
517 int aux
; /* Decoded node data, type-dependent. */
518 enum roff_tok tok
; /* Request or macro ID. */
519 enum roff_type type
; /* AST node type. */
520 enum roff_sec sec
; /* Current named section. */
521 enum mdoc_endbody end
; /* BODY */
525 char *msec
; /* Manual section, usually a digit. */
526 char *vol
; /* Manual volume title. */
527 char *os
; /* Operating system. */
528 char *arch
; /* Machine architecture. */
529 char *title
; /* Manual title, usually CAPS. */
530 char *name
; /* Leading manual name. */
531 char *date
; /* Normalized date. */
532 int hasbody
; /* Document is not empty. */
533 int rcsids
; /* Bits indexed by enum mandoc_os. */
534 enum mandoc_os os_e
; /* Operating system. */
538 struct roff_meta meta
; /* Document meta-data. */
539 struct mparse
*parse
; /* Parse pointer. */
540 struct roff
*roff
; /* Roff parser state data. */
541 struct ohash
*mdocmac
; /* Mdoc macro lookup table. */
542 struct ohash
*manmac
; /* Man macro lookup table. */
543 const char *os_s
; /* Default operating system. */
544 struct roff_node
*first
; /* The first node parsed. */
545 struct roff_node
*last
; /* The last node parsed. */
546 struct roff_node
*last_es
; /* The most recent Es node. */
547 int quick
; /* Abort parse early. */
548 int flags
; /* Parse flags. */
549 #define MDOC_LITERAL (1 << 1) /* In a literal scope. */
550 #define MDOC_PBODY (1 << 2) /* In the document body. */
551 #define MDOC_NEWLINE (1 << 3) /* First macro/text in a line. */
552 #define MDOC_PHRASE (1 << 4) /* In a Bl -column phrase. */
553 #define MDOC_PHRASELIT (1 << 5) /* Literal within a phrase. */
554 #define MDOC_FREECOL (1 << 6) /* `It' invocation should close. */
555 #define MDOC_SYNOPSIS (1 << 7) /* SYNOPSIS-style formatting. */
556 #define MDOC_KEEP (1 << 8) /* In a word keep. */
557 #define MDOC_SMOFF (1 << 9) /* Spacing is off. */
558 #define MDOC_NODELIMC (1 << 10) /* Disable closing delimiter handling. */
559 #define MAN_ELINE (1 << 11) /* Next-line element scope. */
560 #define MAN_BLINE (1 << 12) /* Next-line block scope. */
561 #define MDOC_PHRASEQF (1 << 13) /* Quote first word encountered. */
562 #define MDOC_PHRASEQL (1 << 14) /* Quote last word of this phrase. */
563 #define MDOC_PHRASEQN (1 << 15) /* Quote first word of the next phrase. */
564 #define MAN_LITERAL MDOC_LITERAL
565 #define MAN_NEWLINE MDOC_NEWLINE
566 enum roff_macroset macroset
; /* Kind of high-level macros used. */
567 enum roff_sec lastsec
; /* Last section seen. */
568 enum roff_sec lastnamed
; /* Last standard section seen. */
569 enum roff_next next
; /* Where to put the next node. */
572 extern const char *const *roff_name
;
575 void deroff(char **, const struct roff_node
*);
576 struct ohash
*roffhash_alloc(enum roff_tok
, enum roff_tok
);
577 enum roff_tok
roffhash_find(struct ohash
*, const char *, size_t);
578 void roffhash_free(struct ohash
*);
579 void roff_validate(struct roff_man
*);