Print this page
9718 update mandoc to 1.14.4
   1 /*      $Id: tbl_html.c,v 1.23 2017/07/31 16:14:10 schwarze Exp $ */
   2 /*
   3  * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
   4  * Copyright (c) 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
   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 "config.h"
  19 
  20 #include <sys/types.h>
  21 


  62         case SCALE_PC:  /* 6 pica per inch */
  63         case SCALE_VS:
  64                 return su->scale * 10.0 / 6.0;
  65         case SCALE_EN:
  66         case SCALE_EM:
  67                 return su->scale;
  68         case SCALE_PT:  /* 12 points per pica */
  69                 return su->scale * 10.0 / 6.0 / 12.0;
  70         case SCALE_BU:  /* 24 basic units per character */
  71                 return su->scale / 24.0;
  72         case SCALE_MM:  /* 1/1000 inch */
  73                 return su->scale / 100.0;
  74         default:
  75                 abort();
  76         }
  77 }
  78 
  79 static void
  80 html_tblopen(struct html *h, const struct tbl_span *sp)
  81 {
  82         struct tag      *t;
  83         int              ic;
  84 
  85         if (h->tbl.cols == NULL) {
  86                 h->tbl.len = html_tbl_len;
  87                 h->tbl.slen = html_tbl_strlen;
  88                 h->tbl.sulen = html_tbl_sulen;
  89                 tblcalc(&h->tbl, sp, 0, 0);
  90         }
  91 
  92         assert(NULL == h->tblt);
  93         h->tblt = print_otag(h, TAG_TABLE, "c", "tbl");
  94 
  95         t = print_otag(h, TAG_COLGROUP, "");
  96         for (ic = 0; ic < sp->opts->cols; ic++)
  97                 print_otag(h, TAG_COL, "shw", h->tbl.cols[ic].width);
  98         print_tagq(h, t);
  99 }
 100 
 101 void
 102 print_tblclose(struct html *h)
 103 {
 104 
 105         assert(h->tblt);
 106         print_tagq(h, h->tblt);
 107         h->tblt = NULL;
 108 }
 109 
 110 void
 111 print_tbl(struct html *h, const struct tbl_span *sp)
 112 {
 113         const struct tbl_dat *dp;
 114         struct tag      *tt;
 115         int              ic;
 116 
 117         /* Inhibit printing of spaces: we do padding ourselves. */
 118 


   1 /*      $Id: tbl_html.c,v 1.24 2018/06/25 13:45:57 schwarze Exp $ */
   2 /*
   3  * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
   4  * Copyright (c) 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
   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 "config.h"
  19 
  20 #include <sys/types.h>
  21 


  62         case SCALE_PC:  /* 6 pica per inch */
  63         case SCALE_VS:
  64                 return su->scale * 10.0 / 6.0;
  65         case SCALE_EN:
  66         case SCALE_EM:
  67                 return su->scale;
  68         case SCALE_PT:  /* 12 points per pica */
  69                 return su->scale * 10.0 / 6.0 / 12.0;
  70         case SCALE_BU:  /* 24 basic units per character */
  71                 return su->scale / 24.0;
  72         case SCALE_MM:  /* 1/1000 inch */
  73                 return su->scale / 100.0;
  74         default:
  75                 abort();
  76         }
  77 }
  78 
  79 static void
  80 html_tblopen(struct html *h, const struct tbl_span *sp)
  81 {



  82         if (h->tbl.cols == NULL) {
  83                 h->tbl.len = html_tbl_len;
  84                 h->tbl.slen = html_tbl_strlen;
  85                 h->tbl.sulen = html_tbl_sulen;
  86                 tblcalc(&h->tbl, sp, 0, 0);
  87         }

  88         assert(NULL == h->tblt);
  89         h->tblt = print_otag(h, TAG_TABLE, "c", "tbl");





  90 }
  91 
  92 void
  93 print_tblclose(struct html *h)
  94 {
  95 
  96         assert(h->tblt);
  97         print_tagq(h, h->tblt);
  98         h->tblt = NULL;
  99 }
 100 
 101 void
 102 print_tbl(struct html *h, const struct tbl_span *sp)
 103 {
 104         const struct tbl_dat *dp;
 105         struct tag      *tt;
 106         int              ic;
 107 
 108         /* Inhibit printing of spaces: we do padding ourselves. */
 109