summaryrefslogtreecommitdiffstats
path: root/eqn_html.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-10-12 19:31:41 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-10-12 19:31:41 +0000
commit3aae5aea6108aec8f9c8d9e61ef797f5291a0c60 (patch)
tree10b6c19833cb61eade9dbb7d75c53a1dc079c393 /eqn_html.c
parentbb74cbfe07e7341a1b5980e1331be5009b5eca0e (diff)
downloadmandoc-3aae5aea6108aec8f9c8d9e61ef797f5291a0c60.tar.gz
Improve error handling in the eqn(7) parser.
Get rid of the first fatal error, MANDOCERR_EQNSYNT. In eqn(7), there is no need to be bug-compatible with groff, so there is no need to abondon the whole equation in case of a syntax error. In particular: * Skip "back", "delim", "down", "fwd", "gfont", "gsize", "left", "right", "size", and "up" without arguments. * Skip "gsize" and "size" with a non-numeric argument. * Skip closing delimiters that are not open. * Skip "above" outside piles. * For diacritic marks and binary operators without a left operand, default to an empty box. * Let piles and matrices take one argument rather than insisting on a braced list. Let HTML output handle that, too. * When rewinding, if the root box is guaranteed to match the termination condition, no error handling is needed.
Diffstat (limited to 'eqn_html.c')
-rw-r--r--eqn_html.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/eqn_html.c b/eqn_html.c
index 22881b72..f4bd3482 100644
--- a/eqn_html.c
+++ b/eqn_html.c
@@ -47,10 +47,12 @@ eqn_box(struct html *p, const struct eqn_box *bp)
if (EQN_MATRIX == bp->type) {
if (NULL == bp->first)
goto out;
- assert(EQN_LIST == bp->first->type);
+ if (EQN_LIST != bp->first->type) {
+ eqn_box(p, bp->first);
+ goto out;
+ }
if (NULL == (parent = bp->first->first))
goto out;
- assert(EQN_PILE == parent->type);
/* Estimate the number of rows, first. */
if (NULL == (child = parent->first))
goto out;
@@ -126,8 +128,10 @@ eqn_box(struct html *p, const struct eqn_box *bp)
if (EQN_PILE == bp->type) {
assert(NULL == post);
- post = print_otag(p, TAG_MTABLE, 0, NULL);
- } else if (bp->parent && EQN_PILE == bp->parent->type) {
+ if (bp->first != NULL && bp->first->type == EQN_LIST)
+ post = print_otag(p, TAG_MTABLE, 0, NULL);
+ } else if (bp->type == EQN_LIST &&
+ bp->parent && bp->parent->type == EQN_PILE) {
assert(NULL == post);
post = print_otag(p, TAG_MTR, 0, NULL);
print_otag(p, TAG_MTD, 0, NULL);