=================================================================== RCS file: /cvs/mandoc/tbl_html.c,v retrieving revision 1.20 retrieving revision 1.23 diff -u -p -r1.20 -r1.23 --- mandoc/tbl_html.c 2017/02/05 18:15:39 1.20 +++ mandoc/tbl_html.c 2017/07/31 16:14:10 1.23 @@ -1,4 +1,4 @@ -/* $Id: tbl_html.c,v 1.20 2017/02/05 18:15:39 schwarze Exp $ */ +/* $Id: tbl_html.c,v 1.23 2017/07/31 16:14:10 schwarze Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons * Copyright (c) 2014, 2015, 2017 Ingo Schwarze @@ -31,22 +31,51 @@ static void html_tblopen(struct html *, const struct tbl_span *); static size_t html_tbl_len(size_t, void *); static size_t html_tbl_strlen(const char *, void *); +static size_t html_tbl_sulen(const struct roffsu *, void *); static size_t html_tbl_len(size_t sz, void *arg) { - return sz; } static size_t html_tbl_strlen(const char *p, void *arg) { - return strlen(p); } +static size_t +html_tbl_sulen(const struct roffsu *su, void *arg) +{ + if (su->scale < 0.0) + return 0; + + switch (su->unit) { + case SCALE_FS: /* 2^16 basic units */ + return su->scale * 65536.0 / 24.0; + case SCALE_IN: /* 10 characters per inch */ + return su->scale * 10.0; + case SCALE_CM: /* 2.54 cm per inch */ + return su->scale * 10.0 / 2.54; + case SCALE_PC: /* 6 pica per inch */ + case SCALE_VS: + return su->scale * 10.0 / 6.0; + case SCALE_EN: + case SCALE_EM: + return su->scale; + case SCALE_PT: /* 12 points per pica */ + return su->scale * 10.0 / 6.0 / 12.0; + case SCALE_BU: /* 24 basic units per character */ + return su->scale / 24.0; + case SCALE_MM: /* 1/1000 inch */ + return su->scale / 100.0; + default: + abort(); + } +} + static void html_tblopen(struct html *h, const struct tbl_span *sp) { @@ -56,7 +85,8 @@ html_tblopen(struct html *h, const struct tbl_span *sp if (h->tbl.cols == NULL) { h->tbl.len = html_tbl_len; h->tbl.slen = html_tbl_strlen; - tblcalc(&h->tbl, sp, 0); + h->tbl.sulen = html_tbl_sulen; + tblcalc(&h->tbl, sp, 0, 0); } assert(NULL == h->tblt);