* mdocml: Write text boxes as <mi>, <mn>, or <mo> as appropriate, and
@ 2017-06-23 2:32 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2017-06-23 2:32 UTC (permalink / raw)
To: source
Log Message:
-----------
Write text boxes as <mi>, <mn>, or <mo> as appropriate,
and write fontstyle or fontweight attributes where required.
Missing features reported by bentley@.
Modified Files:
--------------
mdocml:
eqn_html.c
html.c
html.h
Revision Data
-------------
Index: html.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/html.h,v
retrieving revision 1.85
retrieving revision 1.86
diff -Lhtml.h -Lhtml.h -u -p -r1.85 -r1.86
--- html.h
+++ html.h
@@ -51,6 +51,7 @@ enum htmltag {
TAG_MATH,
TAG_MROW,
TAG_MI,
+ TAG_MN,
TAG_MO,
TAG_MSUP,
TAG_MSUB,
Index: html.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/html.c,v
retrieving revision 1.214
retrieving revision 1.215
diff -Lhtml.c -Lhtml.c -u -p -r1.214 -r1.215
--- html.c
+++ html.c
@@ -87,6 +87,7 @@ static const struct htmldata htmltags[TA
{"math", HTML_NLALL | HTML_INDENT},
{"mrow", 0},
{"mi", 0},
+ {"mn", 0},
{"mo", 0},
{"msup", 0},
{"msub", 0},
Index: eqn_html.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/eqn_html.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -Leqn_html.c -Leqn_html.c -u -p -r1.12 -r1.13
--- eqn_html.c
+++ eqn_html.c
@@ -20,6 +20,7 @@
#include <sys/types.h>
#include <assert.h>
+#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -33,7 +34,10 @@ eqn_box(struct html *p, const struct eqn
{
struct tag *post, *row, *cell, *t;
const struct eqn_box *child, *parent;
+ const unsigned char *cp;
size_t i, j, rows;
+ enum htmltag tag;
+ enum eqn_fontt font;
if (NULL == bp)
return;
@@ -136,9 +140,51 @@ eqn_box(struct html *p, const struct eqn
print_otag(p, TAG_MTD, "");
}
- if (NULL != bp->text) {
- assert(NULL == post);
- post = print_otag(p, TAG_MI, "");
+ if (bp->text != NULL) {
+ assert(post == NULL);
+ tag = TAG_MI;
+ cp = (unsigned char *)bp->text;
+ if (isdigit(cp[0]) || (cp[0] == '.' && isdigit(cp[1]))) {
+ tag = TAG_MN;
+ while (*++cp != '\0') {
+ if (*cp != '.' && !isdigit(*cp)) {
+ tag = TAG_MI;
+ break;
+ }
+ }
+ } else if (*cp != '\0' && isalpha(*cp) == 0) {
+ tag = TAG_MO;
+ while (*++cp != '\0') {
+ if (isalnum(*cp)) {
+ tag = TAG_MI;
+ break;
+ }
+ }
+ }
+ font = bp->font;
+ if (bp->text[0] != '\0' &&
+ (((tag == TAG_MN || tag == TAG_MO) &&
+ font == EQNFONT_ROMAN) ||
+ (tag == TAG_MI && font == (bp->text[1] == '\0' ?
+ EQNFONT_ITALIC : EQNFONT_ROMAN))))
+ font = EQNFONT_NONE;
+ switch (font) {
+ case EQNFONT_NONE:
+ post = print_otag(p, tag, "");
+ break;
+ case EQNFONT_ROMAN:
+ post = print_otag(p, tag, "?", "fontstyle", "normal");
+ break;
+ case EQNFONT_BOLD:
+ case EQNFONT_FAT:
+ post = print_otag(p, tag, "?", "fontweight", "bold");
+ break;
+ case EQNFONT_ITALIC:
+ post = print_otag(p, tag, "?", "fontstyle", "italic");
+ break;
+ default:
+ abort();
+ }
print_text(p, bp->text);
} else if (NULL == post) {
if (NULL != bp->left || NULL != bp->right)
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-06-23 2:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-23 2:32 mdocml: Write text boxes as <mi>, <mn>, or <mo> as appropriate, and schwarze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).