-/* $Id: eqn.c,v 1.73 2017/07/05 15:03:27 schwarze Exp $ */
+/* $Id: eqn.c,v 1.74 2017/07/06 00:19:54 schwarze Exp $ */
/*
* Copyright (c) 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
ep->gsize = size;
break;
}
+ while (parent->args == parent->expectargs)
+ parent = parent->parent;
parent = eqn_box_alloc(ep, parent);
parent->type = EQN_LIST;
parent->expectargs = 1;
cur->type = EQN_TEXT;
cur->text = mandoc_strdup("");
}
- /* Handle the "subsup" and "fromto" positions. */
- if (EQN_TOK_SUP == tok && parent->pos == EQNPOS_SUB) {
+ while (parent->expectargs == 1 && parent->args == 1)
+ parent = parent->parent;
+ if (tok == EQN_TOK_FROM || tok == EQN_TOK_TO) {
+ for (cur = parent; cur != NULL; cur = cur->parent)
+ if (cur->pos == EQNPOS_SUB ||
+ cur->pos == EQNPOS_SUP ||
+ cur->pos == EQNPOS_SUBSUP ||
+ cur->pos == EQNPOS_SQRT ||
+ cur->pos == EQNPOS_OVER)
+ break;
+ if (cur != NULL)
+ parent = cur->parent;
+ }
+ if (tok == EQN_TOK_SUP && parent->pos == EQNPOS_SUB) {
parent->expectargs = 3;
parent->pos = EQNPOS_SUBSUP;
break;
}
- if (EQN_TOK_TO == tok && parent->pos == EQNPOS_FROM) {
+ if (tok == EQN_TOK_TO && parent->pos == EQNPOS_FROM) {
parent->expectargs = 3;
parent->pos = EQNPOS_FROMTO;
break;
cur->type = EQN_TEXT;
cur->text = mandoc_strdup("");
}
+ while (parent->args == parent->expectargs)
+ parent = parent->parent;
while (EQN_SUBEXPR == parent->type)
parent = parent->parent;
parent = eqn_box_makebinary(ep, EQNPOS_OVER, parent);
parent = split->parent;
break;
}
- /*
- * Post-process list status.
- */
- while (parent->type == EQN_LIST &&
- parent->expectargs == 1 &&
- parent->args == 1)
- parent = parent->parent;
break;
default:
abort();
-/* $Id: eqn_term.c,v 1.10 2017/07/05 15:03:27 schwarze Exp $ */
+/* $Id: eqn_term.c,v 1.11 2017/07/06 00:19:54 schwarze Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
if (bp->font != EQNFONT_NONE)
term_fontpop(p);
- if ((bp->type == EQN_LIST && bp->expectargs > 1) ||
- (bp->type == EQN_PILE && (bp->prev || bp->next)) ||
- (bp->parent != NULL && bp->parent->pos == EQNPOS_SQRT)) {
- p->flags |= TERMP_NOSPACE;
- term_word(p, bp->right != NULL ? bp->right : ")");
- if (bp->parent->type == EQN_SUBEXPR && bp->next != NULL)
- p->flags |= TERMP_NOSPACE;
- }
-
if (bp->top != NULL) {
p->flags |= TERMP_NOSPACE;
term_word(p, bp->top);
p->flags |= TERMP_NOSPACE;
term_word(p, "_");
}
+ if ((bp->type == EQN_LIST && bp->expectargs > 1) ||
+ (bp->type == EQN_PILE && (bp->prev || bp->next)) ||
+ (bp->parent != NULL && bp->parent->pos == EQNPOS_SQRT)) {
+ p->flags |= TERMP_NOSPACE;
+ term_word(p, bp->right != NULL ? bp->right : ")");
+ if (bp->parent->type == EQN_SUBEXPR && bp->next != NULL)
+ p->flags |= TERMP_NOSPACE;
+ }
}
-# $OpenBSD: Makefile,v 1.2 2015/01/01 15:34:43 schwarze Exp $
+# $OpenBSD: Makefile,v 1.3 2017/07/06 00:08:52 schwarze Exp $
-REGRESS_TARGETS = basic noarg
-HTML_TARGETS = basic noarg
+REGRESS_TARGETS = basic noarg precedence
+HTML_TARGETS = basic noarg precedence
.include <bsd.regress.mk>
--- /dev/null
+.\" $OpenBSD: precedence.in,v 1.1 2017/07/06 00:08:52 schwarze Exp $
+.Dd $Mdocdate: July 6 2017 $
+.Dt SUBSUP-PRECEDENCE 1
+.Os
+.Sh NAME
+.Nm subsup-precedence
+.Nd precedence of subscripts and superscripts
+.Sh DESCRIPTION
+.ps 36
+initial text
+.EQ
+X from a under to c hat ; roman X from bold a to italic c ;
+X sub 1 sup 2 from a sub c sup e to o sub r sup s
+.EN
+final text
--- /dev/null
+SUBSUP-PRECEDENCE(1) General Commands Manual SUBSUP-PRECEDENCE(1)
+
+N\bNA\bAM\bME\bE
+ s\bsu\bub\bbs\bsu\bup\bp-\b-p\bpr\bre\bec\bce\bed\bde\ben\bnc\bce\be - precedence of subscripts and superscripts
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ initial text _\bX__\ba_^_\bc^ ; X_a\ba^_\bc ; _\bX_1^2__\ba__\bc^_\be^_\bo__\br^_\bs final text
+
+OpenBSD July 6, 2017 OpenBSD
--- /dev/null
+<mrow><munderover><mi>X</mi><munder><mi>a</mi><mo>_</mo></munder><mover><mi>c</mi><mo>^</mo></mover></munderover><mo>;</mo><munderover><mrow><mi fontstyle="normal">X</mi></mrow><mrow><mi fontweight="bold">a</mi></mrow><mrow><mi>c</mi></mrow></munderover><mo>;</mo><munderover><msubsup><mi>X</mi><mn>1</mn><mn>2</mn></msubsup><msubsup><mi>a</mi><mi>c</mi><mi>e</mi></msubsup><msubsup><mi>o</mi><mi>r</mi><mi>s</mi></msubsup></munderover></mrow>
-.\" $OpenBSD: precedence.in,v 1.2 2017/07/04 14:53:23 schwarze Exp $
-.Dd $Mdocdate: July 4 2017 $
+.\" $OpenBSD: precedence.in,v 1.3 2017/07/06 00:08:52 schwarze Exp $
+.Dd $Mdocdate: July 6 2017 $
.Dt OVER-PRECEDENCE 1
.Os
.Sh NAME
.Sh DESCRIPTION
initial text
.EQ
-1 + x + x sup 2 over 2 + x sup 3 over { 2 * 3 }
+1 + x + x sup 2 over 2 + x sup 3 over { 2 * 3 } ;
+a hat over c tilde ; bold a over bold c ; sqrt a over sqrt c
.EN
final text
o\bov\bve\ber\br-\b-p\bpr\bre\bec\bce\bed\bde\ben\bnc\bce\be - precedence of the fraction operator
D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
- initial text 1 + _\bx + _\bx^2/2 + _\bx^3/(2 * 3) final text
+ initial text 1 + _\bx + _\bx^2/2 + _\bx^3/(2 * 3) ; _\ba^/_\bc~ ; a\ba/c\bc ; sqrt(_\ba)/sqrt(_\bc)
+ final text
-OpenBSD July 4, 2017 OpenBSD
+OpenBSD July 6, 2017 OpenBSD
-<mrow><mn>1</mn><mo>+</mo><mi>x</mi><mo>+</mo><mfrac><msup><mi>x</mi><mn>2</mn></msup><mn>2</mn></mfrac><mo>+</mo><mfrac><msup><mi>x</mi><mn>3</mn></msup><mrow><mn>2</mn><mo>*</mo><mn>3</mn></mrow></mfrac></mrow>
+<mrow><mn>1</mn><mo>+</mo><mi>x</mi><mo>+</mo><mfrac><msup><mi>x</mi><mn>2</mn></msup><mn>2</mn></mfrac><mo>+</mo><mfrac><msup><mi>x</mi><mn>3</mn></msup><mrow><mn>2</mn><mo>*</mo><mn>3</mn></mrow></mfrac><mo>;</mo><mfrac><mover><mi>a</mi><mo>^</mo></mover><mover><mi>c</mi><mo>~</mo></mover></mfrac><mo>;</mo><mfrac><mrow><mi fontweight="bold">a</mi></mrow><mrow><mi fontweight="bold">c</mi></mrow></mfrac><mo>;</mo><mfrac><msqrt><mi>a</mi></msqrt><msqrt><mi>c</mi></msqrt></mfrac></mrow>
-# $OpenBSD: Makefile,v 1.2 2015/01/01 15:34:43 schwarze Exp $
+# $OpenBSD: Makefile,v 1.3 2017/07/06 00:08:52 schwarze Exp $
-REGRESS_TARGETS = combine noarg sub_group
-HTML_TARGETS = combine noarg sub_group
+REGRESS_TARGETS = combine noarg precedence sub_group
+HTML_TARGETS = combine noarg precedence sub_group
.include <bsd.regress.mk>
--- /dev/null
+.\" $OpenBSD: precedence.in,v 1.1 2017/07/06 00:08:52 schwarze Exp $
+.Dd $Mdocdate: July 6 2017 $
+.Dt SUBSUP-PRECEDENCE 1
+.Os
+.Sh NAME
+.Nm subsup-precedence
+.Nd precedence of subscripts and superscripts
+.Sh DESCRIPTION
+initial text
+.EQ
+x hat sub 1 under sup 2 bar + e tilde sup x hat sub s dyad ;
+roman I sub bold I sup italic I + roman I sup bold I sub italic I
+.EN
+final text
--- /dev/null
+SUBSUP-PRECEDENCE(1) General Commands Manual SUBSUP-PRECEDENCE(1)
+
+N\bNA\bAM\bME\bE
+ s\bsu\bub\bbs\bsu\bup\bp-\b-p\bpr\bre\bec\bce\bed\bde\ben\bnc\bce\be - precedence of subscripts and superscripts
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ initial text _\bx^_1_^2 + _\be~^_\bx^__\bs<-> ; I_I\bI^_\bI + I^I\bI__\bI final text
+
+OpenBSD July 6, 2017 OpenBSD
--- /dev/null
+<mrow><msubsup><mover><mi>x</mi><mo>^</mo></mover><munder><mn>1</mn><mo>_</mo></munder><mover><mn>2</mn><mo></mo></mover></msubsup><mo>+</mo><msup><mover><mi>e</mi><mo>~</mo></mover><msub><mover><mi>x</mi><mo>^</mo></mover><mover><mi>s</mi><mo>↔</mo></mover></msub></msup><mo>;</mo><msubsup><mrow><mi fontstyle="normal">I</mi></mrow><mrow><mi fontweight="bold">I</mi></mrow><mrow><mi>I</mi></mrow></msubsup><mo>+</mo><msup><mrow><mi fontstyle="normal">I</mi></mrow><msub><mrow><mi fontweight="bold">I</mi></mrow><mrow><mi>I</mi></mrow></msub></msup></mrow>
-.\" $OpenBSD: bold.in,v 1.2 2017/07/04 14:53:23 schwarze Exp $
-.Dd $Mdocdate: July 4 2017 $
+.\" $OpenBSD: bold.in,v 1.3 2017/07/06 00:08:52 schwarze Exp $
+.Dd $Mdocdate: July 6 2017 $
.Dt UNARY-BOLD 1
.Os
.Sh NAME
.Sh DESCRIPTION
initial text
.EQ
-bold { sin "sin" }
+bold { sin "sin" } "text" bold x hat
.EN
final text
u\bun\bna\bar\bry\by-\b-b\bbo\bol\bld\bd - font handling in bold boxes
D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
- initial text (\b(sin s\bsi\bin\bn)\b) final text
+ initial text (\b(sin s\bsi\bin\bn)\b) _\bt_\be_\bx_\bt x\bx^\b^ final text
-OpenBSD July 4, 2017 OpenBSD
+OpenBSD July 6, 2017 OpenBSD
-<mrow><mrow><mrow><mi>sin</mi><mi fontweight="bold">sin</mi></mrow></mrow></mrow>
+<mrow><mrow><mrow><mi>sin</mi><mi fontweight="bold">sin</mi></mrow></mrow><mi fontstyle="italic">text</mi><mrow><mover><mi fontweight="bold">x</mi><mo>^</mo></mover></mrow></mrow>
-.\" $OpenBSD: diacrit.in,v 1.2 2017/07/04 14:53:23 schwarze Exp $
-.Dd $Mdocdate: July 4 2017 $
+.\" $OpenBSD: diacrit.in,v 1.3 2017/07/06 00:08:52 schwarze Exp $
+.Dd $Mdocdate: July 6 2017 $
.Dt UNARY-DIACRIT 1
.Os
.Sh NAME
.EQ
x dot x dotdot x hat x tilde x vec x dyad
{ x + y } bar { x + y } under
+x tilde hat
.EN
final text
u\bun\bna\bar\bry\by-\b-d\bdi\bia\bac\bcr\bri\bit\bt - diacritical marks in equations
D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
- initial text _\bx. _\bx" _\bx^ _\bx~ _\bx-> _\bx<-> (_\bx + _\by) (_\bx + _\by)_ final text
+ initial text _\bx. _\bx" _\bx^ _\bx~ _\bx-> _\bx<-> (_\bx + _\by) (_\bx + _\by)_ _\bx~^ final text
-OpenBSD July 4, 2017 OpenBSD
+OpenBSD July 6, 2017 OpenBSD
-<mrow><mover><mi>x</mi><mo>˙</mo></mover><mover><mi>x</mi><mo>¨</mo></mover><mover><mi>x</mi><mo>^</mo></mover><mover><mi>x</mi><mo>~</mo></mover><mover><mi>x</mi><mo>→</mo></mover><mover><mi>x</mi><mo>↔</mo></mover><mover><mrow><mi>x</mi><mo>+</mo><mi>y</mi></mrow><mo></mo></mover><munder><mrow><mi>x</mi><mo>+</mo><mi>y</mi></mrow><mo>_</mo></munder></mrow>
+<mrow><mover><mi>x</mi><mo>˙</mo></mover><mover><mi>x</mi><mo>¨</mo></mover><mover><mi>x</mi><mo>^</mo></mover><mover><mi>x</mi><mo>~</mo></mover><mover><mi>x</mi><mo>→</mo></mover><mover><mi>x</mi><mo>↔</mo></mover><mover><mrow><mi>x</mi><mo>+</mo><mi>y</mi></mrow><mo></mo></mover><munder><mrow><mi>x</mi><mo>+</mo><mi>y</mi></mrow><mo>_</mo></munder><mover><mover><mi>x</mi><mo>~</mo></mover><mo>^</mo></mover></mrow>
-.\" $OpenBSD: sqrt.in,v 1.4 2017/07/04 14:53:23 schwarze Exp $
-.Dd $Mdocdate: July 4 2017 $
+.\" $OpenBSD: sqrt.in,v 1.5 2017/07/06 00:08:52 schwarze Exp $
+.Dd $Mdocdate: July 6 2017 $
.Dt UNARY-SQRT 1
.Os
.Sh NAME
.Sh DESCRIPTION
initial text
.EQ
-r = sqrt { x sup 2 + y sup 2 } + sqrt a+b + sqrt { } + sqrt
+r = sqrt { x sup 2 + y sup 2 } + sqrt a+b + sqrt x hat + sqrt { } + sqrt
.EN
final text
u\bun\bna\bar\bry\by-\b-s\bsq\bqr\brt\bt - square root
D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
- initial text _\br = sqrt(_\bx^2 + _\by^2) + sqrt(_\ba + _\bb) + sqrt() + sqrt final text
+ initial text _\br = sqrt(_\bx^2 + _\by^2) + sqrt(_\ba + _\bb) + sqrt(_\bx^) + sqrt() + sqrt
+ final text
-OpenBSD July 4, 2017 OpenBSD
+OpenBSD July 6, 2017 OpenBSD
-<mrow><mi>r</mi><mo>=</mo><msqrt><mrow><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><msup><mi>y</mi><mn>2</mn></msup></mrow></msqrt><mo>+</mo><msqrt><mrow><mi>a</mi><mo>+</mo><mi>b</mi></mrow></msqrt><mo>+</mo><msqrt><mrow></mrow></msqrt><mo>+</mo><msqrt></msqrt></mrow>
+<mrow><mi>r</mi><mo>=</mo><msqrt><mrow><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><msup><mi>y</mi><mn>2</mn></msup></mrow></msqrt><mo>+</mo><msqrt><mrow><mi>a</mi><mo>+</mo><mi>b</mi></mrow></msqrt><mo>+</mo><msqrt><mover><mi>x</mi><mo>^</mo></mover></msqrt><mo>+</mo><msqrt><mrow></mrow></msqrt><mo>+</mo><msqrt></msqrt></mrow>