mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix interpolation error, encode inserted caption strings and add the caption in HTML output too.
This commit is contained in:
parent
8b51e75bd9
commit
e48f7eb09a
1
AUTHORS
1
AUTHORS
@ -15,6 +15,7 @@ Other contributors, listed alphabetically, are:
|
|||||||
* Josip Dzolonga -- coverage builder
|
* Josip Dzolonga -- coverage builder
|
||||||
* Horst Gutmann -- internationalization support
|
* Horst Gutmann -- internationalization support
|
||||||
* Martin Hans -- autodoc improvements
|
* Martin Hans -- autodoc improvements
|
||||||
|
* Doug Hellmann -- graphviz improvements
|
||||||
* Dave Kuhlman -- original LaTeX writer
|
* Dave Kuhlman -- original LaTeX writer
|
||||||
* Blaise Laflamme -- pyramid theme
|
* Blaise Laflamme -- pyramid theme
|
||||||
* Thomas Lamb -- linkcheck builder
|
* Thomas Lamb -- linkcheck builder
|
||||||
|
2
CHANGES
2
CHANGES
@ -77,6 +77,8 @@ Release 1.1 (in development)
|
|||||||
|
|
||||||
* #306: Added :event:`env-get-outdated` event.
|
* #306: Added :event:`env-get-outdated` event.
|
||||||
|
|
||||||
|
* #590: Added ``caption`` option to graphviz directives.
|
||||||
|
|
||||||
* C++ domain now supports array definitions.
|
* C++ domain now supports array definitions.
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,10 +73,15 @@ It adds these directives:
|
|||||||
the graphviz code.
|
the graphviz code.
|
||||||
|
|
||||||
.. versionadded:: 1.1
|
.. versionadded:: 1.1
|
||||||
All three directives support an ``inline`` flag that controls
|
All three directives support an ``inline`` flag that controls paragraph
|
||||||
paragraph breaks in the output. When set, the graph is inserted
|
breaks in the output. When set, the graph is inserted into the current
|
||||||
into the current paragraph. If the flag is not given, paragraph
|
paragraph. If the flag is not given, paragraph breaks are introduced before
|
||||||
breaks are introduced before and after the image (the default).
|
and after the image (the default).
|
||||||
|
|
||||||
|
.. versionadded:: 1.1
|
||||||
|
All three directives support a ``caption`` option that can be used to give a
|
||||||
|
caption to the diagram. Naturally, diagrams marked as "inline" cannot have a
|
||||||
|
caption.
|
||||||
|
|
||||||
There are also these new config values:
|
There are also these new config values:
|
||||||
|
|
||||||
|
@ -223,7 +223,8 @@ def render_dot_html(self, node, code, options, prefix='graphviz',
|
|||||||
self.builder.warn('dot code %r: ' % code + str(exc))
|
self.builder.warn('dot code %r: ' % code + str(exc))
|
||||||
raise nodes.SkipNode
|
raise nodes.SkipNode
|
||||||
|
|
||||||
if node.get('inline', False):
|
inline = node.get('inline', False)
|
||||||
|
if inline:
|
||||||
wrapper = 'span'
|
wrapper = 'span'
|
||||||
else:
|
else:
|
||||||
wrapper = 'p'
|
wrapper = 'p'
|
||||||
@ -254,6 +255,9 @@ def render_dot_html(self, node, code, options, prefix='graphviz',
|
|||||||
self.body.append('<img src="%s" alt="%s" usemap="#%s" %s/>\n' %
|
self.body.append('<img src="%s" alt="%s" usemap="#%s" %s/>\n' %
|
||||||
(fname, alt, mapname, imgcss))
|
(fname, alt, mapname, imgcss))
|
||||||
self.body.extend(imgmap)
|
self.body.extend(imgmap)
|
||||||
|
if node.get('caption') and not inline:
|
||||||
|
self.body.append('</p>\n<p class="caption">')
|
||||||
|
self.body.append(self.encode(node['caption']))
|
||||||
|
|
||||||
self.body.append('</%s>\n' % wrapper)
|
self.body.append('</%s>\n' % wrapper)
|
||||||
raise nodes.SkipNode
|
raise nodes.SkipNode
|
||||||
@ -278,16 +282,16 @@ def render_dot_latex(self, node, code, options, prefix='graphviz'):
|
|||||||
|
|
||||||
if fname is not None:
|
if fname is not None:
|
||||||
caption = node.get('caption')
|
caption = node.get('caption')
|
||||||
if caption:
|
if caption and not inline:
|
||||||
self.body.append('\n\\begin{figure}[h!]')
|
self.body.append('\n\\begin{figure}[h!]')
|
||||||
self.body.append('\n\\begin{center}')
|
self.body.append('\n\\begin{center}')
|
||||||
self.body.append('\n\\caption{%s}' % caption)
|
self.body.append('\n\\caption{%s}' % self.encode(caption))
|
||||||
self.body.append('\n\\label{figure:%s}' % caption)
|
self.body.append('\n\\label{figure:%s}' % self.encode(caption))
|
||||||
self.body.append('\n\\includegraphics{%s}' % fname)
|
self.body.append('\n\\includegraphics{%s}' % fname)
|
||||||
self.body.append('\n\\end{center}')
|
self.body.append('\n\\end{center}')
|
||||||
self.body.append('\n\\end{figure}\n')
|
self.body.append('\n\\end{figure}\n')
|
||||||
else:
|
else:
|
||||||
self.body.append('%s\\includegraphics{%s}' %
|
self.body.append('%s\\includegraphics{%s}%s' %
|
||||||
(para_separator, fname, para_separator))
|
(para_separator, fname, para_separator))
|
||||||
raise nodes.SkipNode
|
raise nodes.SkipNode
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user