5 static void html_doc_beg(struct doc
*doc
)
7 doc_write(doc
, "<body>\n");
10 static void html_doc_end(struct doc
*doc
)
12 doc_write(doc
, "\n</body>\n");
15 static int digits(int n
)
23 static char *putint(char *s
, int n
)
27 for (i
= 0; i
< d
; i
++) {
28 s
[d
- i
- 1] = n
% 10 + '0';
35 static char *putstr(char *dst
, char *src
)
38 return strchr(dst
, '\0');
41 static void html_head_beg(struct doc
*doc
, int level
)
46 s
= putint(s
, level
+ 1);
51 static void html_head_end(struct doc
*doc
, int level
)
56 s
= putint(s
, level
+ 1);
61 static void html_par_beg(struct doc
*doc
)
63 doc_write(doc
, "<p>\n");
66 static void html_par_end(struct doc
*doc
)
70 static void html_put(struct doc
*doc
, char *s
)
75 static void html_list_beg(struct doc
*doc
)
77 doc_write(doc
, "<ul>\n");
80 static void html_list_end(struct doc
*doc
)
82 doc_write(doc
, "</ul>\n");
85 static void html_item_beg(struct doc
*doc
)
87 doc_write(doc
, "<li>");
90 static void html_item_end(struct doc
*doc
)
92 doc_write(doc
, "</li>\n");
95 static void html_block_beg(struct doc
*doc
, char *beg
, int block
)
99 doc_write(doc
, "<pre>");
102 doc_write(doc
, "<p><i>");
109 static void html_block_end(struct doc
*doc
, char *end
, int block
)
113 doc_write(doc
, "</pre>");
116 doc_write(doc
, "</i>\n");
123 static void html_put_link(struct doc
*doc
, char *s
)
128 while ((link
= strchr(desc
, ':'))) {
135 doc_write(doc
, "<a href=\"");
136 doc_write(doc
, link
? link
+ 2 : s
);
137 doc_write(doc
, "\">");
138 doc_write(doc
, desc
);
139 doc_write(doc
, "</a>");
142 static void html_put_txt(struct doc
*doc
, char *s
, int marker
)
146 doc_write(doc
, "<b>");
148 doc_write(doc
, "</b>");
154 html_put_link(doc
, s
);
167 static void html_table_beg(struct doc
*doc
, int columns
)
169 doc_write(doc
, "<table>\n");
172 static void html_table_end(struct doc
*doc
)
174 doc_write(doc
, "</table>\n");
177 static void html_row_beg(struct doc
*doc
)
179 doc_write(doc
, "<tr>");
182 static void html_row_end(struct doc
*doc
)
184 doc_write(doc
, "</tr>\n");
187 static void html_entry_beg(struct doc
*doc
)
189 doc_write(doc
, "<td>");
192 static void html_entry_end(struct doc
*doc
)
194 doc_write(doc
, "</td>");
197 struct fmt_ops html_ops
= {
198 .doc_beg
= html_doc_beg
,
199 .doc_end
= html_doc_end
,
200 .head_beg
= html_head_beg
,
201 .head_end
= html_head_end
,
202 .par_beg
= html_par_beg
,
203 .par_end
= html_par_end
,
204 .list_beg
= html_list_beg
,
205 .list_end
= html_list_end
,
206 .item_beg
= html_item_beg
,
207 .item_end
= html_item_end
,
208 .table_beg
= html_table_beg
,
209 .table_end
= html_table_end
,
210 .row_beg
= html_row_beg
,
211 .row_end
= html_row_end
,
212 .entry_beg
= html_entry_beg
,
213 .entry_end
= html_entry_end
,
214 .block_beg
= html_block_beg
,
215 .block_end
= html_block_end
,
217 .put_txt
= html_put_txt