diff options
-rw-r--r-- | Makefile | 11 | ||||
-rw-r--r-- | html.c | 134 | ||||
-rw-r--r-- | index.7 | 7 | ||||
-rw-r--r-- | literals.c | 82 | ||||
-rw-r--r-- | mdocml.1 | 6 | ||||
-rw-r--r-- | mdocml.css | 4 | ||||
-rw-r--r-- | ml.h | 5 | ||||
-rw-r--r-- | mlg.c | 14 | ||||
-rw-r--r-- | private.h | 4 | ||||
-rw-r--r-- | roff.c | 4 | ||||
-rw-r--r-- | xml.c | 11 |
11 files changed, 248 insertions, 34 deletions
@@ -1,5 +1,3 @@ -.SUFFIXES: .html .7 - VERSION = 1.0.1 # FIXME @@ -28,8 +26,10 @@ HTML = index.html mdocml.html XML = index.xml +TEXT = index.txt + CLEAN = mdocml mdocml.tgz $(LLNS) $(LNS) $(OBJS) $(LIBS) $(HTML) \ - $(XML) + $(XML) $(TEXT) INSTALL = Makefile $(HEADS) $(SRCS) $(MANS) @@ -52,7 +52,7 @@ lint: llib-lmdocml.ln dist: mdocml.tgz -www: all $(HTML) $(XML) +www: all $(HTML) $(XML) $(TEXT) regress: mdocml @for f in $(FAIL); do \ @@ -76,6 +76,9 @@ index.html: index.7 mdocml.css index.xml: index.7 mdocml.css ./mdocml -Wall -o $@ index.7 +index.txt: index.7 + cp -f index.7 index.txt + mdocml.html: mdocml.1 mdocml.css ./mdocml -Wall -fhtml -e -o $@ mdocml.1 @@ -76,8 +76,11 @@ static int html_begin(struct md_mbuf *, static int html_printargs(struct md_mbuf *, int, const char *, const int *, const char **, size_t *); -static int html_end(struct md_mbuf *, - const struct md_args *); +static int html_end(struct md_mbuf *, + const struct md_args *, + const struct tm *, + const char *, const char *, + enum roffmsec, enum roffvol); static int html_blocktagname(struct md_mbuf *, const struct md_args *, int, struct htmlq *, const int *, @@ -384,6 +387,7 @@ html_begin(struct md_mbuf *mbuf, const struct md_args *args, const struct tm *tm, const char *os, const char *name, enum roffmsec msec, enum roffvol vol) { + enum roffvol bvol; struct html_pair attr[4]; char ts[32], title[64]; int i; @@ -391,12 +395,48 @@ html_begin(struct md_mbuf *mbuf, const struct md_args *args, (void)snprintf(ts, sizeof(ts), "%s(%s)", name, roff_msecname(msec)); - (void)snprintf(ts, sizeof(ts), "%s", - name, roff_volname(vol)); - if (vol >= ROFF_ARCH_START) { + switch (msec) { + case(ROFF_MSEC_1): + /* FALLTHROUGH */ + case(ROFF_MSEC_6): + /* FALLTHROUGH */ + case(ROFF_MSEC_7): + bvol = ROFF_VOL_URM; + break; + case(ROFF_MSEC_2): + /* FALLTHROUGH */ + case(ROFF_MSEC_3): + /* FALLTHROUGH */ + case(ROFF_MSEC_3p): + /* FALLTHROUGH */ + case(ROFF_MSEC_4): + /* FALLTHROUGH */ + case(ROFF_MSEC_5): + bvol = ROFF_VOL_PRM; + break; + case(ROFF_MSEC_8): + bvol = ROFF_VOL_PRM; + break; + case(ROFF_MSEC_9): + bvol = ROFF_VOL_KM; + break; + case(ROFF_MSEC_UNASS): + /* FALLTHROUGH */ + case(ROFF_MSEC_DRAFT): + /* FALLTHROUGH */ + case(ROFF_MSEC_PAPER): + bvol = ROFF_VOL_NONE; + break; + default: + abort(); + /* NOTREACHED */ + } - } + (void)snprintf(title, sizeof(title), "%s (%s)", + roff_volname(bvol), roff_volname(vol)); + } else + (void)snprintf(title, sizeof(title), "%s", roff_volname(vol)); i = 0; @@ -439,13 +479,13 @@ html_begin(struct md_mbuf *mbuf, const struct md_args *args, HTML_TAG_STYLE, 1, attr)) return(0); if ( ! html_commentput(mbuf, ML_OPEN, NULL)) - return(NULL); + return(0); if ( ! html_loadcss(mbuf, args->params.html.css)) return(0); if ( ! html_commentput(mbuf, ML_CLOSE, NULL)) - return(NULL); + return(0); if ( ! html_tputln(mbuf, ML_CLOSE, i, HTML_TAG_STYLE)) return(0); } else { @@ -474,29 +514,44 @@ html_begin(struct md_mbuf *mbuf, const struct md_args *args, attr[0].attr = HTML_ATTR_WIDTH; attr[0].val = "100%"; + attr[1].attr = HTML_ATTR_CLASS; + attr[1].val = "header-table"; - if ( ! html_aputln(mbuf, ML_OPEN, i++, HTML_TAG_TABLE, 1, attr)) + if ( ! html_aputln(mbuf, ML_OPEN, i++, HTML_TAG_TABLE, 2, attr)) return(0); if ( ! html_tputln(mbuf, ML_OPEN, i++, HTML_TAG_TR)) return(0); - if ( ! html_tputln(mbuf, ML_OPEN, i, HTML_TAG_TD)) + attr[0].attr = HTML_ATTR_ALIGN; + attr[0].val = "left"; + attr[1].attr = HTML_ATTR_CLASS; + attr[1].val = "header-section"; + + if ( ! html_aputln(mbuf, ML_OPEN, i, HTML_TAG_TD, 2, attr)) return(0); if ( ! ml_putstring(mbuf, ts, NULL)) return(0); if ( ! html_tputln(mbuf, ML_CLOSE, i, HTML_TAG_TD)) return(0); - if ( ! html_tputln(mbuf, ML_OPEN, i, HTML_TAG_TD)) + attr[0].attr = HTML_ATTR_ALIGN; + attr[0].val = "center"; + attr[1].attr = HTML_ATTR_CLASS; + attr[1].val = "header-volume"; + + if ( ! html_aputln(mbuf, ML_OPEN, i, HTML_TAG_TD, 2, attr)) + return(0); + if ( ! ml_putstring(mbuf, title, NULL)) return(0); - /* TODO: middle. */ if ( ! html_tputln(mbuf, ML_CLOSE, i, HTML_TAG_TD)) return(0); attr[0].attr = HTML_ATTR_ALIGN; attr[0].val = "right"; + attr[1].attr = HTML_ATTR_CLASS; + attr[1].val = "header-section"; - if ( ! html_aputln(mbuf, ML_OPEN, i, HTML_TAG_TD, 1, attr)) + if ( ! html_aputln(mbuf, ML_OPEN, i, HTML_TAG_TD, 2, attr)) return(0); if ( ! ml_putstring(mbuf, ts, NULL)) return(0); @@ -511,8 +566,59 @@ html_begin(struct md_mbuf *mbuf, const struct md_args *args, /* ARGSUSED */ static int -html_end(struct md_mbuf *mbuf, const struct md_args *args) +html_end(struct md_mbuf *mbuf, const struct md_args *args, + const struct tm *tm, const char *os, + const char *name, enum roffmsec msec, enum roffvol vol) { + struct html_pair attr[4]; + int i; + char ts[64]; + + if (0 == strftime(ts, sizeof(ts), "%B %d, %Y", tm)) { + warn("strftime"); + return(0); + } + + i = 0; + + attr[0].attr = HTML_ATTR_WIDTH; + attr[0].val = "100%"; + attr[1].attr = HTML_ATTR_CLASS; + attr[1].val = "header-footer"; + + if ( ! html_aputln(mbuf, ML_OPEN, i++, HTML_TAG_TABLE, 2, attr)) + return(0); + if ( ! html_tputln(mbuf, ML_OPEN, i++, HTML_TAG_TR)) + return(0); + + attr[0].attr = HTML_ATTR_ALIGN; + attr[0].val = "left"; + attr[1].attr = HTML_ATTR_CLASS; + attr[1].val = "footer-os"; + + if ( ! html_aputln(mbuf, ML_OPEN, i, HTML_TAG_TD, 2, attr)) + return(0); + if ( ! ml_putstring(mbuf, os, NULL)) + return(0); + if ( ! html_tputln(mbuf, ML_CLOSE, i, HTML_TAG_TD)) + return(0); + + attr[0].attr = HTML_ATTR_ALIGN; + attr[0].val = "right"; + attr[1].attr = HTML_ATTR_CLASS; + attr[1].val = "footer-date"; + + if ( ! html_aputln(mbuf, ML_OPEN, i, HTML_TAG_TD, 2, attr)) + return(0); + if ( ! ml_putstring(mbuf, ts, NULL)) + return(0); + if ( ! html_tputln(mbuf, ML_CLOSE, i, HTML_TAG_TD)) + return(0); + + if ( ! html_tputln(mbuf, ML_CLOSE, --i, HTML_TAG_TR)) + return(0); + if ( ! html_tputln(mbuf, ML_CLOSE, --i, HTML_TAG_TABLE)) + return(0); if ( ! html_tputln(mbuf, ML_CLOSE, 0, HTML_TAG_DIV)) return(0); @@ -103,7 +103,7 @@ Download at http://mdocml.bsd.lv/mdocml.tgz .Ns . .\" - UPDATE ME WITH EVERY RELEASE. ---------------------------------- -The current version is 1.0.1, dated 08/12/2008. +The current version is 1.0.2, dated 10/12/2008. .\" ------------------------------------------------------------------ .Pp Previous versions are archived as mdocml-x.y.z.tgz, with the appropriate @@ -118,7 +118,10 @@ is available at http://mdocml.bsd.lv/mdocml.html .Sh EXAMPLES This page was produced as follows: .Pp -.D1 % mdocml -fhtml -W -e -o index.html index.7 +.D1 % mdocml -fhtml -Wall -e -o index.html index.7 +.Pp +The original mdoc source is at http://mdocml.bsd.lv/index.txt +.Ns . .\" .Sh SEE ALSO .Bl -ohang @@ -531,3 +531,85 @@ roff_vol(const char *p) return(ROFF_VOL_MAX); } + + +char * +roff_volname(enum roffvol vol) +{ + + /* FIXME: is OpenBSD specific! */ + + switch (vol) { + case(ROFF_VOL_AMD): + return("OpenBSD Ancestral Manual Documents"); + case(ROFF_VOL_IND): + return("OpenBSD Manual Master Index"); + case(ROFF_VOL_KM): + return("OpenBSD Kernel Manual"); + case(ROFF_VOL_LOCAL): + return("OpenBSD Local Manual"); + case(ROFF_VOL_PRM): + return("OpenBSD Programmer's Manual"); + case(ROFF_VOL_PS1): + return("OpenBSD Programmer's Supplementary Documents"); + case(ROFF_VOL_SMM): + return("OpenBSD System Manager's Manual"); + case(ROFF_VOL_URM): + return("OpenBSD Reference Manual"); + case(ROFF_VOL_USD): + return("OpenBSD User's Supplementary Documents"); + case(ROFF_ARCH_ALPHA): + return("Alpha"); + case(ROFF_ARCH_AMD64): + return("AMD64"); + case(ROFF_ARCH_AMIGA): + return("Amiga"); + case(ROFF_ARCH_ARC): + return("ARC"); + case(ROFF_ARCH_ARMISH): + return("ARMISH"); + case(ROFF_ARCH_AVIION): + return("AVIION"); + case(ROFF_ARCH_HP300): + return("HP300"); + case(ROFF_ARCH_HPPA): + return("HPPA"); + case(ROFF_ARCH_HPPA64): + return("HPPA64"); + case(ROFF_ARCH_I386): + return("i386"); + case(ROFF_ARCH_LANDISK): + return("LANDISK"); + case(ROFF_ARCH_LUNA88K): + return("Luna88K"); + case(ROFF_ARCH_MAC68K): + return("Mac68K"); + case(ROFF_ARCH_MACPPC): + return("MacPPC"); + case(ROFF_ARCH_MVME68K): + return("MVME68K"); + case(ROFF_ARCH_MVME88K): + return("MVME88K"); + case(ROFF_ARCH_MVMEPPC): + return("MVMEPPC"); + case(ROFF_ARCH_PMAX): + return("PMAX"); + case(ROFF_ARCH_SGI): + return("SGI"); + case(ROFF_ARCH_SPARC): + return("SPARC"); + case(ROFF_ARCH_SPARC64): + return("SPARC64"); + case(ROFF_ARCH_SUN3): + return("Sun3"); + case(ROFF_ARCH_VAX): + return("Vax"); + case(ROFF_ARCH_ZAURUS): + return("Zaurus"); + default: + break; + } + + abort(); + /* NOTREACHED */ +} @@ -1,6 +1,6 @@ .\" .Dd $Mdocdate$ -.Dt mdocml 1 alpha +.Dt mdocml 1 .Os .\" .Sh NAME @@ -26,7 +26,9 @@ and the default. Arguments common to all filters follow: .Bl -tag -width "\-o outfile" .It Fl f Ar filter -The output filter name. +The output filter name. This +.Em must +be declared before any other options. .It Fl o Ar outfile Write output to .Ar outfile , @@ -1,7 +1,7 @@ body { margin: 10px; font-family: Tahoma, sans-serif; font-size: small; } - h1 { font-size: medium; } + h1 { font-size: small; } h2 { font-size: small; } div.mdoc { width: 600px; } div.block-Sh { margin-bottom: 20px; } @@ -11,6 +11,8 @@ div.body-Sh { margin-left: 20px; margin-top: 10px; text-align: justify; } + table.header-table { margin-bottom: 10px; } + td.header-section { text-transform: uppercase; } span.inline-Nd:before { content: ' \2014 '; } span.inline-Fl:before { content: '-'; } span.inline-Fl { font-weight: bolder; } @@ -48,7 +48,10 @@ struct ml_cbs { const char *, const char *, enum roffmsec, enum roffvol); int (*ml_end)(struct md_mbuf *, - const struct md_args *); + const struct md_args *, + const struct tm *, + const char *, const char *, + enum roffmsec, enum roffvol); ssize_t (*ml_beginstring)(struct md_mbuf *, const struct md_args *, const char *, size_t); @@ -59,7 +59,9 @@ static int mlg_roffmsg(void *arg, static int mlg_roffhead(void *, const struct tm *, const char *, const char *, enum roffmsec, enum roffvol); -static int mlg_rofftail(void *); +static int mlg_rofftail(void *, const struct tm *, + const char *, const char *, + enum roffmsec, enum roffvol); static int mlg_roffin(void *, int, int *, const char **); static int mlg_roffdata(void *, int, @@ -413,7 +415,8 @@ mlg_roffhead(void *arg, const struct tm *tm, const char *os, mlg_mode(p, MD_BLK_IN); - if ( ! (*p->cbs.ml_begin)(p->mbuf, p->args, tm, os, title, sec, vol)) + if ( ! (*p->cbs.ml_begin)(p->mbuf, p->args, + tm, os, title, sec, vol)) return(0); p->indent++; @@ -422,7 +425,8 @@ mlg_roffhead(void *arg, const struct tm *tm, const char *os, static int -mlg_rofftail(void *arg) +mlg_rofftail(void *arg, const struct tm *tm, const char *os, + const char *title, enum roffmsec sec, enum roffvol vol) { struct md_mlg *p; @@ -433,11 +437,11 @@ mlg_rofftail(void *arg) if ( ! mlg_newline(p)) return(0); - if ( ! (*p->cbs.ml_end)(p->mbuf, p->args)) + if ( ! (*p->cbs.ml_end)(p->mbuf, p->args, + tm, os, title, sec, vol)) return(0); mlg_mode(p, MD_BLK_OUT); - return(mlg_newline(p)); } @@ -346,7 +346,8 @@ struct roffcb { const char *, const char *, const char *); int (*roffhead)(void *, const struct tm *, const char *, const char *, enum roffmsec, enum roffvol); - int (*rofftail)(void *); + int (*rofftail)(void *, const struct tm *, const char *, + const char *, enum roffmsec, enum roffvol); int (*roffdata)(void *, int, const char *, const char *); int (*roffin)(void *, int, int *, const char **); int (*roffout)(void *, int); @@ -391,6 +392,7 @@ enum roffmsec roff_msec(const char *); int roff_sec(const char **); enum roffatt roff_att(const char *); enum roffvol roff_vol(const char *); +char *roff_volname(enum roffvol); __END_DECLS @@ -164,7 +164,9 @@ roff_free(struct rofftree *tree, int flush) goto end; } - if ( ! (*tree->cb.rofftail)(tree->arg)) + if ( ! (*tree->cb.rofftail)(tree->arg, &tree->tm, + tree->os, tree->title, + tree->section, tree->volume)) goto end; error = 0; @@ -44,8 +44,11 @@ static int xml_begin(struct md_mbuf *, const struct tm *, const char *, const char *, enum roffmsec, enum roffvol); -static int xml_end(struct md_mbuf *, - const struct md_args *); +static int xml_end(struct md_mbuf *, + const struct md_args *, + const struct tm *, + const char *, const char *, + enum roffmsec, enum roffvol); static ssize_t xml_printtagname(struct md_mbuf *, enum md_ns, int); static ssize_t xml_printtagargs(struct md_mbuf *, @@ -139,7 +142,9 @@ xml_begin(struct md_mbuf *mbuf, const struct md_args *args, /* ARGSUSED */ static int -xml_end(struct md_mbuf *mbuf, const struct md_args *args) +xml_end(struct md_mbuf *mbuf, const struct md_args *args, + const struct tm *tm, const char *os, + const char *title, enum roffmsec sec, enum roffvol vol) { return(ml_puts(mbuf, "</mdoc>", NULL)); |