Lines Matching refs:h
18 #include "config.h"
20 #include <sys/types.h>
22 #include <assert.h>
23 #include <ctype.h>
24 #include <stdarg.h>
25 #include <stdio.h>
26 #include <stdint.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #include <unistd.h>
31 #include "mandoc.h"
32 #include "mandoc_aux.h"
33 #include "out.h"
34 #include "html.h"
35 #include "main.h"
134 struct html *h;
144 h = mandoc_calloc(1, sizeof(struct html));
146 h->tags.head = NULL;
147 h->symtab = mchars;
152 h->style = v;
155 h->base_man = v;
158 h->base_includes = v;
161 h->oflags |= HTML_FRAGMENT;
167 return(h);
174 struct html *h;
176 h = (struct html *)p;
178 while ((tag = h->tags.head) != NULL) {
179 h->tags.head = tag->next;
183 free(h);
187 print_gen_head(struct html *h)
194 print_otag(h, TAG_META, 1, tag);
199 t = print_otag(h, TAG_STYLE, 0, NULL);
200 print_text(h, "table.head, table.foot { width: 100%; }\n"
206 print_tagq(h, t);
208 if (h->style) {
212 tag[1].val = h->style;
217 print_otag(h, TAG_LINK, 4, tag);
222 print_metaf(struct html *h, enum mandoc_esc deco)
228 font = h->metal;
249 if (h->metaf) {
250 print_tagq(h, h->metaf);
251 h->metaf = NULL;
254 h->metal = h->metac;
255 h->metac = font;
259 h->metaf = print_otag(h, TAG_I, 0, NULL);
262 h->metaf = print_otag(h, TAG_B, 0, NULL);
265 h->metaf = print_otag(h, TAG_B, 0, NULL);
266 print_otag(h, TAG_I, 0, NULL);
359 print_encode(struct html *h, const char *p, int norecurse)
371 if (HTML_SKIPCHAR & h->flags && '\\' != *p) {
372 h->flags &= ~HTML_SKIPCHAR;
405 print_metaf(h, esc);
408 h->flags |= HTML_SKIPCHAR;
414 if (h->flags & HTML_SKIPCHAR) {
415 h->flags &= ~HTML_SKIPCHAR;
430 c = mchars_spec2cp(h->symtab, seq, len);
459 print_attr(struct html *h, const char *key, const char *val)
462 (void)print_encode(h, val, 1);
467 print_otag(struct html *h, enum htmltag tag,
478 t->next = h->tags.head;
479 h->tags.head = t;
483 if ( ! (HTML_NOSPACE & h->flags))
486 if ( ! (HTML_KEEP & h->flags)) {
487 if (HTML_PREKEEP & h->flags)
488 h->flags |= HTML_KEEP;
494 if ( ! (h->flags & HTML_NONOSPACE))
495 h->flags &= ~HTML_NOSPACE;
497 h->flags |= HTML_NOSPACE;
503 print_attr(h, htmlattrs[p[i].key], p[i].val);
512 h->flags |= HTML_NOSPACE;
521 print_ctag(struct html *h, struct tag *tag)
528 if (tag == h->metaf)
529 h->metaf = NULL;
530 if (tag == h->tblt)
531 h->tblt = NULL;
535 h->flags |= HTML_NOSPACE;
539 h->tags.head = tag->next;
544 print_gen_decls(struct html *h)
551 print_text(struct html *h, const char *word)
554 if ( ! (HTML_NOSPACE & h->flags)) {
556 if ( ! (HTML_KEEP & h->flags)) {
557 if (HTML_PREKEEP & h->flags)
558 h->flags |= HTML_KEEP;
564 assert(NULL == h->metaf);
565 switch (h->metac) {
567 h->metaf = print_otag(h, TAG_I, 0, NULL);
570 h->metaf = print_otag(h, TAG_B, 0, NULL);
573 h->metaf = print_otag(h, TAG_B, 0, NULL);
574 print_otag(h, TAG_I, 0, NULL);
581 if ( ! print_encode(h, word, 0)) {
582 if ( ! (h->flags & HTML_NONOSPACE))
583 h->flags &= ~HTML_NOSPACE;
584 h->flags &= ~HTML_NONEWLINE;
586 h->flags |= HTML_NOSPACE | HTML_NONEWLINE;
588 if (h->metaf) {
589 print_tagq(h, h->metaf);
590 h->metaf = NULL;
593 h->flags &= ~HTML_IGNDELIM;
597 print_tagq(struct html *h, const struct tag *until)
601 while ((tag = h->tags.head) != NULL) {
602 print_ctag(h, tag);
609 print_stagq(struct html *h, const struct tag *suntil)
613 while ((tag = h->tags.head) != NULL) {
616 print_ctag(h, tag);
621 print_paragraph(struct html *h)
627 t = print_otag(h, TAG_DIV, 1, &tag);
628 print_tagq(h, t);
633 bufinit(struct html *h)
636 h->buf[0] = '\0';
637 h->buflen = 0;
641 bufcat_style(struct html *h, const char *key, const char *val)
644 bufcat(h, key);
645 bufcat(h, ":");
646 bufcat(h, val);
647 bufcat(h, ";");
651 bufcat(struct html *h, const char *p)
660 h->buflen = strlcat(h->buf, p, BUFSIZ);
661 assert(h->buflen < BUFSIZ);
665 bufcat_fmt(struct html *h, const char *fmt, ...)
670 (void)vsnprintf(h->buf + (int)h->buflen,
671 BUFSIZ - h->buflen - 1, fmt, ap);
673 h->buflen = strlen(h->buf);
677 bufncat(struct html *h, const char *p, size_t sz)
680 assert(h->buflen + sz + 1 < BUFSIZ);
681 strncat(h->buf, p, sz);
682 h->buflen += sz;
686 buffmt_includes(struct html *h, const char *name)
690 pp = h->base_includes;
692 bufinit(h);
694 bufncat(h, pp, (size_t)(p - pp));
697 bufcat(h, name);
700 bufncat(h, p, 2);
706 bufcat(h, pp);
710 buffmt_man(struct html *h, const char *name, const char *sec)
714 pp = h->base_man;
716 bufinit(h);
718 bufncat(h, pp, (size_t)(p - pp));
721 bufcat(h, sec ? sec : "1");
724 bufcat_fmt(h, "%s", name);
727 bufncat(h, p, 2);
733 bufcat(h, pp);
737 bufcat_su(struct html *h, const char *p, const struct roffsu *su)
747 bufcat_fmt(h, "%s: %.2f%s;", p, v, roffscales[su->unit]);
751 bufcat_id(struct html *h, const char *src)
754 /* Cf. <http://www.w3.org/TR/html4/types.html#h-6.2>. */
757 bufcat_fmt(h, "%.2x", *src++);