From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from scc-mailout-kit-02.scc.kit.edu (scc-mailout-kit-02.scc.kit.edu [129.13.231.82]) by fantadrom.bsd.lv (OpenSMTPD) with ESMTP id a07a62e7 for ; Wed, 21 Jun 2017 19:37:06 -0500 (EST) Received: from asta-nat.asta.uni-karlsruhe.de ([172.22.63.82] helo=hekate.usta.de) by scc-mailout-kit-02.scc.kit.edu with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (envelope-from ) id 1dNq7M-0005pk-Kb; Thu, 22 Jun 2017 02:37:05 +0200 Received: from donnerwolke.usta.de ([172.24.96.3]) by hekate.usta.de with esmtp (Exim 4.77) (envelope-from ) id 1dNq7M-0000tY-Gt; Thu, 22 Jun 2017 02:37:04 +0200 Received: from athene.usta.de ([172.24.96.10]) by donnerwolke.usta.de with esmtp (Exim 4.84_2) (envelope-from ) id 1dNq7L-00011K-RA; Thu, 22 Jun 2017 02:37:04 +0200 Received: from localhost (athene.usta.de [local]) by athene.usta.de (OpenSMTPD) with ESMTPA id 7542f0ab; Thu, 22 Jun 2017 02:37:03 +0200 (CEST) Date: Thu, 22 Jun 2017 02:37:03 +0200 From: Ingo Schwarze To: "Anthony J. Bentley" Cc: tech@mdocml.bsd.lv Subject: Re: eqn(7) doesn't distinguish mathematical words Message-ID: <20170622003703.GG51095@athene.usta.de> References: <52112.1497933403@cathet.us> X-Mailinglist: mdocml-tech Reply-To: tech@mdocml.bsd.lv MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <52112.1497933403@cathet.us> User-Agent: Mutt/1.6.2 (2016-07-01) Hi Anthony, Anthony J. Bentley wrote on Mon, Jun 19, 2017 at 10:36:43PM -0600: > From the Plan 9 eqn(1) manual: > "Mathematical words like sin, cos, log are made Roman automatically." That was already addressed earlier. > The exception proves the rule, which is that eqn(1) italicizes words > in general. > > .EQ > a ab sin > .EN > > In groff and Heirloom, the above results in italic a and ab, and > roman sin. Fixed for the terminal formatter by the commit appended below. > In mandoc -Thtml, it instead results in italic a, and roman > ab and sin. Improving HTML output is still an open task. Yours, Ingo Log Message: ----------- Fix font selection for text boxes in the terminal formatter. Issue reported by bentley@. The AST data structure is powerful enough that all required information can easily be provided in the parser, and no change of the formatting code is needed. Modified Files: -------------- mdocml: eqn.c Revision Data ------------- Index: eqn.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/eqn.c,v retrieving revision 1.66 retrieving revision 1.67 diff -Leqn.c -Leqn.c -u -p -r1.66 -r1.67 --- eqn.c +++ eqn.c @@ -84,6 +84,8 @@ enum eqn_tok { EQN_TOK_ABOVE, EQN_TOK__MAX, EQN_TOK_FUNC, + EQN_TOK_QUOTED, + EQN_TOK_SYM, EQN_TOK_EOF }; @@ -517,7 +519,7 @@ eqn_tok_parse(struct eqn_node *ep, char if (quoted) { if (p != NULL) *p = mandoc_strndup(start, sz); - return EQN_TOK__MAX; + return EQN_TOK_QUOTED; } for (i = 0; i < EQN_TOK__MAX; i++) @@ -528,7 +530,7 @@ eqn_tok_parse(struct eqn_node *ep, char if (STRNEQ(start, sz, eqnsyms[i].str, strlen(eqnsyms[i].str))) { mandoc_asprintf(p, "\\[%s]", eqnsyms[i].sym); - return EQN_TOK__MAX; + return EQN_TOK_SYM; } } @@ -1084,8 +1086,10 @@ this_tok: * TODO: make sure we're not in an open subexpression. */ return ROFF_EQN; - case EQN_TOK_FUNC: case EQN_TOK__MAX: + case EQN_TOK_FUNC: + case EQN_TOK_QUOTED: + case EQN_TOK_SYM: assert(p != NULL); /* * If we already have something in the stack and we're @@ -1112,17 +1116,27 @@ this_tok: cur->text = p; /* * If not inside any explicit font context, - * give every letter its own box. + * quoted strings become italic, and every letter + * of a bare string gets its own italic box. */ - if (fontp == NULL && *p != '\0') { + do { + if (fontp != NULL || *p == '\0' || + tok == EQN_TOK_SYM) + break; + if (tok == EQN_TOK_QUOTED) { + cur->font = EQNFONT_ITALIC; + break; + } cp = p; for (;;) { + if (isalpha((unsigned char)*cp)) + cur->font = EQNFONT_ITALIC; cpn = cp + 1; if (*cp == '\\') mandoc_escape(&cpn, NULL, NULL); if (*cpn == '\0') break; - if (isalpha((unsigned char)*cp) == 0 && + if (cur->font != EQNFONT_ITALIC && isalpha((unsigned char)*cpn) == 0) { cp = cpn; continue; @@ -1137,7 +1151,7 @@ this_tok: cur = nbox; cp = nbox->text; } - } + } while (0); /* * Post-process list status. */ -- To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv