From 5ed742dc63b34ff435a2b04d4e14fcb6081d49b0 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Thu, 16 Oct 2014 01:11:20 +0000 Subject: 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. --- eqn.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'eqn.c') diff --git a/eqn.c b/eqn.c index 1cc0874a..e36df60a 100644 --- a/eqn.c +++ b/eqn.c @@ -1,4 +1,4 @@ -/* $Id: eqn.c,v 1.53 2014/10/12 20:08:58 schwarze Exp $ */ +/* $Id: eqn.c,v 1.54 2014/10/16 01:11:20 schwarze Exp $ */ /* * Copyright (c) 2011, 2014 Kristaps Dzonsons * Copyright (c) 2014 Ingo Schwarze @@ -587,6 +587,30 @@ eqn_box_makebinary(struct eqn_node *ep, return(newb); } +/* + * 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. */ @@ -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, -- cgit v1.2.3-56-ge451