]> git.cameronkatri.com Git - mandoc.git/blobdiff - html.c
Remove \s TODO: these are intelligently ignored along with \m and \M.
[mandoc.git] / html.c
diff --git a/html.c b/html.c
index 0ec9bc91f62938b1282773d2053cdbc82f90c208..5e19b09cfc94a7c74a136546cd04431ee490eacf 100644 (file)
--- a/html.c
+++ b/html.c
@@ -1,6 +1,6 @@
-/*     $Id: html.c,v 1.103 2010/06/25 19:50:23 kristaps Exp $ */
+/*     $Id: html.c,v 1.107 2010/07/16 22:33:30 kristaps Exp $ */
 /*
 /*
- * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -217,28 +217,36 @@ print_gen_head(struct html *h)
 static void
 print_spec(struct html *h, const char *p, size_t len)
 {
 static void
 print_spec(struct html *h, const char *p, size_t len)
 {
+       int              cp;
        const char      *rhs;
        size_t           sz;
 
        const char      *rhs;
        size_t           sz;
 
-       rhs = chars_a2ascii(h->symtab, p, len, &sz);
-
-       if (NULL == rhs) 
+       if ((cp = chars_spec2cp(h->symtab, p, len)) > 0) {
+               printf("&#%d;", cp);
+               return;
+       } else if (-1 == cp)
                return;
                return;
-       fwrite(rhs, 1, sz, stdout);
+
+       if (NULL != (rhs = chars_spec2str(h->symtab, p, len, &sz)))
+               fwrite(rhs, 1, sz, stdout);
 }
 
 
 static void
 print_res(struct html *h, const char *p, size_t len)
 {
 }
 
 
 static void
 print_res(struct html *h, const char *p, size_t len)
 {
+       int              cp;
        const char      *rhs;
        size_t           sz;
 
        const char      *rhs;
        size_t           sz;
 
-       rhs = chars_a2res(h->symtab, p, len, &sz);
-
-       if (NULL == rhs)
+       if ((cp = chars_res2cp(h->symtab, p, len)) > 0) {
+               printf("&#%d;", cp);
+               return;
+       } else if (-1 == cp)
                return;
                return;
-       fwrite(rhs, 1, sz, stdout);
+
+       if (NULL != (rhs = chars_res2str(h->symtab, p, len, &sz)))
+               fwrite(rhs, 1, sz, stdout);
 }
 
 
 }
 
 
@@ -393,8 +401,15 @@ print_otag(struct html *h, enum htmltag tag,
                t = NULL;
 
        if ( ! (HTML_NOSPACE & h->flags))
                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("&#160;");
+               }
 
        /* Print out the tag name and attributes. */
 
 
        /* Print out the tag name and attributes. */
 
@@ -484,11 +499,11 @@ print_doctype(struct html *h)
 
 
 void
 
 
 void
-print_text(struct html *h, const char *p)
+print_text(struct html *h, const char *word)
 {
 
 {
 
-       if (*p && 0 == *(p + 1))
-               switch (*p) {
+       if (word[0] && '\0' == word[1])
+               switch (word[0]) {
                case('.'):
                        /* FALLTHROUGH */
                case(','):
                case('.'):
                        /* FALLTHROUGH */
                case(','):
@@ -511,19 +526,26 @@ print_text(struct html *h, const char *p)
                        break;
                }
 
                        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("&#160;");
+       }
 
 
-       assert(p);
-       if ( ! print_encode(h, p, 0))
+       assert(word);
+       if ( ! print_encode(h, word, 0))
                h->flags &= ~HTML_NOSPACE;
 
        /* 
         * Note that we don't process the pipe: the parser sees it as
         * punctuation, but we don't in terms of typography.
         */
                h->flags &= ~HTML_NOSPACE;
 
        /* 
         * Note that we don't process the pipe: the parser sees it as
         * punctuation, but we don't in terms of typography.
         */
-       if (*p && 0 == *(p + 1))
-               switch (*p) {
+       if (word[0] && '\0' == word[1])
+               switch (word[0]) {
                case('('):
                        /* FALLTHROUGH */
                case('['):
                case('('):
                        /* FALLTHROUGH */
                case('['):