[BACK]Return to roff_html.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Annotation of mandoc/roff_html.c, Revision 1.9

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

CVSweb