]> git.cameronkatri.com Git - mandoc.git/blobdiff - mdoc_html.c
enclosures sometimes cause bogus end-of-sentence
[mandoc.git] / mdoc_html.c
index c41124d744ae85b1540428aa143dd81ff8e8f57b..f1b022a4d8f2c8fd9a78153d4a0cacb007f1e72c 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id: mdoc_html.c,v 1.98 2010/07/19 11:11:54 kristaps Exp $ */
+/*     $Id: mdoc_html.c,v 1.104 2010/09/04 20:18:53 kristaps Exp $ */
 /*
  * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
  *
@@ -125,6 +125,7 @@ static      int               mdoc_pq_pre(MDOC_ARGS);
 static int               mdoc_rs_pre(MDOC_ARGS);
 static int               mdoc_rv_pre(MDOC_ARGS);
 static int               mdoc_sh_pre(MDOC_ARGS);
+static int               mdoc_sm_pre(MDOC_ARGS);
 static int               mdoc_sp_pre(MDOC_ARGS);
 static void              mdoc_sq_post(MDOC_ARGS);
 static int               mdoc_sq_pre(MDOC_ARGS);
@@ -227,7 +228,7 @@ static      const struct htmlmdoc mdocs[MDOC_MAX] = {
        {NULL, NULL}, /* Sc */
        {mdoc_sq_pre, mdoc_sq_post}, /* So */
        {mdoc_sq_pre, mdoc_sq_post}, /* Sq */
-       {NULL, NULL}, /* Sm */ /* FIXME - no idea. */
+       {mdoc_sm_pre, NULL}, /* Sm */ 
        {mdoc_sx_pre, NULL}, /* Sx */
        {mdoc_sy_pre, NULL}, /* Sy */
        {NULL, NULL}, /* Tn */
@@ -1182,7 +1183,7 @@ mdoc_bl_pre(MDOC_ARGS)
        ord = malloc(sizeof(struct ord));
        if (NULL == ord) {
                perror(NULL);
-               exit(EXIT_FAILURE);
+               exit((int)MANDOCLEVEL_SYSERR);
        }
        ord->cookie = n;
        ord->pos = 1;
@@ -1456,14 +1457,11 @@ mdoc_bd_pre(MDOC_ARGS)
        print_otag(h, TAG_DIV, 2, tag);
 
        for (nn = n->child; nn; nn = nn->next) {
-               h->flags |= HTML_NOSPACE;
                print_mdoc_node(m, nn, h);
-               if (NULL == nn->next)
+               if (nn->next && nn->next->line == nn->line)
                        continue;
-               if (nn->prev && nn->prev->line < nn->line)
-                       print_text(h, "\n");
-               else if (NULL == nn->prev)
-                       print_text(h, "\n");
+               print_text(h, "\n");
+               h->flags |= HTML_NOSPACE;
        }
 
        return(0);
@@ -1720,6 +1718,23 @@ mdoc_fn_pre(MDOC_ARGS)
 }
 
 
+/* ARGSUSED */
+static int
+mdoc_sm_pre(MDOC_ARGS)
+{
+
+       assert(n->child && MDOC_TEXT == n->child->type);
+       if (0 == strcmp("on", n->child->string)) {
+               /* FIXME: no p->col to check... */
+               h->flags &= ~HTML_NOSPACE;
+               h->flags &= ~HTML_NONOSPACE;
+       } else
+               h->flags |= HTML_NONOSPACE;
+
+       return(0);
+}
+
+
 /* ARGSUSED */
 static int
 mdoc_sp_pre(MDOC_ARGS)
@@ -2179,6 +2194,9 @@ mdoc__x_pre(MDOC_ARGS)
        switch (n->tok) {
        case(MDOC__A):
                PAIR_CLASS_INIT(&tag[0], "ref-auth");
+               if (n->prev && MDOC__A == n->prev->tok)
+                       if (NULL == n->next || MDOC__A != n->next->tok)
+                               print_text(h, "and");
                break;
        case(MDOC__B):
                PAIR_CLASS_INIT(&tag[0], "ref-book");
@@ -2231,6 +2249,7 @@ mdoc__x_pre(MDOC_ARGS)
 
        PAIR_HREF_INIT(&tag[1], n->child->string);
        print_otag(h, TAG_A, 2, tag);
+
        return(1);
 }
 
@@ -2240,6 +2259,11 @@ static void
 mdoc__x_post(MDOC_ARGS)
 {
 
+       if (MDOC__A == n->tok && n->next && MDOC__A == n->next->tok)
+               if (NULL == n->next->next || MDOC__A != n->next->next->tok)
+                       if (NULL == n->prev || MDOC__A != n->prev->tok)
+                               return;
+
        /* TODO: %U */
 
        h->flags |= HTML_NOSPACE;