Print this page
9718 update mandoc to 1.14.4
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/mandoc/roff_html.c
+++ new/usr/src/cmd/mandoc/roff_html.c
1 -/* $Id: roff_html.c,v 1.11 2017/06/24 14:38:33 schwarze Exp $ */
1 +/* $Id: roff_html.c,v 1.12 2018/06/25 14:53:58 schwarze Exp $ */
2 2 /*
3 3 * Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
4 - * Copyright (c) 2014, 2017 Ingo Schwarze <schwarze@openbsd.org>
4 + * Copyright (c) 2014, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
5 5 *
6 6 * Permission to use, copy, modify, and distribute this software for any
7 7 * purpose with or without fee is hereby granted, provided that the above
8 8 * copyright notice and this permission notice appear in all copies.
9 9 *
10 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 17 */
18 18 #include <sys/types.h>
19 19
20 20 #include <assert.h>
21 21 #include <stddef.h>
22 22
23 23 #include "mandoc.h"
24 24 #include "roff.h"
25 25 #include "out.h"
26 26 #include "html.h"
27 27
28 28 #define ROFF_HTML_ARGS struct html *h, const struct roff_node *n
29 29
30 30 typedef void (*roff_html_pre_fp)(ROFF_HTML_ARGS);
31 31
32 32 static void roff_html_pre_br(ROFF_HTML_ARGS);
33 33 static void roff_html_pre_ce(ROFF_HTML_ARGS);
34 34 static void roff_html_pre_sp(ROFF_HTML_ARGS);
35 35
36 36 static const roff_html_pre_fp roff_html_pre_acts[ROFF_MAX] = {
37 37 roff_html_pre_br, /* br */
38 38 roff_html_pre_ce, /* ce */
39 39 NULL, /* ft */
40 40 NULL, /* ll */
41 41 NULL, /* mc */
42 42 NULL, /* po */
43 43 roff_html_pre_ce, /* rj */
44 44 roff_html_pre_sp, /* sp */
45 45 NULL, /* ta */
46 46 NULL, /* ti */
47 47 };
48 48
49 49
50 50 void
51 51 roff_html_pre(struct html *h, const struct roff_node *n)
52 52 {
53 53 assert(n->tok < ROFF_MAX);
54 54 if (roff_html_pre_acts[n->tok] != NULL)
55 55 (*roff_html_pre_acts[n->tok])(h, n);
56 56 }
57 57
58 58 static void
59 59 roff_html_pre_br(ROFF_HTML_ARGS)
60 60 {
61 61 struct tag *t;
62 62
63 63 t = print_otag(h, TAG_DIV, "");
64 64 print_text(h, "\\~"); /* So the div isn't empty. */
65 65 print_tagq(h, t);
66 66 }
67 67
68 68 static void
69 69 roff_html_pre_ce(ROFF_HTML_ARGS)
70 70 {
71 71 for (n = n->child->next; n != NULL; n = n->next) {
72 72 if (n->type == ROFFT_TEXT) {
73 73 if (n->flags & NODE_LINE)
74 74 roff_html_pre_br(h, n);
↓ open down ↓ |
60 lines elided |
↑ open up ↑ |
75 75 print_text(h, n->string);
76 76 } else
77 77 roff_html_pre(h, n);
78 78 }
79 79 roff_html_pre_br(h, n);
80 80 }
81 81
82 82 static void
83 83 roff_html_pre_sp(ROFF_HTML_ARGS)
84 84 {
85 - struct roffsu su;
86 -
87 - SCALE_VS_INIT(&su, 1);
88 - if ((n = n->child) != NULL) {
89 - if (a2roffsu(n->string, &su, SCALE_VS) == NULL)
90 - su.scale = 1.0;
91 - else if (su.scale < 0.0)
92 - su.scale = 0.0;
93 - }
94 - print_otag(h, TAG_DIV, "suh", &su);
95 - print_text(h, "\\~"); /* So the div isn't empty. */
85 + print_paragraph(h);
96 86 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX