aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-07-24 10:09:03 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-07-24 10:09:03 +0000
commitdf50b5d64e0d28bd648ff97b998eced503c945fc (patch)
treed9ad05ade4dcf6795aab4da47c7035e27f2f7b7b
parent234884d113221f817102fb404dadd44b4e860fb9 (diff)
downloadmandoc-df50b5d64e0d28bd648ff97b998eced503c945fc.tar.gz
mandoc-df50b5d64e0d28bd648ff97b998eced503c945fc.tar.zst
mandoc-df50b5d64e0d28bd648ff97b998eced503c945fc.zip
Tuned the initial eqn output, making it completely simple. This
completes a full initial eqn system, so I'm tagging a release on it.
-rw-r--r--Makefile4
-rw-r--r--eqn_html.c52
-rw-r--r--eqn_term.c56
-rw-r--r--index.sgml6
4 files changed, 52 insertions, 66 deletions
diff --git a/Makefile b/Makefile
index eceee4fd..ceeaab60 100644
--- a/Makefile
+++ b/Makefile
@@ -11,8 +11,8 @@
# in the lower-left hand corner of -mdoc manuals.
# CFLAGS += -DOSNAME="\"OpenBSD 4.5\""
-VERSION = 1.11.4
-VDATE = 12 July 2011
+VERSION = 1.11.5
+VDATE = 24 July 2011
# IFF your system supports multi-byte functions (setlocale(), wcwidth(),
# putwchar()) AND has __STDC_ISO_10646__ (that is, wchar_t is simply a
# UCS-4 value) should you define USE_WCHAR. If you define it and your
diff --git a/eqn_html.c b/eqn_html.c
index 78e11d43..80c82f1d 100644
--- a/eqn_html.c
+++ b/eqn_html.c
@@ -1,4 +1,4 @@
-/* $Id: eqn_html.c,v 1.1 2011/07/23 22:57:13 kristaps Exp $ */
+/* $Id: eqn_html.c,v 1.2 2011/07/24 10:09:03 kristaps Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -27,10 +27,16 @@
#include "out.h"
#include "html.h"
+static const enum htmltag fontmap[EQNFONT__MAX] = {
+ TAG_SPAN, /* EQNFONT_NONE */
+ TAG_SPAN, /* EQNFONT_ROMAN */
+ TAG_B, /* EQNFONT_BOLD */
+ TAG_B, /* EQNFONT_FAT */
+ TAG_I /* EQNFONT_ITALIC */
+};
+
+
static void eqn_box(struct html *, const struct eqn_box *);
-static void eqn_box_post(struct html *, const struct eqn_box *);
-static void eqn_box_pre(struct html *, const struct eqn_box *);
-static void eqn_text(struct html *, const struct eqn_box *);
void
print_eqn(struct html *p, const struct eqn *ep)
@@ -51,39 +57,25 @@ print_eqn(struct html *p, const struct eqn *ep)
static void
eqn_box(struct html *p, const struct eqn_box *bp)
{
+ struct tag *t;
- eqn_box_pre(p, bp);
- eqn_text(p, bp);
-
- if (bp->first)
- eqn_box(p, bp->first);
-
- eqn_box_post(p, bp);
-
- if (bp->next)
- eqn_box(p, bp->next);
-}
-
-static void
-eqn_box_pre(struct html *p, const struct eqn_box *bp)
-{
+ t = EQNFONT_NONE == bp->font ? NULL :
+ print_otag(p, fontmap[(int)bp->font], 0, NULL);
if (bp->left)
print_text(p, bp->left);
-}
+
+ if (bp->text)
+ print_text(p, bp->text);
-static void
-eqn_box_post(struct html *p, const struct eqn_box *bp)
-{
+ if (bp->first)
+ eqn_box(p, bp->first);
+ if (NULL != t)
+ print_tagq(p, t);
if (bp->right)
print_text(p, bp->right);
-}
-static void
-eqn_text(struct html *p, const struct eqn_box *bp)
-{
-
- if (bp->text)
- print_text(p, bp->text);
+ if (bp->next)
+ eqn_box(p, bp->next);
}
diff --git a/eqn_term.c b/eqn_term.c
index 59671e84..cfbd8d48 100644
--- a/eqn_term.c
+++ b/eqn_term.c
@@ -1,4 +1,4 @@
-/* $Id: eqn_term.c,v 1.3 2011/07/23 22:57:13 kristaps Exp $ */
+/* $Id: eqn_term.c,v 1.4 2011/07/24 10:09:03 kristaps Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -27,10 +27,15 @@
#include "out.h"
#include "term.h"
+static const enum termfont fontmap[EQNFONT__MAX] = {
+ TERMFONT_NONE, /* EQNFONT_NONE */
+ TERMFONT_NONE, /* EQNFONT_ROMAN */
+ TERMFONT_BOLD, /* EQNFONT_BOLD */
+ TERMFONT_BOLD, /* EQNFONT_FAT */
+ TERMFONT_UNDER /* EQNFONT_ITALIC */
+};
+
static void eqn_box(struct termp *, const struct eqn_box *);
-static void eqn_box_post(struct termp *, const struct eqn_box *);
-static void eqn_box_pre(struct termp *, const struct eqn_box *);
-static void eqn_text(struct termp *, const struct eqn_box *);
void
term_eqn(struct termp *p, const struct eqn *ep)
@@ -38,6 +43,7 @@ term_eqn(struct termp *p, const struct eqn *ep)
p->flags |= TERMP_NONOSPACE;
eqn_box(p, ep->root);
+ term_word(p, " ");
p->flags &= ~TERMP_NONOSPACE;
}
@@ -45,38 +51,26 @@ static void
eqn_box(struct termp *p, const struct eqn_box *bp)
{
- eqn_box_pre(p, bp);
- eqn_text(p, bp);
-
- if (bp->first)
- eqn_box(p, bp->first);
-
- eqn_box_post(p, bp);
-
- if (bp->next)
- eqn_box(p, bp->next);
-}
-
-static void
-eqn_box_pre(struct termp *p, const struct eqn_box *bp)
-{
-
+ if (EQNFONT_NONE != bp->font)
+ term_fontpush(p, fontmap[(int)bp->font]);
if (bp->left)
term_word(p, bp->left);
-}
+ if (EQN_SUBEXPR == bp->type)
+ term_word(p, "(");
-static void
-eqn_box_post(struct termp *p, const struct eqn_box *bp)
-{
+ if (bp->text)
+ term_word(p, bp->text);
+ if (bp->first)
+ eqn_box(p, bp->first);
+
+ if (EQN_SUBEXPR == bp->type)
+ term_word(p, ")");
if (bp->right)
term_word(p, bp->right);
-}
+ if (EQNFONT_NONE != bp->font)
+ term_fontpop(p);
-static void
-eqn_text(struct termp *p, const struct eqn_box *bp)
-{
-
- if (bp->text)
- term_word(p, bp->text);
+ if (bp->next)
+ eqn_box(p, bp->next);
}
diff --git a/index.sgml b/index.sgml
index fd1a9065..0fc114ae 100644
--- a/index.sgml
+++ b/index.sgml
@@ -311,14 +311,14 @@
<A NAME="news">News</A>
</H1>
<P CLASS="news">
- xx-07-2011: version 1.11.5
+ 24-07-2011: version 1.11.5
</P>
<P>
Significant <A HREF="eqn.7.html">eqn</A> improvements. <SPAN CLASS="nm">mdocml</SPAN> can now parse arbitrary eqn input
(although few GNU extensions are accepted, nor is mixing low-level roff with eqn). See the <A HREF="eqn.7.html">eqn</A>
manual for details. For the time being, equations are rendered as simple in-line text. The equation parser satisfies
the language specified in the <A CLASS="external" HREF="http://www.kohala.com/start/troff/v7man/eqn/eqn2e.ps">Second
- Edition eqn User's Guide</A>.
+ Edition User's Guide</A>.
</P>
<P CLASS="news">
12-07-2011: version 1.11.4
@@ -366,7 +366,7 @@
<SMALL>
Copyright &#169; 2008&#8211;2011
<A CLASS="external" HREF="http://kristaps.bsd.lv">Kristaps Dzonsons</A>,
- $Date: 2011/07/23 18:41:18 $
+ $Date: 2011/07/24 10:09:03 $
</SMALL>
</P>
</BODY>