summaryrefslogtreecommitdiffstats
path: root/eqn.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
commit1355393bef46aede0de7305138dd0b3b3dab287c (patch)
treeaa6c81705b9c2da774d6f10414fe170e7b76162d /eqn.c
parentb53f13bc3058beab88ad98e78c0ce6c0ff5be2a0 (diff)
downloadmandoc-1355393bef46aede0de7305138dd0b3b3dab287c.tar.gz
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 'eqn.c')
-rw-r--r--eqn.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/eqn.c b/eqn.c
index 64f2348d..19bd6910 100644
--- a/eqn.c
+++ b/eqn.c
@@ -588,6 +588,30 @@ eqn_box_makebinary(struct eqn_node *ep,
}
/*
+ * Parse the "delim" control statement.
+ */
+static void
+eqn_delim(struct eqn_node *ep)
+{
+ const char *start;
+ size_t sz;
+
+ if ((start = eqn_nextrawtok(ep, &sz)) == NULL)
+ mandoc_msg(MANDOCERR_REQ_EMPTY, ep->parse,
+ ep->eqn.ln, ep->eqn.pos, "delim");
+ else if (strncmp(start, "off", 3) == 0)
+ ep->delim = 0;
+ else if (strncmp(start, "on", 2) == 0) {
+ if (ep->odelim && ep->cdelim)
+ ep->delim = 1;
+ } else if (start[1] != '\0') {
+ ep->odelim = start[0];
+ ep->cdelim = start[1];
+ ep->delim = 1;
+ }
+}
+
+/*
* Undefine a previously-defined string.
*/
static int
@@ -698,6 +722,8 @@ this_tok:
EQN_MSG(MANDOCERR_EQNEOF, ep);
break;
case (EQN_TOK_DELIM):
+ eqn_delim(ep);
+ break;
case (EQN_TOK_GFONT):
if (eqn_nextrawtok(ep, NULL) == NULL)
mandoc_msg(MANDOCERR_REQ_EMPTY, ep->parse,