From 314ca44f160b0c1b8bf73bc7c4157ca07db5da8a Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Wed, 10 Dec 2008 12:05:33 +0000 Subject: Versioning up. --- Makefile | 11 +++-- html.c | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------- index.7 | 9 ++-- literals.c | 84 +++++++++++++++++++++++++++++++++++++- mdocml.1 | 8 ++-- mdocml.css | 4 +- ml.h | 7 +++- mlg.c | 16 +++++--- private.h | 6 ++- roff.c | 6 ++- xml.c | 13 ++++-- 11 files changed, 257 insertions(+), 43 deletions(-) diff --git a/Makefile b/Makefile index 34f5bcf2..de2de11a 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/html.c b/html.c index 132f4d29..dd0e595c 100644 --- a/html.c +++ b/html.c @@ -1,4 +1,4 @@ -/* $Id: html.c,v 1.21 2008/12/10 10:43:57 kristaps Exp $ */ +/* $Id: html.c,v 1.22 2008/12/10 12:05:33 kristaps Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons * @@ -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); diff --git a/index.7 b/index.7 index 19cce925..dc221188 100644 --- a/index.7 +++ b/index.7 @@ -1,5 +1,5 @@ .\" -.Dd $Mdocdate: December 8 2008 $ +.Dd $Mdocdate: December 10 2008 $ .Dt index 7 .Os LOCAL .\" @@ -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 diff --git a/literals.c b/literals.c index ab02bd45..e6eba897 100644 --- a/literals.c +++ b/literals.c @@ -1,4 +1,4 @@ -/* $Id: literals.c,v 1.7 2008/12/10 10:43:57 kristaps Exp $ */ +/* $Id: literals.c,v 1.8 2008/12/10 12:05:33 kristaps Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons * @@ -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 */ +} diff --git a/mdocml.1 b/mdocml.1 index db7e4cae..176faf5b 100644 --- a/mdocml.1 +++ b/mdocml.1 @@ -1,6 +1,6 @@ .\" -.Dd $Mdocdate: December 9 2008 $ -.Dt mdocml 1 alpha +.Dd $Mdocdate: December 10 2008 $ +.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 , diff --git a/mdocml.css b/mdocml.css index f9a1df3c..50acf27a 100644 --- a/mdocml.css +++ b/mdocml.css @@ -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; } diff --git a/ml.h b/ml.h index f637860c..e67e8e32 100644 --- a/ml.h +++ b/ml.h @@ -1,4 +1,4 @@ -/* $Id: ml.h,v 1.13 2008/12/10 10:43:57 kristaps Exp $ */ +/* $Id: ml.h,v 1.14 2008/12/10 12:05:33 kristaps Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons * @@ -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); diff --git a/mlg.c b/mlg.c index c4ddf090..72b9ebd1 100644 --- a/mlg.c +++ b/mlg.c @@ -1,4 +1,4 @@ -/* $Id: mlg.c,v 1.25 2008/12/10 10:43:57 kristaps Exp $ */ +/* $Id: mlg.c,v 1.26 2008/12/10 12:05:33 kristaps Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons * @@ -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)); } diff --git a/private.h b/private.h index 5e0a3f82..8ee39dd6 100644 --- a/private.h +++ b/private.h @@ -1,4 +1,4 @@ -/* $Id: private.h,v 1.36 2008/12/10 10:43:57 kristaps Exp $ */ +/* $Id: private.h,v 1.37 2008/12/10 12:05:33 kristaps Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons * @@ -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 diff --git a/roff.c b/roff.c index 99047556..77417f01 100644 --- a/roff.c +++ b/roff.c @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.58 2008/12/10 10:43:57 kristaps Exp $ */ +/* $Id: roff.c,v 1.59 2008/12/10 12:05:33 kristaps Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons * @@ -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; diff --git a/xml.c b/xml.c index 8d73301b..3489cc63 100644 --- a/xml.c +++ b/xml.c @@ -1,4 +1,4 @@ -/* $Id: xml.c,v 1.23 2008/12/10 10:43:57 kristaps Exp $ */ +/* $Id: xml.c,v 1.24 2008/12/10 12:05:33 kristaps Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons * @@ -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, "", NULL)); -- cgit v1.2.3-56-ge451