diff options
| author | Simon Tatham <anakin@pobox.com> | 2004-06-27 12:23:38 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2004-06-27 12:23:38 +0000 |
| commit | d9b0f4031a36b4a7348b21e6a0933f0417e22ab3 (patch) | |
| tree | 505997c13af236b2d9ca0fdde893d721ae1333b7 | |
| parent | 765012cad1a36c9bb3094c66d055a3b612e4c3a2 (diff) | |
| download | halibut-d9b0f4031a36b4a7348b21e6a0933f0417e22ab3.zip halibut-d9b0f4031a36b4a7348b21e6a0933f0417e22ab3.tar.gz halibut-d9b0f4031a36b4a7348b21e6a0933f0417e22ab3.tar.bz2 halibut-d9b0f4031a36b4a7348b21e6a0933f0417e22ab3.tar.xz | |
Fix up the restrict_charset and output_charset configuration for the
HTML backend. After an argument with James in which it transpired
that we each thought it was absolutely obvious which one
\cfg{html-charset} ought to map to, and each of us was thinking of a
different one, I've decided that this implies it _isn't_ obvious,
and hence there is no single \cfg{html-charset} directive at all.
Instead, we have \cfg{html-restrict-charset} and \cfg{html-output-
charset}, and any naive user who `just wants to change character
set' is just going to have to RTFM and figure out which one they
mean.
[originally from svn r4313]
| -rw-r--r-- | bk_html.c | 27 |
1 files changed, 10 insertions, 17 deletions
@@ -16,17 +16,6 @@ * nav_prev_text, nav_next_text, nav_separator, * index_main_sep, index_multi_sep, pre_versionid, * post_versionid - * * Some means of specifying the distinction between - * restrict-charset and output-charset. It seems to me that - * `html-charset' is output-charset, and that - * restrict-charset usually wants to be either output-charset - * or UTF-8 (the latter indicating that any Unicode character - * is fair game and it will be specified using &#foo; if it - * isn't in output-charset). However, since XHTML defaults to - * UTF-8 and it's fiddly to tell it otherwise, it's just - * possible that some user may need to set restrict-charset - * to their charset of choice while leaving _output_-charset - * at UTF-8. Figure out some configuration, and apply it. * * - nonbreaking spaces. * @@ -142,7 +131,7 @@ typedef struct { * level. */ FILE *fp; - int charset; + int charset, restrict_charset; charset_state cstate; int ver; enum { @@ -242,7 +231,7 @@ static htmlconfig html_configure(paragraph *source) { ret.head_end = ret.body_tag = ret.body_start = ret.body_end = ret.addr_start = ret.addr_end = ret.nav_attr = NULL; ret.author = ret.description = NULL; - ret.restrict_charset = CS_ASCII; + ret.restrict_charset = CS_UTF8; ret.output_charset = CS_ASCII; ret.htmlver = HTML_4; ret.index_text = L"Index"; @@ -287,10 +276,13 @@ static htmlconfig html_configure(paragraph *source) { if (!ustrnicmp(k, L"xhtml-", 6)) k++; /* treat `xhtml-' and `html-' the same */ - if (!ustricmp(k, L"html-charset")) { + if (!ustricmp(k, L"html-restrict-charset")) { char *csname = utoa_dup(uadv(k), CS_ASCII); - ret.restrict_charset = ret.output_charset = - charset_from_localenc(csname); + ret.restrict_charset = charset_from_localenc(csname); + sfree(csname); + } else if (!ustricmp(k, L"html-output-charset")) { + char *csname = utoa_dup(uadv(k), CS_ASCII); + ret.output_charset = charset_from_localenc(csname); sfree(csname); } else if (!ustricmp(k, L"html-version")) { wchar_t *vername = uadv(k); @@ -732,6 +724,7 @@ void html_backend(paragraph *sourceform, keywordlist *keywords, ho.fp = fopen(f->filename, "w"); ho.charset = conf.output_charset; + ho.restrict_charset = conf.restrict_charset; ho.cstate = charset_init_state; ho.ver = conf.htmlver; ho.state = HO_NEUTRAL; @@ -1584,7 +1577,7 @@ static void html_words(htmloutput *ho, word *words, int flags, else html_text(ho, cfg->rquote); } else { - if (cvt_ok(ho->charset, w->text) || !w->alt) + if (cvt_ok(ho->restrict_charset, w->text) || !w->alt) html_text(ho, w->text); else html_words(ho, w->alt, flags, file, keywords, cfg); |