]> git.cameronkatri.com Git - mandoc.git/blobdiff - html.c
STYLE message about full stop at the end of .Nd; inspired by mdoclint(1)
[mandoc.git] / html.c
diff --git a/html.c b/html.c
index 8f1e3df490a2981173f30334c73ad542bf6a93a8..fef0aa0d0ddda2f1e75c182a38fa898c53f5669a 100644 (file)
--- a/html.c
+++ b/html.c
@@ -1,4 +1,4 @@
-/*     $Id: html.c,v 1.204 2017/01/29 14:02:41 schwarze Exp $ */
+/*     $Id: html.c,v 1.212 2017/05/14 12:27:28 schwarze Exp $ */
 /*
  * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2011-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
 /*
  * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2011-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -28,8 +28,9 @@
 #include <string.h>
 #include <unistd.h>
 
 #include <string.h>
 #include <unistd.h>
 
-#include "mandoc.h"
 #include "mandoc_aux.h"
 #include "mandoc_aux.h"
+#include "mandoc.h"
+#include "roff.h"
 #include "out.h"
 #include "html.h"
 #include "manconf.h"
 #include "out.h"
 #include "html.h"
 #include "manconf.h"
@@ -65,7 +66,7 @@ static        const struct htmldata htmltags[TAG_MAX] = {
        {"br",          HTML_NOSTACK | HTML_AUTOCLOSE | HTML_NLALL},
        {"a",           0},
        {"table",       HTML_NLALL | HTML_INDENT},
        {"br",          HTML_NOSTACK | HTML_AUTOCLOSE | HTML_NLALL},
        {"a",           0},
        {"table",       HTML_NLALL | HTML_INDENT},
-       {"tbody",       HTML_NLALL | HTML_INDENT},
+       {"colgroup",    HTML_NLALL | HTML_INDENT},
        {"col",         HTML_NOSTACK | HTML_AUTOCLOSE | HTML_NLALL},
        {"tr",          HTML_NLALL | HTML_INDENT},
        {"td",          HTML_NLAROUND},
        {"col",         HTML_NOSTACK | HTML_AUTOCLOSE | HTML_NLALL},
        {"tr",          HTML_NLALL | HTML_INDENT},
        {"td",          HTML_NLAROUND},
@@ -76,6 +77,8 @@ static        const struct htmldata htmltags[TAG_MAX] = {
        {"dt",          HTML_NLAROUND},
        {"dd",          HTML_NLAROUND | HTML_INDENT},
        {"pre",         HTML_NLALL | HTML_NOINDENT},
        {"dt",          HTML_NLAROUND},
        {"dd",          HTML_NLAROUND | HTML_INDENT},
        {"pre",         HTML_NLALL | HTML_NOINDENT},
+       {"var",         0},
+       {"cite",        0},
        {"b",           0},
        {"i",           0},
        {"code",        0},
        {"b",           0},
        {"i",           0},
        {"code",        0},
@@ -234,6 +237,28 @@ print_metaf(struct html *h, enum mandoc_esc deco)
        }
 }
 
        }
 }
 
+char *
+html_make_id(const struct roff_node *n)
+{
+       const struct roff_node  *nch;
+       char                    *buf, *cp;
+
+       for (nch = n->child; nch != NULL; nch = nch->next)
+               if (nch->type != ROFFT_TEXT)
+                       return NULL;
+
+       buf = NULL;
+       deroff(&buf, n);
+
+       /* http://www.w3.org/TR/html5/dom.html#the-id-attribute */
+
+       for (cp = buf; *cp != '\0'; cp++)
+               if (*cp == ' ')
+                       *cp = '_';
+
+       return buf;
+}
+
 int
 html_strlen(const char *cp)
 {
 int
 html_strlen(const char *cp)
 {
@@ -532,18 +557,25 @@ print_otag(struct html *h, enum htmltag tag, const char *fmt, ...)
                print_byte(h, '=');
                print_byte(h, '"');
                switch (*fmt) {
                print_byte(h, '=');
                print_byte(h, '"');
                switch (*fmt) {
-               case 'M':
-                       print_href(h, arg1, arg2, 1);
-                       fmt++;
-                       break;
                case 'I':
                        print_href(h, arg1, NULL, 0);
                        fmt++;
                        break;
                case 'I':
                        print_href(h, arg1, NULL, 0);
                        fmt++;
                        break;
+               case 'M':
+                       print_href(h, arg1, arg2, 1);
+                       fmt++;
+                       break;
                case 'R':
                        print_byte(h, '#');
                case 'R':
                        print_byte(h, '#');
+                       print_encode(h, arg1, NULL, 1);
                        fmt++;
                        fmt++;
-                       /* FALLTHROUGH */
+                       break;
+               case 'T':
+                       print_encode(h, arg1, NULL, 1);
+                       print_word(h, "\" title=\"");
+                       print_encode(h, arg1, NULL, 1);
+                       fmt++;
+                       break;
                default:
                        print_encode(h, arg1, NULL, 1);
                        break;
                default:
                        print_encode(h, arg1, NULL, 1);
                        break;
@@ -577,13 +609,21 @@ print_otag(struct html *h, enum htmltag tag, const char *fmt, ...)
                        SCALE_VS_INIT(su, i);
                        break;
                case 'w':
                        SCALE_VS_INIT(su, i);
                        break;
                case 'w':
-               case 'W':
                        if ((arg2 = va_arg(ap, char *)) == NULL)
                                break;
                        su = &mysu;
                        a2width(arg2, su);
                        if ((arg2 = va_arg(ap, char *)) == NULL)
                                break;
                        su = &mysu;
                        a2width(arg2, su);
-                       if (fmt[-1] == 'W')
+                       if (*fmt == '+') {
+                               /* Increase to make even bold text fit. */
+                               su->scale *= 1.2;
+                               /* Add padding. */
+                               su->scale += 3.0;
+                               fmt++;
+                       }
+                       if (*fmt == '-') {
                                su->scale *= -1.0;
                                su->scale *= -1.0;
+                               fmt++;
+                       }
                        break;
                default:
                        abort();
                        break;
                default:
                        abort();