From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from krisdoz.my.domain (kristaps@localhost [127.0.0.1]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id o66CbIIJ017276 for ; Tue, 6 Jul 2010 08:37:18 -0400 (EDT) Received: (from kristaps@localhost) by krisdoz.my.domain (8.14.3/8.14.3/Submit) id o66CbIje014014; Tue, 6 Jul 2010 08:37:18 -0400 (EDT) Date: Tue, 6 Jul 2010 08:37:18 -0400 (EDT) Message-Id: <201007061237.o66CbIje014014@krisdoz.my.domain> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: kristaps@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: Give -T[x]html `Bk -words' capability. X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- Give -T[x]html `Bk -words' capability. Modified Files: -------------- mdocml: html.c html.h mdoc_html.c Revision Data ------------- Index: html.h =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/html.h,v retrieving revision 1.24 retrieving revision 1.25 diff -Lhtml.h -Lhtml.h -u -p -r1.24 -r1.25 --- html.h +++ html.h @@ -110,7 +110,9 @@ enum htmltype { struct html { int flags; #define HTML_NOSPACE (1 << 0) -#define HTML_IGNDELIM (1 << 2) +#define HTML_IGNDELIM (1 << 1) +#define HTML_KEEP (1 << 2) +#define HTML_PREKEEP (1 << 3) struct tagq tags; struct ordq ords; void *symtab; Index: html.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/html.c,v retrieving revision 1.104 retrieving revision 1.105 diff -Lhtml.c -Lhtml.c -u -p -r1.104 -r1.105 --- html.c +++ html.c @@ -393,8 +393,15 @@ print_otag(struct html *h, enum htmltag t = NULL; if ( ! (HTML_NOSPACE & h->flags)) - if ( ! (HTML_CLRLINE & htmltags[tag].flags)) - putchar(' '); + if ( ! (HTML_CLRLINE & htmltags[tag].flags)) { + /* Manage keeps! */ + if ( ! (HTML_KEEP & h->flags)) { + if (HTML_PREKEEP & h->flags) + h->flags |= HTML_KEEP; + putchar(' '); + } else + printf(" "); + } /* Print out the tag name and attributes. */ @@ -511,8 +518,15 @@ print_text(struct html *h, const char *w break; } - if ( ! (h->flags & HTML_NOSPACE)) - putchar(' '); + if ( ! (HTML_NOSPACE & h->flags)) { + /* Manage keeps! */ + if ( ! (HTML_KEEP & h->flags)) { + if (HTML_PREKEEP & h->flags) + h->flags |= HTML_KEEP; + putchar(' '); + } else + printf(" "); + } assert(word); if ( ! print_encode(h, word, 0)) Index: mdoc_html.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_html.c,v retrieving revision 1.93 retrieving revision 1.94 diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.93 -r1.94 --- mdoc_html.c +++ mdoc_html.c @@ -73,6 +73,8 @@ static int mdoc_aq_pre(MDOC_ARGS); static int mdoc_ar_pre(MDOC_ARGS); static int mdoc_bd_pre(MDOC_ARGS); static int mdoc_bf_pre(MDOC_ARGS); +static void mdoc_bk_post(MDOC_ARGS); +static int mdoc_bk_pre(MDOC_ARGS); static void mdoc_bl_post(MDOC_ARGS); static int mdoc_bl_pre(MDOC_ARGS); static void mdoc_bq_post(MDOC_ARGS); @@ -237,7 +239,7 @@ static const struct htmlmdoc mdocs[MDOC_ {NULL, NULL}, /* Fc */ {mdoc_op_pre, mdoc_op_post}, /* Oo */ {NULL, NULL}, /* Oc */ - {NULL, NULL}, /* Bk */ + {mdoc_bk_pre, mdoc_bk_post}, /* Bk */ {NULL, NULL}, /* Ek */ {mdoc_bt_pre, NULL}, /* Bt */ {NULL, NULL}, /* Hf */ @@ -442,6 +444,18 @@ print_mdoc_node(MDOC_ARGS) break; } + if (HTML_KEEP & h->flags) { + if (n->prev && n->prev->line != n->line) { + h->flags &= ~HTML_KEEP; + h->flags |= HTML_PREKEEP; + } else if (NULL == n->prev) { + if (n->parent && n->parent->line != n->line) { + h->flags &= ~HTML_KEEP; + h->flags |= HTML_PREKEEP; + } + } + } + if (child && n->child) print_mdoc_nodelist(m, n->child, h); @@ -2226,4 +2240,36 @@ mdoc__x_post(MDOC_ARGS) h->flags |= HTML_NOSPACE; print_text(h, n->next ? "," : "."); +} + + +/* ARGSUSED */ +static int +mdoc_bk_pre(MDOC_ARGS) +{ + + switch (n->type) { + case (MDOC_BLOCK): + break; + case (MDOC_HEAD): + return(0); + case (MDOC_BODY): + h->flags |= HTML_PREKEEP; + break; + default: + abort(); + /* NOTREACHED */ + } + + return(1); +} + + +/* ARGSUSED */ +static void +mdoc_bk_post(MDOC_ARGS) +{ + + if (MDOC_BODY == n->type) + h->flags &= ~(HTML_KEEP | HTML_PREKEEP); } -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv