version 1.184, 2014/12/20 00:20:11 |
version 1.190, 2015/10/12 00:15:31 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
* copyright notice and this permission notice appear in all copies. |
* copyright notice and this permission notice appear in all copies. |
* |
* |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES |
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR |
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|
|
#include "mandoc_aux.h" |
#include "mandoc_aux.h" |
#include "out.h" |
#include "out.h" |
#include "html.h" |
#include "html.h" |
|
#include "manconf.h" |
#include "main.h" |
#include "main.h" |
|
|
struct htmldata { |
struct htmldata { |
Line 129 static void print_attr(struct html *, const char *, c |
|
Line 130 static void print_attr(struct html *, const char *, c |
|
|
|
|
|
void * |
void * |
html_alloc(const struct mchars *mchars, char *outopts) |
html_alloc(const struct mchars *mchars, const struct manoutput *outopts) |
{ |
{ |
struct html *h; |
struct html *h; |
const char *toks[5]; |
|
char *v; |
|
|
|
toks[0] = "style"; |
|
toks[1] = "man"; |
|
toks[2] = "includes"; |
|
toks[3] = "fragment"; |
|
toks[4] = NULL; |
|
|
|
h = mandoc_calloc(1, sizeof(struct html)); |
h = mandoc_calloc(1, sizeof(struct html)); |
|
|
h->tags.head = NULL; |
h->tags.head = NULL; |
h->symtab = mchars; |
h->symtab = mchars; |
|
|
while (outopts && *outopts) |
h->style = outopts->style; |
switch (getsubopt(&outopts, UNCONST(toks), &v)) { |
h->base_man = outopts->man; |
case 0: |
h->base_includes = outopts->includes; |
h->style = v; |
if (outopts->fragment) |
break; |
h->oflags |= HTML_FRAGMENT; |
case 1: |
|
h->base_man = v; |
|
break; |
|
case 2: |
|
h->base_includes = v; |
|
break; |
|
case 3: |
|
h->oflags |= HTML_FRAGMENT; |
|
break; |
|
default: |
|
break; |
|
} |
|
|
|
return(h); |
return h; |
} |
} |
|
|
void |
void |
Line 237 print_metaf(struct html *h, enum mandoc_esc deco) |
|
Line 218 print_metaf(struct html *h, enum mandoc_esc deco) |
|
font = HTMLFONT_BI; |
font = HTMLFONT_BI; |
break; |
break; |
case ESCAPE_FONT: |
case ESCAPE_FONT: |
/* FALLTHROUGH */ |
|
case ESCAPE_FONTROMAN: |
case ESCAPE_FONTROMAN: |
font = HTMLFONT_NONE; |
font = HTMLFONT_NONE; |
break; |
break; |
default: |
default: |
abort(); |
abort(); |
/* NOTREACHED */ |
|
} |
} |
|
|
if (h->metaf) { |
if (h->metaf) { |
Line 301 html_strlen(const char *cp) |
|
Line 280 html_strlen(const char *cp) |
|
cp++; |
cp++; |
switch (mandoc_escape(&cp, NULL, NULL)) { |
switch (mandoc_escape(&cp, NULL, NULL)) { |
case ESCAPE_ERROR: |
case ESCAPE_ERROR: |
return(sz); |
return sz; |
case ESCAPE_UNICODE: |
case ESCAPE_UNICODE: |
/* FALLTHROUGH */ |
|
case ESCAPE_NUMBERED: |
case ESCAPE_NUMBERED: |
/* FALLTHROUGH */ |
|
case ESCAPE_SPECIAL: |
case ESCAPE_SPECIAL: |
|
case ESCAPE_OVERSTRIKE: |
if (skip) |
if (skip) |
skip = 0; |
skip = 0; |
else |
else |
Line 319 html_strlen(const char *cp) |
|
Line 297 html_strlen(const char *cp) |
|
break; |
break; |
} |
} |
} |
} |
return(sz); |
return sz; |
} |
} |
|
|
static int |
static int |
Line 340 print_escape(char c) |
|
Line 318 print_escape(char c) |
|
printf("""); |
printf("""); |
break; |
break; |
case ASCII_NBRSP: |
case ASCII_NBRSP: |
putchar('-'); |
printf(" "); |
break; |
break; |
case ASCII_HYPH: |
case ASCII_HYPH: |
putchar('-'); |
putchar('-'); |
/* FALLTHROUGH */ |
break; |
case ASCII_BREAK: |
case ASCII_BREAK: |
break; |
break; |
default: |
default: |
return(0); |
return 0; |
} |
} |
return(1); |
return 1; |
} |
} |
|
|
static int |
static int |
Line 389 print_encode(struct html *h, const char *p, int norecu |
|
Line 367 print_encode(struct html *h, const char *p, int norecu |
|
|
|
switch (esc) { |
switch (esc) { |
case ESCAPE_FONT: |
case ESCAPE_FONT: |
/* FALLTHROUGH */ |
|
case ESCAPE_FONTPREV: |
case ESCAPE_FONTPREV: |
/* FALLTHROUGH */ |
|
case ESCAPE_FONTBOLD: |
case ESCAPE_FONTBOLD: |
/* FALLTHROUGH */ |
|
case ESCAPE_FONTITALIC: |
case ESCAPE_FONTITALIC: |
/* FALLTHROUGH */ |
|
case ESCAPE_FONTBI: |
case ESCAPE_FONTBI: |
/* FALLTHROUGH */ |
|
case ESCAPE_FONTROMAN: |
case ESCAPE_FONTROMAN: |
if (0 == norecurse) |
if (0 == norecurse) |
print_metaf(h, esc); |
print_metaf(h, esc); |
Line 433 print_encode(struct html *h, const char *p, int norecu |
|
Line 406 print_encode(struct html *h, const char *p, int norecu |
|
if ('\0' == *p) |
if ('\0' == *p) |
nospace = 1; |
nospace = 1; |
continue; |
continue; |
|
case ESCAPE_OVERSTRIKE: |
|
if (len == 0) |
|
continue; |
|
c = seq[len - 1]; |
|
break; |
default: |
default: |
continue; |
continue; |
} |
} |
Line 445 print_encode(struct html *h, const char *p, int norecu |
|
Line 423 print_encode(struct html *h, const char *p, int norecu |
|
putchar(c); |
putchar(c); |
} |
} |
|
|
return(nospace); |
return nospace; |
} |
} |
|
|
static void |
static void |
Line 507 print_otag(struct html *h, enum htmltag tag, |
|
Line 485 print_otag(struct html *h, enum htmltag tag, |
|
if ((HTML_AUTOCLOSE | HTML_CLRLINE) & htmltags[tag].flags) |
if ((HTML_AUTOCLOSE | HTML_CLRLINE) & htmltags[tag].flags) |
putchar('\n'); |
putchar('\n'); |
|
|
return(t); |
return t; |
} |
} |
|
|
static void |
static void |