aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-10-16 01:11:20 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-10-16 01:11:20 +0000
commit5ed742dc63b34ff435a2b04d4e14fcb6081d49b0 (patch)
treefa3b2b20e34566f744745409e53d12cb65f8bc37 /mdoc.c
parent191186556e8df468bec99ae47cd09817e9d288a0 (diff)
downloadmandoc-5ed742dc63b34ff435a2b04d4e14fcb6081d49b0.tar.gz
mandoc-5ed742dc63b34ff435a2b04d4e14fcb6081d49b0.tar.zst
mandoc-5ed742dc63b34ff435a2b04d4e14fcb6081d49b0.zip
Implement in-line equations, much needed by Xenocara manuals.
Put the steering into the roff parser rather than into the mdoc parser such that it works for all macro languages and on both text and macro lines. Line breaks and blank characters generated before and after in-line equations are not perfect yet, but let's do one thing at a time.
Diffstat (limited to 'mdoc.c')
-rw-r--r--mdoc.c59
1 files changed, 1 insertions, 58 deletions
diff --git a/mdoc.c b/mdoc.c
index 205a02b0..118fdcb5 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.225 2014/09/06 23:24:32 schwarze Exp $ */
+/* $Id: mdoc.c,v 1.226 2014/10/16 01:11:20 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -91,9 +91,6 @@ static struct mdoc_node *node_alloc(struct mdoc *, int, int,
enum mdoct, enum mdoc_type);
static int node_append(struct mdoc *,
struct mdoc_node *);
-#if 0
-static int mdoc_preptext(struct mdoc *, int, char *, int);
-#endif
static int mdoc_ptext(struct mdoc *, int, char *, int);
static int mdoc_pmacro(struct mdoc *, int, char *, int);
@@ -609,60 +606,6 @@ mdoc_node_relink(struct mdoc *mdoc, struct mdoc_node *p)
return(node_append(mdoc, p));
}
-#if 0
-/*
- * Pre-treat a text line.
- * Text lines can consist of equations, which must be handled apart from
- * the regular text.
- * Thus, use this function to step through a line checking if it has any
- * equations embedded in it.
- * This must handle multiple equations AND equations that do not end at
- * the end-of-line, i.e., will re-enter in the next roff parse.
- */
-static int
-mdoc_preptext(struct mdoc *mdoc, int line, char *buf, int offs)
-{
- char *start, *end;
- char delim;
-
- while ('\0' != buf[offs]) {
- /* Mark starting position if eqn is set. */
- start = NULL;
- if ('\0' != (delim = roff_eqndelim(mdoc->roff)))
- if (NULL != (start = strchr(buf + offs, delim)))
- *start++ = '\0';
-
- /* Parse text as normal. */
- if ( ! mdoc_ptext(mdoc, line, buf, offs))
- return(0);
-
- /* Continue only if an equation exists. */
- if (NULL == start)
- break;
-
- /* Read past the end of the equation. */
- offs += start - (buf + offs);
- assert(start == &buf[offs]);
- if (NULL != (end = strchr(buf + offs, delim))) {
- *end++ = '\0';
- while (' ' == *end)
- end++;
- }
-
- /* Parse the equation itself. */
- roff_openeqn(mdoc->roff, NULL, line, offs, buf);
-
- /* Process a finished equation? */
- if (roff_closeeqn(mdoc->roff))
- if ( ! mdoc_addeqn(mdoc, roff_eqn(mdoc->roff)))
- return(0);
- offs += (end - (buf + offs));
- }
-
- return(1);
-}
-#endif
-
/*
* Parse free-form text, that is, a line that does not begin with the
* control character.