From 041d7c37a5efa3ccf6d630455b11e2704333525c Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Tue, 16 Jun 2009 22:19:51 +0200 Subject: [PATCH] #116: Added ``html_output_encoding`` config value. --- CHANGES | 4 +++- doc/config.rst | 8 ++++++++ sphinx/builders/html.py | 3 ++- sphinx/config.py | 1 + sphinx/quickstart.py | 2 +- sphinx/themes/basic/layout.html | 2 +- 6 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index acce76f73..24fbb7b13 100644 --- a/CHANGES +++ b/CHANGES @@ -1,7 +1,9 @@ Release 1.0 (in development) ============================ -* Add ``latexpdf`` target in quickstart Makefile. +* Added ``html_output_encoding`` config value. + +* Added ``latexpdf`` target in quickstart Makefile. * #200: Added ``Sphinx.add_stylesheet()``. diff --git a/doc/config.rst b/doc/config.rst index dc9fe096b..3ce8d53bb 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -536,6 +536,14 @@ that use Sphinx' HTMLWriter class. .. versionadded:: 0.4 +.. confval:: html_output_encoding + + Encoding of HTML output files. Default is ``'utf-8'``. Note that this + encoding name must both be a valid Python encoding name and a valid HTML + ``charset`` value. + + .. versionadded:: 1.0 + .. confval:: htmlhelp_basename Output file base name for HTML help builder. Default is ``'pydoc'``. diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py index 5338c947c..c80b20a37 100644 --- a/sphinx/builders/html.py +++ b/sphinx/builders/html.py @@ -665,6 +665,7 @@ class StandaloneHTMLBuilder(Builder): ctx['pathto'] = pathto ctx['hasdoc'] = lambda name: name in self.env.all_docs ctx['customsidebar'] = self.config.html_sidebars.get(pagename) + ctx['encoding'] = encoding = self.config.html_output_encoding ctx['toctree'] = lambda **kw: self._get_local_toctree(pagename, **kw) ctx.update(addctx) @@ -677,7 +678,7 @@ class StandaloneHTMLBuilder(Builder): # outfilename's path is in general different from self.outdir ensuredir(path.dirname(outfilename)) try: - f = codecs.open(outfilename, 'w', 'utf-8') + f = codecs.open(outfilename, 'w', encoding) try: f.write(output) finally: diff --git a/sphinx/config.py b/sphinx/config.py index 147082890..5f23d6d99 100644 --- a/sphinx/config.py +++ b/sphinx/config.py @@ -86,6 +86,7 @@ class Config(object): html_show_copyright = (True, 'html'), html_show_sphinx = (True, 'html'), html_context = ({}, 'html'), + html_output_encoding = ('utf-8', 'html'), # HTML help only options htmlhelp_basename = (lambda self: make_filename(self.project), None), diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py index 2f1f8720f..3cc97fed5 100644 --- a/sphinx/quickstart.py +++ b/sphinx/quickstart.py @@ -56,7 +56,7 @@ templates_path = ['%(dot)stemplates'] source_suffix = '%(suffix)s' # The encoding of source files. -#source_encoding = 'utf-8' +#source_encoding = 'utf-8-sig' # The master toctree document. master_doc = '%(master_str)s' diff --git a/sphinx/themes/basic/layout.html b/sphinx/themes/basic/layout.html index dfee95ad5..2f643c5da 100644 --- a/sphinx/themes/basic/layout.html +++ b/sphinx/themes/basic/layout.html @@ -91,7 +91,7 @@ - + {{ metatags }} {%- if not embedded %} {%- set titlesuffix = " — "|safe + docstitle|e %}