1 /* $Id: roff.h,v 1.74 2020/04/08 11:56:03 schwarze Exp $ */
3 * Copyright (c) 2013-2015, 2017-2020 Ingo Schwarze <schwarze@openbsd.org>
4 * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
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.
18 * Common data types for all syntax trees and related functions.
40 SEC_IMPLEMENTATION, /* IMPLEMENTATION NOTES */
194 /* MAN_in; ignored in mdoc(7) */
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. */
498 struct roff_node *parent; /* Parent AST node. */
499 struct roff_node *child; /* First child AST node. */
500 struct roff_node *last; /* Last child AST node. */
501 struct roff_node *next; /* Sibling AST node. */
502 struct roff_node *prev; /* Prior sibling AST node. */
503 struct roff_node *head; /* BLOCK */
504 struct roff_node *body; /* BLOCK/ENDBODY */
505 struct roff_node *tail; /* BLOCK */
506 struct mdoc_arg *args; /* BLOCK/ELEM */
507 union mdoc_data *norm; /* Normalized arguments. */
508 char *string; /* TEXT */
509 char *tag; /* For less(1) :t and HTML id=. */
510 struct tbl_span *span; /* TBL */
511 struct eqn_box *eqn; /* EQN */
512 int line; /* Input file line number. */
513 int pos; /* Input file column number. */
515 #define NODE_VALID (1 << 0) /* Has been validated. */
516 #define NODE_ENDED (1 << 1) /* Gone past body end mark. */
517 #define NODE_BROKEN (1 << 2) /* Must validate parent when ending. */
518 #define NODE_LINE (1 << 3) /* First macro/text on line. */
519 #define NODE_DELIMO (1 << 4)
520 #define NODE_DELIMC (1 << 5)
521 #define NODE_EOS (1 << 6) /* At sentence boundary. */
522 #define NODE_SYNPRETTY (1 << 7) /* SYNOPSIS-style formatting. */
523 #define NODE_NOFILL (1 << 8) /* Fill mode switched off. */
524 #define NODE_NOSRC (1 << 9) /* Generated node, not in input file. */
525 #define NODE_NOPRT (1 << 10) /* Shall not print anything. */
526 #define NODE_ID (1 << 11) /* Target for deep linking. */
527 #define NODE_HREF (1 << 12) /* Link to another place in this page. */
528 int prev_font; /* Before entering this node. */
529 int aux; /* Decoded node data, type-dependent. */
530 enum roff_tok tok; /* Request or macro ID. */
531 enum roff_type type; /* AST node type. */
532 enum roff_sec sec; /* Current named section. */
533 enum mdoc_endbody end; /* BODY */
537 struct roff_node *first; /* The first node parsed. */
538 char *msec; /* Manual section, usually a digit. */
539 char *vol; /* Manual volume title. */
540 char *os; /* Operating system. */
541 char *arch; /* Machine architecture. */
542 char *title; /* Manual title, usually CAPS. */
543 char *name; /* Leading manual name. */
544 char *date; /* Normalized date. */
545 char *sodest; /* .so target file name or NULL. */
546 int hasbody; /* Document is not empty. */
547 int rcsids; /* Bits indexed by enum mandoc_os. */
548 enum mandoc_os os_e; /* Operating system. */
549 enum roff_macroset macroset; /* Kind of high-level macros used. */
552 extern const char *const *roff_name;
555 int arch_valid(const char *, enum mandoc_os);
556 void deroff(char **, const struct roff_node *);
557 struct roff_node *roff_node_child(struct roff_node *);
558 struct roff_node *roff_node_next(struct roff_node *);
559 struct roff_node *roff_node_prev(struct roff_node *);
560 int roff_node_transparent(struct roff_node *);
561 int roff_tok_transparent(enum roff_tok);