]>
git.cameronkatri.com Git - mandoc.git/blob - roff.h
59fd8ba9fded79cee9dbd5fd2c03a8fc6fb1fb28
1 /* $Id: roff.h,v 1.43 2017/05/04 17:48:29 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 */
150 /* MAN_fi; ignored in mdoc(7) */
159 /* MAN_ft; ignored in mdoc(7) */
181 /* MAN_in; ignored in mdoc(7) */
199 /* MAN_ll, MDOC_ll */
213 /* MAN_nf; ignored in mdoc(7) */
264 /* MAN_sp, MDOC_sp */
478 ROFF_NEXT_SIBLING
= 0,
483 * Indicates that a BODY's formatting has ended, but
484 * the scope is still open. Used for badly nested blocks.
488 ENDBODY_SPACE
/* Is broken: append a space. */
492 struct roff_node
*parent
; /* Parent AST node. */
493 struct roff_node
*child
; /* First child AST node. */
494 struct roff_node
*last
; /* Last child AST node. */
495 struct roff_node
*next
; /* Sibling AST node. */
496 struct roff_node
*prev
; /* Prior sibling AST node. */
497 struct roff_node
*head
; /* BLOCK */
498 struct roff_node
*body
; /* BLOCK/ENDBODY */
499 struct roff_node
*tail
; /* BLOCK */
500 struct mdoc_arg
*args
; /* BLOCK/ELEM */
501 union mdoc_data
*norm
; /* Normalized arguments. */
502 char *string
; /* TEXT */
503 const struct tbl_span
*span
; /* TBL */
504 const struct eqn
*eqn
; /* EQN */
505 int line
; /* Input file line number. */
506 int pos
; /* Input file column number. */
508 #define NODE_VALID (1 << 0) /* Has been validated. */
509 #define NODE_ENDED (1 << 1) /* Gone past body end mark. */
510 #define NODE_EOS (1 << 2) /* At sentence boundary. */
511 #define NODE_LINE (1 << 3) /* First macro/text on line. */
512 #define NODE_SYNPRETTY (1 << 4) /* SYNOPSIS-style formatting. */
513 #define NODE_BROKEN (1 << 5) /* Must validate parent when ending. */
514 #define NODE_DELIMO (1 << 6)
515 #define NODE_DELIMC (1 << 7)
516 #define NODE_NOSRC (1 << 8) /* Generated node, not in input file. */
517 #define NODE_NOPRT (1 << 9) /* Shall not print anything. */
518 int prev_font
; /* Before entering this node. */
519 int aux
; /* Decoded node data, type-dependent. */
520 enum roff_tok tok
; /* Request or macro ID. */
521 enum roff_type type
; /* AST node type. */
522 enum roff_sec sec
; /* Current named section. */
523 enum mdoc_endbody end
; /* BODY */
527 char *msec
; /* Manual section, usually a digit. */
528 char *vol
; /* Manual volume title. */
529 char *os
; /* Operating system. */
530 char *arch
; /* Machine architecture. */
531 char *title
; /* Manual title, usually CAPS. */
532 char *name
; /* Leading manual name. */
533 char *date
; /* Normalized date. */
534 int hasbody
; /* Document is not empty. */
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 *defos
; /* 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
*);