summaryrefslogtreecommitdiff
path: root/docutils
diff options
context:
space:
mode:
authorgoodger <goodger@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2005-04-27 21:04:03 +0000
committergoodger <goodger@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2005-04-27 21:04:03 +0000
commit810c824a20b0fc98e291a81914be984dee8770fe (patch)
tree68ecfce7d3585664dfa81205845e1bb9cbbc4324 /docutils
parentcc4c356a64f2017e20092e2a782a353baee3b1ba (diff)
downloaddocutils-810c824a20b0fc98e291a81914be984dee8770fe.tar.gz
fixed encoding/charset values in "html_prolog" & "html_head" parts, which should not have been interpolated
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@3268 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils')
-rw-r--r--docutils/docs/api/publisher.txt14
-rw-r--r--docutils/docutils/writers/html4css1.py12
-rw-r--r--docutils/test/DocutilsTestSupport.py21
3 files changed, 32 insertions, 15 deletions
diff --git a/docutils/docs/api/publisher.txt b/docutils/docs/api/publisher.txt
index 55883f1ae..66aaa06fb 100644
--- a/docutils/docs/api/publisher.txt
+++ b/docutils/docs/api/publisher.txt
@@ -132,11 +132,21 @@ html_body
html_head
``parts['html_head']`` contains the HTML ``<head>`` content, less
the stylesheet link and the ``<head>`` and ``</head>`` tags
- themselves.
+ themselves. The "Content-Type" meta tag's "charset" value is left
+ unresolved, as "%s"::
+
+ <meta http-equiv="Content-Type" content="text/html; charset=%s" />
+
+ The interpolation should be done by client code.
html_prolog
``parts['html_prolog]`` contains the XML declaration and the
- doctype declaration.
+ doctype declaration. The XML declaration's "encoding" attribute's
+ value is left unresolved, as "%s"::
+
+ <?xml version="1.0" encoding="%s" ?>
+
+ The interpolation should be done by client code.
html_subtitle
``parts['html_subtitle']`` contains the document subtitle,
diff --git a/docutils/docutils/writers/html4css1.py b/docutils/docutils/writers/html4css1.py
index 9323565d7..fc602cdbd 100644
--- a/docutils/docutils/writers/html4css1.py
+++ b/docutils/docutils/writers/html4css1.py
@@ -186,8 +186,8 @@ class HTMLTranslator(nodes.NodeVisitor):
'xhtml1-transitional.dtd">\n')
head_prefix_template = ('<html xmlns="http://www.w3.org/1999/xhtml"'
' xml:lang="%s" lang="%s">\n<head>\n')
- content_type = ('<meta http-equiv="Content-Type" content="text/html; '
- 'charset=%s" />\n')
+ content_type = ('<meta http-equiv="Content-Type"'
+ ' content="text/html; charset=%s" />\n')
generator = ('<meta name="generator" content="Docutils %s: '
'http://docutils.sourceforge.net/" />\n')
stylesheet_link = '<link rel="stylesheet" href="%s" type="text/css" />\n'
@@ -207,7 +207,8 @@ class HTMLTranslator(nodes.NodeVisitor):
if settings.xml_declaration:
self.head_prefix.append(self.xml_declaration
% settings.output_encoding)
- self.html_prolog.append(self.xml_declaration) # not interpolated
+ # encoding not interpolated:
+ self.html_prolog.append(self.xml_declaration)
self.head_prefix.extend([self.doctype,
self.head_prefix_template % (lcode, lcode)])
self.html_prolog.append(self.doctype)
@@ -248,7 +249,7 @@ class HTMLTranslator(nodes.NodeVisitor):
self.subtitle = []
self.header = []
self.footer = []
- self.html_head = []
+ self.html_head = [self.content_type] # charset not interpolated
self.html_title = []
self.html_subtitle = []
self.html_body = []
@@ -632,7 +633,8 @@ class HTMLTranslator(nodes.NodeVisitor):
self.fragment.extend(self.body)
self.body_prefix.append(self.starttag(node, 'div', CLASS='document'))
self.body_suffix.insert(0, '</div>\n')
- self.html_head.extend(self.head)
+ # skip content-type meta tag with interpolated charset value:
+ self.html_head.extend(self.head[1:])
self.html_body.extend(self.body_prefix[1:] + self.body_pre_docinfo
+ self.docinfo + self.body
+ self.body_suffix[:-1])
diff --git a/docutils/test/DocutilsTestSupport.py b/docutils/test/DocutilsTestSupport.py
index 87a200598..d9f78f774 100644
--- a/docutils/test/DocutilsTestSupport.py
+++ b/docutils/test/DocutilsTestSupport.py
@@ -731,11 +731,16 @@ class HtmlWriterPublishPartsTestCase(WriterPublishTestCase):
expected = self.expected % {'version': docutils.__version__}
self.compare_output(self.input, output, expected)
- standard_meta_value_template = """\
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils %s: http://docutils.sourceforge.net/" />
-"""
- standard_meta_value = standard_meta_value_template % docutils.__version__
+
+ standard_content_type_template = ('<meta http-equiv="Content-Type"'
+ ' content="text/html; charset=%s" />\n')
+ standard_generator_template = (
+ '<meta name="generator"'
+ ' content="Docutils %s: http://docutils.sourceforge.net/" />\n')
+ standard_html_meta_value = (
+ standard_content_type_template
+ + standard_generator_template % docutils.__version__)
+ standard_meta_value = standard_html_meta_value % 'utf-8'
standard_stylesheet_value = ('<link rel="stylesheet" href="default.css" '
'type="text/css" />\n')
standard_html_prolog = """\
@@ -745,16 +750,16 @@ class HtmlWriterPublishPartsTestCase(WriterPublishTestCase):
def format_output(self, parts):
"""Minimize & standardize the output."""
- # remove redundant bits:
+ # remove redundant parts:
del parts['whole']
assert parts['body'] == parts['fragment']
del parts['body']
- # remove standard bits:
+ # remove standard portions:
parts['meta'] = parts['meta'].replace(self.standard_meta_value, '')
if parts['stylesheet'] == self.standard_stylesheet_value:
del parts['stylesheet']
parts['html_head'] = parts['html_head'].replace(
- self.standard_meta_value, '...')
+ self.standard_html_meta_value, '...')
parts['html_prolog'] = parts['html_prolog'].replace(
self.standard_html_prolog, '')
# remove empty values: