diff options
| -rw-r--r-- | CHANGES | 6 | ||||
| -rw-r--r-- | doc/builders.rst | 68 | ||||
| -rw-r--r-- | sphinx/ext/pngmath.py | 18 | ||||
| -rw-r--r-- | sphinx/htmlhelp.py | 20 | ||||
| -rw-r--r-- | sphinx/latexwriter.py | 12 | ||||
| -rw-r--r-- | sphinx/static/default.css | 2 | ||||
| -rw-r--r-- | sphinx/templates/changes/frameset.html | 2 | ||||
| -rw-r--r-- | sphinx/templates/changes/rstsource.html | 2 | ||||
| -rw-r--r-- | sphinx/templates/changes/versionchanges.html | 4 | ||||
| -rw-r--r-- | sphinx/templates/defindex.html | 6 | ||||
| -rw-r--r-- | sphinx/templates/layout.html | 18 | ||||
| -rw-r--r-- | sphinx/templates/opensearch.xml | 6 | ||||
| -rw-r--r-- | sphinx/util/jsdump.py | 5 |
13 files changed, 110 insertions, 59 deletions
@@ -161,6 +161,12 @@ New features added Bugs fixed ---------- +* Escape configuration values placed in HTML templates. + +* Fix small problems in HTML help index generation. + +* Fix LaTeX output for line blocks in tables. + * Fix "illegal unit" error when using pixel image widths/heights. * Support table captions in LaTeX output. diff --git a/doc/builders.rst b/doc/builders.rst index 21780806..508ab3c5 100644 --- a/doc/builders.rst +++ b/doc/builders.rst @@ -30,34 +30,6 @@ The builder's "name" must be given to the **-b** command-line option of Its name is ``htmlhelp``. -.. class:: PickleHTMLBuilder - - This builder produces a directory with pickle files containing mostly HTML - fragments and TOC information, for use of a web application (or custom - postprocessing tool) that doesn't use the standard HTML templates. - - See :ref:`serialization-details` for details about the output format. - - Its name is ``pickle``. (The old name ``web`` still works as well.) - - The file suffix is ``.fpickle``. The global context is called - ``globalcontext.pickle``, the search index ``searchindex.pickle``. - -.. class:: JSONHTMLBuilder - - This builder produces a directory with JSON files containing mostly HTML - fragments and TOC information, for use of a web application (or custom - postprocessing tool) that doesn't use the standard HTML templates. - - See :ref:`serialization-details` for details about the output format. - - Its name is ``json``. - - The file suffix is ``.fjson``. The global context is called - ``globalcontext.json``, the search index ``searchindex.json``. - - .. versionadded:: 0.5 - .. class:: LaTeXBuilder This builder produces a bunch of LaTeX files in the output directory. You @@ -66,6 +38,16 @@ The builder's "name" must be given to the **-b** command-line option of configuration values that customize the output of this builder, see the chapter :ref:`latex-options` for details. + .. note:: + + The produced LaTeX file uses several LaTeX packages that may not be + present in a "minimal" TeX distribution installation. For TeXLive, + the following packages need to be installed: + + * latex-recommended + * latex-extra + * fonts-recommended + Its name is ``latex``. .. class:: TextBuilder @@ -124,7 +106,35 @@ The builder's "name" must be given to the **-b** command-line option of See :ref:`serialization-details` for details about the output format. .. versionadded:: 0.5 - + +.. class:: PickleHTMLBuilder + + This builder produces a directory with pickle files containing mostly HTML + fragments and TOC information, for use of a web application (or custom + postprocessing tool) that doesn't use the standard HTML templates. + + See :ref:`serialization-details` for details about the output format. + + Its name is ``pickle``. (The old name ``web`` still works as well.) + + The file suffix is ``.fpickle``. The global context is called + ``globalcontext.pickle``, the search index ``searchindex.pickle``. + +.. class:: JSONHTMLBuilder + + This builder produces a directory with JSON files containing mostly HTML + fragments and TOC information, for use of a web application (or custom + postprocessing tool) that doesn't use the standard HTML templates. + + See :ref:`serialization-details` for details about the output format. + + Its name is ``json``. + + The file suffix is ``.fjson``. The global context is called + ``globalcontext.json``, the search index ``searchindex.json``. + + .. versionadded:: 0.5 + .. class:: ChangesBuilder This builder produces an HTML overview of all :dir:`versionadded`, diff --git a/sphinx/ext/pngmath.py b/sphinx/ext/pngmath.py index aa0d0c2e..8dd3e600 100644 --- a/sphinx/ext/pngmath.py +++ b/sphinx/ext/pngmath.py @@ -178,7 +178,14 @@ def cleanup_tempdir(app, exc): pass def html_visit_math(self, node): - fname, depth = render_math(self, '$'+node['latex']+'$') + try: + fname, depth = render_math(self, '$'+node['latex']+'$') + except MathExtError, exc: + sm = nodes.system_message(str(exc), type='WARNING', level=2, + backrefs=[], source=node['latex']) + sm.walkabout(self) + self.builder.warn('display latex %r: ' % node['latex'] + str(exc)) + raise nodes.SkipNode self.body.append('<img class="math" src="%s" alt="%s" %s/>' % (fname, self.encode(node['latex']).strip(), depth and 'style="vertical-align: %dpx" ' % (-depth) or '')) @@ -189,7 +196,14 @@ def html_visit_displaymath(self, node): latex = node['latex'] else: latex = wrap_displaymath(node['latex'], None) - fname, depth = render_math(self, latex) + try: + fname, depth = render_math(self, latex) + except MathExtError, exc: + sm = nodes.system_message(str(exc), type='WARNING', level=2, + backrefs=[], source=node['latex']) + sm.walkabout(self) + self.builder.warn('inline latex %r: ' % node['latex'] + str(exc)) + raise nodes.SkipNode self.body.append(self.starttag(node, 'div', CLASS='math')) self.body.append('<p>') if node['number']: diff --git a/sphinx/htmlhelp.py b/sphinx/htmlhelp.py index 33dbd9ff..4cc68bc9 100644 --- a/sphinx/htmlhelp.py +++ b/sphinx/htmlhelp.py @@ -55,6 +55,7 @@ from sphinx import addnodes project_template = '''\ [OPTIONS] Binary TOC=Yes +Binary Index=No Compiled file=%(outname)s.chm Contents file=%(outname)s.hhc Default Window=%(outname)s @@ -191,12 +192,21 @@ def build_hhx(builder, outdir, outname): try: f.write('<UL>\n') def write_index(title, refs, subitems): - if refs: - f.write('<LI> ') - item = object_sitemap % (cgi.escape(title), refs[0]) + def write_param(name, value): + item = ' <param name="%s" value="%s">\n' % (name, value) f.write(item.encode('ascii', 'xmlcharrefreplace')) - for ref in refs[1:]: - f.write(object_sitemap % ('[Link]', ref)) + title = cgi.escape(title) + f.write('<LI> <OBJECT type="text/sitemap">\n') + write_param('Keyword', title) + if len(refs) == 0: + write_param('See Also', title) + elif len(refs) == 1: + write_param('Local', refs[0]) + else: + for i, ref in enumerate(refs): + write_param('Name', '[%d] %s' % (i, ref)) # XXX: better title? + write_param('Local', ref) + f.write('</OBJECT>\n') if subitems: f.write('<UL> ') for subitem in subitems: diff --git a/sphinx/latexwriter.py b/sphinx/latexwriter.py index 6d19b4ac..94cb23db 100644 --- a/sphinx/latexwriter.py +++ b/sphinx/latexwriter.py @@ -221,6 +221,7 @@ class LaTeXTranslator(nodes.NodeVisitor): self.first_document = 1 self.this_is_the_title = 1 self.literal_whitespace = 0 + self.no_contractions = 0 def astext(self): return (HEADER % self.elements + self.highlighter.get_stylesheet() + @@ -939,8 +940,10 @@ class LaTeXTranslator(nodes.NodeVisitor): def visit_literal_emphasis(self, node): self.body.append(r'\emph{\texttt{') + self.no_contractions += 1 def depart_literal_emphasis(self, node): self.body.append('}}') + self.no_contractions -= 1 def visit_strong(self, node): self.body.append(r'\textbf{') @@ -1038,7 +1041,10 @@ class LaTeXTranslator(nodes.NodeVisitor): # no output in this line -- add a nonbreaking space, else the # \\ command will give an error self.body.append('~') - self.body.append('\\\\\n') + if self.table is not None: + self.body.append('\\newline\n') + else: + self.body.append('\\\\\n') def visit_block_quote(self, node): # If the block quote contains a single object and that object @@ -1098,7 +1104,7 @@ class LaTeXTranslator(nodes.NodeVisitor): def visit_option_string(self, node): ostring = node.astext() - self.body.append(self.encode(ostring.replace('--', u'--'))) + self.body.append(self.encode(ostring.replace('--', u'-{-}'))) raise nodes.SkipNode def visit_description(self, node): @@ -1150,6 +1156,8 @@ class LaTeXTranslator(nodes.NodeVisitor): # Insert a blank before the newline, to avoid # ! LaTeX Error: There's no line here to end. text = text.replace(u'\n', u'~\\\\\n').replace(u' ', u'~') + if self.no_contractions: + text = text.replace('--', u'-{-}') return text def visit_Text(self, node): diff --git a/sphinx/static/default.css b/sphinx/static/default.css index 288fa487..9731cd86 100644 --- a/sphinx/static/default.css +++ b/sphinx/static/default.css @@ -836,7 +836,7 @@ img.math { vertical-align: middle; } -div.math { +div.math p { text-align: center; } diff --git a/sphinx/templates/changes/frameset.html b/sphinx/templates/changes/frameset.html index 6d053533..9d9af9eb 100644 --- a/sphinx/templates/changes/frameset.html +++ b/sphinx/templates/changes/frameset.html @@ -2,7 +2,7 @@ "http://www.w3.org/TR/html4/frameset.dtd"> <html> <head> - <title>{% trans version=version, docstitle=docstitle %}Changes in Version {{ version }} — {{ docstitle }}{% endtrans %}</title> + <title>{% trans version=version|e, docstitle=docstitle|e %}Changes in Version {{ version }} — {{ docstitle }}{% endtrans %}</title> </head> <frameset cols="45%,*"> <frame name="main" src="changes.html"> diff --git a/sphinx/templates/changes/rstsource.html b/sphinx/templates/changes/rstsource.html index a4b3c53c..abd12c1d 100644 --- a/sphinx/templates/changes/rstsource.html +++ b/sphinx/templates/changes/rstsource.html @@ -2,7 +2,7 @@ "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> - <title>{% trans filename=filename, docstitle=docstitle %}{{ filename }} — {{ docstitle }}{% endtrans %}</title> + <title>{% trans filename=filename, docstitle=docstitle|e %}{{ filename }} — {{ docstitle }}{% endtrans %}</title> <style type="text/css"> .hl { background-color: yellow } </style> diff --git a/sphinx/templates/changes/versionchanges.html b/sphinx/templates/changes/versionchanges.html index 5a58e22a..14d5efd3 100644 --- a/sphinx/templates/changes/versionchanges.html +++ b/sphinx/templates/changes/versionchanges.html @@ -9,12 +9,12 @@ <head> <link rel="stylesheet" href="default.css"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> - <title>{% trans version=version, docstitle=docstitle %}Changes in Version {{ version }} — {{ docstitle }}{% endtrans %}</title> + <title>{% trans version=version|e, docstitle=docstitle|e %}Changes in Version {{ version }} — {{ docstitle }}{% endtrans %}</title> </head> <body> <div class="document"> <div class="body"> - <h1>{% trans version=version %}Automatically generated list of changes in version {{ version }}{% endtrans %}</h1> + <h1>{% trans version=version|e %}Automatically generated list of changes in version {{ version }}{% endtrans %}</h1> <h2>{{ _('Library changes') }}</h2> {% for modname, changes in libchanges %} <h4>{{ modname }}</h4> diff --git a/sphinx/templates/defindex.html b/sphinx/templates/defindex.html index 78ac0801..40f4f4c9 100644 --- a/sphinx/templates/defindex.html +++ b/sphinx/templates/defindex.html @@ -1,11 +1,11 @@ {% extends "layout.html" %} {% set title = _('Overview') %} {% block body %} - <h1>{{ docstitle }}</h1> + <h1>{{ docstitle|e }}</h1> <p> Welcome! This is - {% block description %}the documentation for {{ project }} - {{ release }}{% if last_updated %}, last updated {{ last_updated }}{% endif %}{% endblock %}. + {% block description %}the documentation for {{ project|e }} + {{ release|e }}{% if last_updated %}, last updated {{ last_updated|e }}{% endif %}{% endblock %}. </p> {% block tables %} <p><strong>{{ _('Indices and tables:') }}</strong></p> diff --git a/sphinx/templates/layout.html b/sphinx/templates/layout.html index e6374b6d..eb691455 100644 --- a/sphinx/templates/layout.html +++ b/sphinx/templates/layout.html @@ -15,7 +15,7 @@ {%- if not loop.first %}{{ reldelim2 }}{% endif %}</li> {%- endfor %} {%- block rootrellink %} - <li><a href="{{ pathto(master_doc) }}">{{ shorttitle }}</a>{{ reldelim1 }}</li> + <li><a href="{{ pathto(master_doc) }}">{{ shorttitle|e }}</a>{{ reldelim1 }}</li> {%- endblock %} {%- for parent in parents %} <li><a href="{{ parent.link|e }}" accesskey="U">{{ parent.title }}</a>{{ reldelim1 }}</li> @@ -89,7 +89,7 @@ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> {{ metatags }} {%- if builder != 'htmlhelp' %} - {%- set titlesuffix = " — " + docstitle %} + {%- set titlesuffix = " — " + docstitle|e %} {%- endif %} <title>{{ title|striptags }}{{ titlesuffix }}</title> {%- if builder == 'web' %} @@ -106,7 +106,7 @@ <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '{{ pathto("", 1) }}', - VERSION: '{{ release }}', + VERSION: '{{ release|e }}', COLLAPSE_MODINDEX: false, FILE_SUFFIX: '{{ file_suffix }}' }; @@ -116,7 +116,7 @@ {%- endfor %} {%- if use_opensearch %} <link rel="search" type="application/opensearchdescription+xml" - title="{% trans docstitle=docstitle%}Search within {{ docstitle }}{% endtrans %}" + title="{% trans docstitle=docstitle|e %}Search within {{ docstitle }}{% endtrans %}" href="{{ pathto('_static/opensearch.xml', 1) }}"/> {%- endif %} {%- if favicon %} @@ -132,7 +132,7 @@ {%- if hasdoc('copyright') %} <link rel="copyright" title="{{ _('Copyright') }}" href="{{ pathto('copyright') }}" /> {%- endif %} - <link rel="top" title="{{ docstitle }}" href="{{ pathto('index') }}" /> + <link rel="top" title="{{ docstitle|e }}" href="{{ pathto('index') }}" /> {%- if parents %} <link rel="up" title="{{ parents[-1].title|striptags }}" href="{{ parents[-1].link|e }}" /> {%- endif %} @@ -175,15 +175,15 @@ {%- block footer %} <div class="footer"> {%- if hasdoc('copyright') %} - {% trans path=pathto('copyright'), copyright=copyright %}© <a href="{{ path }}">Copyright</a> {{ copyright }}.{% endtrans %} + {% trans path=pathto('copyright'), copyright=copyright|e %}© <a href="{{ path }}">Copyright</a> {{ copyright }}.{% endtrans %} {%- else %} - {% trans copyright=copyright %}© Copyright {{ copyright }}.{% endtrans %} + {% trans copyright=copyright|e %}© Copyright {{ copyright }}.{% endtrans %} {%- endif %} {%- if last_updated %} - {% trans last_updated %}Last updated on {{ last_updated }}.{% endtrans %} + {% trans last_updated=last_updated|e %}Last updated on {{ last_updated }}.{% endtrans %} {%- endif %} {%- if show_sphinx %} - {% trans sphinx_version=sphinx_version %}Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> {{ sphinx_version }}.{% endtrans %} + {% trans sphinx_version=sphinx_version|e %}Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> {{ sphinx_version }}.{% endtrans %} {%- endif %} </div> {%- endblock %} diff --git a/sphinx/templates/opensearch.xml b/sphinx/templates/opensearch.xml index fb7fd31f..03875be4 100644 --- a/sphinx/templates/opensearch.xml +++ b/sphinx/templates/opensearch.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"> - <ShortName>{{ project }}</ShortName> - <Description>{% trans docstitle=docstitle %}Search {{ docstitle }}{% endtrans %}</Description> + <ShortName>{{ project|e }}</ShortName> + <Description>{% trans docstitle=docstitle|e %}Search {{ docstitle }}{% endtrans %}</Description> <InputEncoding>utf-8</InputEncoding> <Url type="text/html" method="get" template="{{ use_opensearch }}/{{ pathto('search') }}?q={searchTerms}&check_keywords=yes&area=default"/> - <LongName>{{ docstitle }}</LongName> + <LongName>{{ docstitle|e }}</LongName> {% block extra %} {# Put e.g. an <Image> element here. #} {% endblock %} </OpenSearchDescription> diff --git a/sphinx/util/jsdump.py b/sphinx/util/jsdump.py index 199c5e09..3d246d0c 100644 --- a/sphinx/util/jsdump.py +++ b/sphinx/util/jsdump.py @@ -124,7 +124,10 @@ def loads(x): i += 1 elif c in '}]': if key: - raise ValueError("unfinished dict") + if keys[-1] is not nothing: + raise ValueError("unfinished dict") + # empty dict + key = False oldobj = stack.pop() keys.pop() if stack: |
