diff options
| author | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2010-03-02 11:51:33 +0000 |
|---|---|---|
| committer | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2010-03-02 11:51:33 +0000 |
| commit | babeacc0221e1ffe61e66cf91623853458c2fc02 (patch) | |
| tree | ecff2ec72e40f752bf167c67c4d962c30b466abb | |
| parent | 767f1f92900ea84d3e8e234d76f0eeefc47ce08a (diff) | |
| download | docutils-babeacc0221e1ffe61e66cf91623853458c2fc02.tar.gz | |
support SWF images,
improve formatting of HTML test output.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@6254 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
| -rw-r--r-- | docutils/HISTORY.txt | 2 | ||||
| -rw-r--r-- | docutils/docs/user/rst/images/biohazard.svg | 2 | ||||
| -rw-r--r-- | docutils/docutils/writers/html4css1/__init__.py | 19 | ||||
| -rw-r--r-- | docutils/test/functional/expected/standalone_rst_html4css1.html | 127 | ||||
| -rw-r--r-- | docutils/test/functional/expected/standalone_rst_latex.tex | 18 | ||||
| -rw-r--r-- | docutils/test/functional/expected/standalone_rst_pseudoxml.txt | 20 | ||||
| -rw-r--r-- | docutils/test/functional/input/data/standard.txt | 19 | ||||
| -rw-r--r-- | docutils/test/functional/input/data/svg_images.txt | 57 | ||||
| -rw-r--r-- | docutils/test/functional/input/data/swf_images.txt | 24 | ||||
| -rw-r--r-- | docutils/test/functional/input/standalone_rst_html4css1.txt | 1 |
10 files changed, 174 insertions, 115 deletions
diff --git a/docutils/HISTORY.txt b/docutils/HISTORY.txt index 7ef94d18f..b4ad6e6e5 100644 --- a/docutils/HISTORY.txt +++ b/docutils/HISTORY.txt @@ -32,7 +32,7 @@ Changes Since 0.6 * docutils/writers/html4css1/__init__.py - - Support SVG images (thanks to Stefan Rank). + - Support SVG and SWF images (thanks to Stefan Rank). * docutils/writers/latex2e/__init__.py diff --git a/docutils/docs/user/rst/images/biohazard.svg b/docutils/docs/user/rst/images/biohazard.svg index 10209090a..723b101be 100644 --- a/docutils/docs/user/rst/images/biohazard.svg +++ b/docutils/docs/user/rst/images/biohazard.svg @@ -14,7 +14,7 @@ sodipodi:version="0.32" id="svg24159" height="48" - width="48.000004" + width="48" version="1.0"> <title id="title2837">Biohazard</title> diff --git a/docutils/docutils/writers/html4css1/__init__.py b/docutils/docutils/writers/html4css1/__init__.py index 5871ab0dc..a885d7606 100644 --- a/docutils/docutils/writers/html4css1/__init__.py +++ b/docutils/docutils/writers/html4css1/__init__.py @@ -947,19 +947,23 @@ class HTMLTranslator(nodes.NodeVisitor): def visit_image(self, node): atts = {} uri = node['uri'] - issvg = uri.lower().endswith('.svg') - if issvg: + # place SVG and SWF images in an <object> element + types = {'.svg': 'image/svg+xml', + '.swf': 'application/x-shockwave-flash'} + ext = os.path.splitext(uri)[1].lower() + if ext in ('.svg', '.swf'): atts['data'] = uri - atts['type'] = 'image/svg+xml' + atts['type'] = types[ext] else: atts['src'] = uri + atts['alt'] = node.get('alt', uri) + # image size if 'width' in node: atts['width'] = node['width'] if 'height' in node: atts['height'] = node['height'] if 'scale' in node: - if Image and not ('width' in node - and 'height' in node): + if Image and not ('width' in node and 'height' in node): try: im = Image.open(str(uri)) except (IOError, # Source image can't be found or opened @@ -988,7 +992,6 @@ class HTMLTranslator(nodes.NodeVisitor): del atts[att_name] if style: atts['style'] = ' '.join(style) - atts['alt'] = node.get('alt', uri) if (isinstance(node.parent, nodes.TextElement) or (isinstance(node.parent, nodes.reference) and not isinstance(node.parent.parent, nodes.TextElement))): @@ -1011,10 +1014,10 @@ class HTMLTranslator(nodes.NodeVisitor): atts['class'] = 'align-%s' % node['align'] else: self.context.append('') - if issvg: + if ext in ('.svg', '.swf'): # place in an object element, # do NOT use an empty tag: incorrect rendering in browsers self.body.append(self.starttag(node, 'object', suffix, **atts) + - atts['alt'] + '</object>' + suffix) + node.get('alt', uri) + '</object>' + suffix) else: self.body.append(self.emptytag(node, 'img', suffix, **atts)) diff --git a/docutils/test/functional/expected/standalone_rst_html4css1.html b/docutils/test/functional/expected/standalone_rst_html4css1.html index 98d6f892f..4ecfc82be 100644 --- a/docutils/test/functional/expected/standalone_rst_html4css1.html +++ b/docutils/test/functional/expected/standalone_rst_html4css1.html @@ -133,9 +133,10 @@ They are transformed from section titles after parsing. --> <li><a class="reference internal" href="#list-tables" id="id69">2.22 List Tables</a></li> <li><a class="reference internal" href="#custom-roles" id="id70">2.23 Custom Roles</a></li> <li><a class="reference internal" href="#svg-images" id="id71">2.24 SVG Images</a></li> +<li><a class="reference internal" href="#swf-images" id="id72">2.25 SWF Images</a></li> </ul> </li> -<li><a class="reference internal" href="#error-handling" id="id72">3 Error Handling</a></li> +<li><a class="reference internal" href="#error-handling" id="id73">3 Error Handling</a></li> </ul> </div> <div class="section" id="structural-elements"> @@ -479,7 +480,7 @@ Here's a reference to the next footnote: <a class="footnote-reference" href="#id <colgroup><col class="label" /><col /></colgroup> <tbody valign="top"> <tr><td class="label">[4]</td><td>Here's an unreferenced footnote, with a reference to a -nonexistent footnote: <a href="#id81"><span class="problematic" id="id82"><span id="id17"></span>[5]_</span></a>.</td></tr> +nonexistent footnote: <a href="#id82"><span class="problematic" id="id83"><span id="id17"></span>[5]_</span></a>.</td></tr> </tbody> </table> </div> @@ -492,7 +493,7 @@ nonexistent footnote: <a href="#id81"><span class="problematic" id="id82"><span rendered separately and differently from footnotes.</td></tr> </tbody> </table> -<p>Here's a reference to the above, <a class="citation-reference" href="#cit2002" id="id18">[CIT2002]</a>, and a <a href="#id83"><span class="problematic" id="id84"><span id="id19"></span>[nonexistent]_</span></a> +<p>Here's a reference to the above, <a class="citation-reference" href="#cit2002" id="id18">[CIT2002]</a>, and a <a href="#id84"><span class="problematic" id="id85"><span id="id19"></span>[nonexistent]_</span></a> citation.</p> </div> <div class="section" id="targets"> @@ -506,7 +507,7 @@ hyperlink targets</a> are also possible.</p> "<a class="reference external" href="http://www.python.org/">Python</a> <a class="footnote-reference" href="#id25" id="id27">[5]</a>".</p> <p>Targets may be indirect and anonymous. Thus <a class="reference internal" href="#targets">this phrase</a> may also refer to the <a class="reference internal" href="#targets">Targets</a> section.</p> -<p>Here's a <a href="#id85"><span class="problematic" id="id86">`hyperlink reference without a target`_</span></a>, which generates an +<p>Here's a <a href="#id86"><span class="problematic" id="id87">`hyperlink reference without a target`_</span></a>, which generates an error.</p> <div class="section" id="duplicate-target-names"> <h3><a class="toc-backref" href="#id51">2.13.1 Duplicate Target Names</a></h3> @@ -518,34 +519,34 @@ explicit targets will generate "warning" (level-2) system messages.</p <h3><a class="toc-backref" href="#id52">2.13.2 Duplicate Target Names</a></h3> <p>Since there are two "Duplicate Target Names" section headers, we cannot uniquely refer to either of them by name. If we try to (like -this: <a href="#id87"><span class="problematic" id="id88">`Duplicate Target Names`_</span></a>), an error is generated.</p> +this: <a href="#id88"><span class="problematic" id="id89">`Duplicate Target Names`_</span></a>), an error is generated.</p> </div> </div> <div class="section" id="directives"> <h2><a class="toc-backref" href="#id53">2.14 Directives</a></h2> <div class="contents local topic" id="contents"> <ul class="auto-toc simple"> -<li><a class="reference internal" href="#document-parts" id="id73">2.14.1 Document Parts</a></li> -<li><a class="reference internal" href="#images-and-figures" id="id74">2.14.2 Images and Figures</a></li> -<li><a class="reference internal" href="#admonitions" id="id75">2.14.3 Admonitions</a></li> -<li><a class="reference internal" href="#topics-sidebars-and-rubrics" id="id76">2.14.4 Topics, Sidebars, and Rubrics</a></li> -<li><a class="reference internal" href="#target-footnotes" id="id77">2.14.5 Target Footnotes</a></li> -<li><a class="reference internal" href="#replacement-text" id="id78">2.14.6 Replacement Text</a></li> -<li><a class="reference internal" href="#compound-paragraph" id="id79">2.14.7 Compound Paragraph</a></li> -<li><a class="reference internal" href="#parsed-literal-blocks" id="id80">2.14.8 Parsed Literal Blocks</a></li> +<li><a class="reference internal" href="#document-parts" id="id74">2.14.1 Document Parts</a></li> +<li><a class="reference internal" href="#images-and-figures" id="id75">2.14.2 Images and Figures</a></li> +<li><a class="reference internal" href="#admonitions" id="id76">2.14.3 Admonitions</a></li> +<li><a class="reference internal" href="#topics-sidebars-and-rubrics" id="id77">2.14.4 Topics, Sidebars, and Rubrics</a></li> +<li><a class="reference internal" href="#target-footnotes" id="id78">2.14.5 Target Footnotes</a></li> +<li><a class="reference internal" href="#replacement-text" id="id79">2.14.6 Replacement Text</a></li> +<li><a class="reference internal" href="#compound-paragraph" id="id80">2.14.7 Compound Paragraph</a></li> +<li><a class="reference internal" href="#parsed-literal-blocks" id="id81">2.14.8 Parsed Literal Blocks</a></li> </ul> </div> <p>These are just a sample of the many reStructuredText Directives. For others, please see <a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html">http://docutils.sourceforge.net/docs/ref/rst/directives.html</a>.</p> <div class="section" id="document-parts"> -<h3><a class="toc-backref" href="#id73">2.14.1 Document Parts</a></h3> +<h3><a class="toc-backref" href="#id74">2.14.1 Document Parts</a></h3> <p>An example of the "contents" directive can be seen above this section (a local, untitled table of <a class="reference internal" href="#contents">contents</a>) and at the beginning of the document (a document-wide <a class="reference internal" href="#table-of-contents">table of contents</a>).</p> </div> <div class="section" id="images-and-figures"> -<h3><a class="toc-backref" href="#id74">2.14.2 Images and Figures</a></h3> +<h3><a class="toc-backref" href="#id75">2.14.2 Images and Figures</a></h3> <p>An image directive (also clickable -- a hyperlink reference):</p> <a class="reference internal image-reference" href="#directives"><img alt="../../../docs/user/rst/images/title.png" class="class1 class2" src="../../../docs/user/rst/images/title.png" /></a> <p>Image with multiple IDs:</p> @@ -600,30 +601,32 @@ layout.</p> </div> </div> <p>A left-aligned figure:</p> -<div class="figclass1 figclass2 figure align-left"> -<img alt="reStructuredText, the markup syntax" class="class1 class2" src="../../../docs/user/rst/images/biohazard.png" style="width: 50px;" /> +<div class="figclass1 figclass2 figure align-left" style="width: 70%"> +<img alt="reStructuredText, the markup syntax" class="class1 class2" src="../../../docs/user/rst/images/biohazard.png" style="width: 40px;" /> <p class="caption">This is the caption.</p> <div class="legend"> <p>This is the legend.</p> <p>The legend may consist of several paragraphs.</p> </div> </div> -<p>This paragraph might flow around the figure. The specific behavior depends -upon the style sheet and the browser or rendering software used.</p> +<p>This paragraph might flow around the figure.</p> +<p>The specific behavior depends upon the style sheet and the browser or +rendering software used.</p> <p>A centered figure:</p> <div class="figure align-center"> -<img alt="../../../docs/user/rst/images/biohazard.png" src="../../../docs/user/rst/images/biohazard.png" style="width: 50px;" /> +<img alt="../../../docs/user/rst/images/biohazard.png" src="../../../docs/user/rst/images/biohazard.png" style="width: 40px;" /> <p class="caption">This is the caption.</p> <div class="legend"> <p>This is the legend.</p> <p>The legend may consist of several paragraphs.</p> </div> </div> -<p>This paragraph might flow around the figure. The specific behavior depends -upon the style sheet and the browser or rendering software used.</p> +<p>This paragraph might flow around the figure.</p> +<p>The specific behavior depends upon the style sheet and the browser or +rendering software used.</p> <p>A right-aligned figure:</p> <div class="figure align-right"> -<img alt="../../../docs/user/rst/images/biohazard.png" src="../../../docs/user/rst/images/biohazard.png" style="width: 50px;" /> +<img alt="../../../docs/user/rst/images/biohazard.png" src="../../../docs/user/rst/images/biohazard.png" style="width: 40px;" /> <p class="caption">This is the caption.</p> <div class="legend"> <p>This is the legend.</p> @@ -634,7 +637,7 @@ upon the style sheet and the browser or rendering software used.</p> upon the style sheet and the browser or rendering software used.</p> </div> <div class="section" id="admonitions"> -<h3><a class="toc-backref" href="#id75">2.14.3 Admonitions</a></h3> +<h3><a class="toc-backref" href="#id76">2.14.3 Admonitions</a></h3> <div class="attention"> <p class="first admonition-title">Attention!</p> <p class="last">Directives at large.</p> @@ -683,7 +686,7 @@ Reader discretion is strongly advised.</p> </div> </div> <div class="section" id="topics-sidebars-and-rubrics"> -<h3><a class="toc-backref" href="#id76">2.14.4 Topics, Sidebars, and Rubrics</a></h3> +<h3><a class="toc-backref" href="#id77">2.14.4 Topics, Sidebars, and Rubrics</a></h3> <p><em>Sidebars</em> are like miniature, parallel documents.</p> <div class="sidebar"> <p class="first sidebar-title">Sidebar Title</p> @@ -707,7 +710,7 @@ document's structure. It is typically highlighted in red (hence the name).</p> allowed (e.g. inside a directive).</p> </div> <div class="section" id="target-footnotes"> -<h3><a class="toc-backref" href="#id77">2.14.5 Target Footnotes</a></h3> +<h3><a class="toc-backref" href="#id78">2.14.5 Target Footnotes</a></h3> <table class="docutils footnote" frame="void" id="id25" rules="none"> <colgroup><col class="label" /><col /></colgroup> <tbody valign="top"> @@ -722,11 +725,11 @@ allowed (e.g. inside a directive).</p> </table> </div> <div class="section" id="replacement-text"> -<h3><a class="toc-backref" href="#id78">2.14.6 Replacement Text</a></h3> +<h3><a class="toc-backref" href="#id79">2.14.6 Replacement Text</a></h3> <p>I recommend you try <a class="reference external" href="http://www.python.org/">Python, <em>the</em> best language around</a> <a class="footnote-reference" href="#id25" id="id28">[5]</a>.</p> </div> <div class="section" id="compound-paragraph"> -<h3><a class="toc-backref" href="#id79">2.14.7 Compound Paragraph</a></h3> +<h3><a class="toc-backref" href="#id80">2.14.7 Compound Paragraph</a></h3> <div class="some-class compound"> <p class="compound-first">Compound 1, paragraph 1.</p> <p class="compound-middle">Compound 1, paragraph 2.</p> @@ -794,7 +797,7 @@ paragraph.</td> </div> </div> <div class="section" id="parsed-literal-blocks"> -<h3><a class="toc-backref" href="#id80">2.14.8 Parsed Literal Blocks</a></h3> +<h3><a class="toc-backref" href="#id81">2.14.8 Parsed Literal Blocks</a></h3> <pre class="literal-block"> This is a parsed literal block. This line is indented. The next line is blank. @@ -1006,42 +1009,56 @@ crunchy, now would it?</td> </div> <div class="section" id="svg-images"> <h2><a class="toc-backref" href="#id71">2.24 SVG Images</a></h2> +<object data="../../../docs/user/rst/images/biohazard.svg" style="width: 48px; height: 48px;" type="image/svg+xml"> +../../../docs/user/rst/images/biohazard.svg</object> <p>Scalable vector graphics (SVG) images are not supported by all backends. Rendering depends partially on the backend, especially if the size is not explicitely given.</p> +<object align="left" class="align-left" data="../../../docs/user/rst/images/title-scaling.svg" style="width: 50%;" type="image/svg+xml"> +../../../docs/user/rst/images/title-scaling.svg</object> +<p>A scaling image occupying 50% of the line width (scales with the +browser window).</p> <p>Whether an SVG image is scaled or clipped/padded cannot be set in the containing HTML. It depends on the viewport declaration inside its root <svg> element.</p> -<object align="left" alt="../../../docs/user/rst/images/biohazard-scaling.svg" class="align-left" data="../../../docs/user/rst/images/biohazard-scaling.svg" style="height: 1em;" type="image/svg+xml"> +<p>An inline SVG image <object data="../../../docs/user/rst/images/biohazard-scaling.svg" style="height: 0.8em;" type="image/svg+xml">inline-svg</object> scaled to a height of 0.8 em.</p> +<object align="right" class="align-right" data="../../../docs/user/rst/images/title-scaling.svg" style="width: 50%; height: 1.2em;" type="image/svg+xml"> +../../../docs/user/rst/images/title-scaling.svg</object> +<p>A scaling image occupying 50% of the line width and 1.2 em high, +right aligned (this SVG image keeps the aspect ratio):</p> +<object align="left" class="align-left" data="../../../docs/user/rst/images/biohazard-scaling.svg" style="height: 1em;" type="image/svg+xml"> ../../../docs/user/rst/images/biohazard-scaling.svg</object> <p>A scaling image 1 em high, left aligned.</p> -<a class="reference internal image-reference" href="#directives"><object align="right" alt="../../../docs/user/rst/images/biohazard-scaling.svg" class="align-right" data="../../../docs/user/rst/images/biohazard-scaling.svg" style="width: 5mm;" type="image/svg+xml">../../../docs/user/rst/images/biohazard-scaling.svg</object></a> -<p>A scaling image 5 mm wide, right aligned, with hyperlink reference:</p> -<object align="left" alt="../../../docs/user/rst/images/title-scaling.svg" class="align-left" data="../../../docs/user/rst/images/title-scaling.svg" style="width: 50%;" type="image/svg+xml"> -../../../docs/user/rst/images/title-scaling.svg</object> -<p>A scaling image occupying 50% of the line width (scales with the -browser window):</p> -<object align="left" alt="../../../docs/user/rst/images/title-scaling.svg" class="align-left" data="../../../docs/user/rst/images/title-scaling.svg" style="width: 50%; height: 15px;" type="image/svg+xml"> -../../../docs/user/rst/images/title-scaling.svg</object> -<p>A scaling image occupying 50% of the line width and 15 pixel high -(this SVG image keeps the aspect ratio):</p> -<p>An inline image <object alt="inline-svg" data="../../../docs/user/rst/images/biohazard-scaling.svg" style="height: 0.8em;" type="image/svg+xml">inline-svg</object> scaled to match the text size.</p> -<object align="left" alt="../../../docs/user/rst/images/biohazard.svg" class="align-left" data="../../../docs/user/rst/images/biohazard.svg" style="width: 4cm; height: 2em;" type="image/svg+xml"> +<p>A scaling image 5 mm x 5 mm, centered, with hyperlink reference:</p> +<a class="reference internal image-reference" href="#directives"><div align="center" class="align-center"><object class="align-center" data="../../../docs/user/rst/images/biohazard-scaling.svg" style="width: 5mm; height: 5mm;" type="image/svg+xml">../../../docs/user/rst/images/biohazard-scaling.svg</object></div> +</a> +<object align="left" class="align-left" data="../../../docs/user/rst/images/biohazard.svg" style="width: 4cm; height: 2em;" type="image/svg+xml"> ../../../docs/user/rst/images/biohazard.svg</object> <p>A fixed-size image in a 4 cm x 2 em box.</p> -<object align="left" alt="../../../docs/user/rst/images/title.svg" class="align-left" data="../../../docs/user/rst/images/title.svg" style="width: 50%; height: 15px;" type="image/svg+xml"> +<object align="left" class="align-left" data="../../../docs/user/rst/images/title.svg" style="width: 50%; height: 15px;" type="image/svg+xml"> ../../../docs/user/rst/images/title.svg</object> <p>A fixed-size image in a box 50% the line width and 15 pixle high.</p> -<p>SVG image in a figure:</p> <div class="figure"> -<object alt="reStructuredText, the markup syntax" data="../../../docs/user/rst/images/title.svg" style="width: 290px; height: 28px;" type="image/svg+xml"> +<object data="../../../docs/user/rst/images/title.svg" style="width: 290px; height: 28px;" type="image/svg+xml"> reStructuredText, the markup syntax</object> -<p class="caption">This is the caption.</p> +<p class="caption">SVG image in a figure.</p> +</div> </div> +<div class="section" id="swf-images"> +<h2><a class="toc-backref" href="#id72">2.25 SWF Images</a></h2> +<p>Shockwave Flash is an image/movie format that most modern web browsers +support via a plugin. It is sometimes blocked due to privacy/security +concerns.</p> +<p>Images with extension <tt class="docutils literal">.swf</tt> are placed inside <object> elements. +For complete control over display options use raw HTML.</p> +<object align="left" class="align-left" data="../../../docs/user/rst/images/biohazard.swf" style="width: 4cm; height: 2em;" type="application/x-shockwave-flash"> +[biohazard.swf]</object> +<p>An SWF image in a 4 cm x 2 em box, left aligned.</p> +<p>An inline SWF image <object data="../../../docs/user/rst/images/biohazard.swf" style="width: 0.8em; height: 0.8em;" type="application/x-shockwave-flash">inline-swf</object> scaled to 8.0 em x 0.8 em.</p> </div> </div> <div class="section" id="error-handling"> -<h1><a class="toc-backref" href="#id72">3 Error Handling</a></h1> +<h1><a class="toc-backref" href="#id73">3 Error Handling</a></h1> <p>Any errors caught during processing will generate system messages.</p> <p>There should be five messages in the following, auto-generated section, "Docutils System Messages":</p> @@ -1052,17 +1069,17 @@ section, "Docutils System Messages":</p> <div class="system-message" id="id23"> <p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/data/standard.txt</tt>, line 104); <em><a href="#id24">backlink</a></em></p> Undefined substitution referenced: "problematic".</div> -<div class="system-message" id="id81"> -<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/standalone_rst_html4css1.txt</tt>, line 363); <em><a href="#id82">backlink</a></em></p> +<div class="system-message" id="id82"> +<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/standalone_rst_html4css1.txt</tt>, line 363); <em><a href="#id83">backlink</a></em></p> Unknown target name: "5".</div> -<div class="system-message" id="id83"> -<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/data/standard.txt</tt>, line 372); <em><a href="#id84">backlink</a></em></p> +<div class="system-message" id="id84"> +<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/data/standard.txt</tt>, line 372); <em><a href="#id85">backlink</a></em></p> Unknown target name: "nonexistent".</div> -<div class="system-message" id="id85"> -<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/data/standard.txt</tt>, line 399); <em><a href="#id86">backlink</a></em></p> +<div class="system-message" id="id86"> +<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/data/standard.txt</tt>, line 399); <em><a href="#id87">backlink</a></em></p> Unknown target name: "hyperlink reference without a target".</div> -<div class="system-message" id="id87"> -<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/data/standard.txt</tt>, line 412); <em><a href="#id88">backlink</a></em></p> +<div class="system-message" id="id88"> +<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/data/standard.txt</tt>, line 412); <em><a href="#id89">backlink</a></em></p> Duplicate target name, cannot be used as a unique reference: "duplicate target names".</div> </div> </div> diff --git a/docutils/test/functional/expected/standalone_rst_latex.tex b/docutils/test/functional/expected/standalone_rst_latex.tex index 157389be9..39da3cb75 100644 --- a/docutils/test/functional/expected/standalone_rst_latex.tex +++ b/docutils/test/functional/expected/standalone_rst_latex.tex @@ -1017,7 +1017,7 @@ This paragraph is also part of the legend. A left-aligned figure: \begin{figure} -\noindent\makebox[\textwidth][c]{\includegraphics[width=50bp]{../../../docs/user/rst/images/biohazard.png}} +\noindent\makebox[\textwidth][c]{\includegraphics[width=40px]{../../../docs/user/rst/images/biohazard.png}} \caption{This is the caption.} \begin{DUlegend} This is the legend. @@ -1026,12 +1026,14 @@ The legend may consist of several paragraphs. \end{DUlegend} \end{figure} -This paragraph might flow around the figure. The specific behavior depends -upon the style sheet and the browser or rendering software used. +This paragraph might flow around the figure. + +The specific behavior depends upon the style sheet and the browser or +rendering software used. A centered figure: \begin{figure} -\noindent\makebox[\textwidth][c]{\includegraphics[width=50bp]{../../../docs/user/rst/images/biohazard.png}} +\noindent\makebox[\textwidth][c]{\includegraphics[width=40px]{../../../docs/user/rst/images/biohazard.png}} \caption{This is the caption.} \begin{DUlegend} This is the legend. @@ -1040,12 +1042,14 @@ The legend may consist of several paragraphs. \end{DUlegend} \end{figure} -This paragraph might flow around the figure. The specific behavior depends -upon the style sheet and the browser or rendering software used. +This paragraph might flow around the figure. + +The specific behavior depends upon the style sheet and the browser or +rendering software used. A right-aligned figure: \begin{figure} -\noindent\makebox[\textwidth][c]{\includegraphics[width=50bp]{../../../docs/user/rst/images/biohazard.png}} +\noindent\makebox[\textwidth][c]{\includegraphics[width=40px]{../../../docs/user/rst/images/biohazard.png}} \caption{This is the caption.} \begin{DUlegend} This is the legend. diff --git a/docutils/test/functional/expected/standalone_rst_pseudoxml.txt b/docutils/test/functional/expected/standalone_rst_pseudoxml.txt index 21c681e01..ec40067d6 100644 --- a/docutils/test/functional/expected/standalone_rst_pseudoxml.txt +++ b/docutils/test/functional/expected/standalone_rst_pseudoxml.txt @@ -1240,8 +1240,8 @@ This paragraph is also part of the legend. <paragraph> A left-aligned figure: - <figure align="left" classes="figclass1 figclass2"> - <image alt="reStructuredText, the markup syntax" classes="class1 class2" uri="../../../docs/user/rst/images/biohazard.png" width="50"> + <figure align="left" classes="figclass1 figclass2" width="70%"> + <image alt="reStructuredText, the markup syntax" classes="class1 class2" uri="../../../docs/user/rst/images/biohazard.png" width="40px"> <caption> This is the caption. <legend> @@ -1250,12 +1250,14 @@ <paragraph> The legend may consist of several paragraphs. <paragraph> - This paragraph might flow around the figure. The specific behavior depends - upon the style sheet and the browser or rendering software used. + This paragraph might flow around the figure. + <paragraph> + The specific behavior depends upon the style sheet and the browser or + rendering software used. <paragraph> A centered figure: <figure align="center"> - <image uri="../../../docs/user/rst/images/biohazard.png" width="50"> + <image uri="../../../docs/user/rst/images/biohazard.png" width="40px"> <caption> This is the caption. <legend> @@ -1264,12 +1266,14 @@ <paragraph> The legend may consist of several paragraphs. <paragraph> - This paragraph might flow around the figure. The specific behavior depends - upon the style sheet and the browser or rendering software used. + This paragraph might flow around the figure. + <paragraph> + The specific behavior depends upon the style sheet and the browser or + rendering software used. <paragraph> A right-aligned figure: <figure align="right"> - <image uri="../../../docs/user/rst/images/biohazard.png" width="50"> + <image uri="../../../docs/user/rst/images/biohazard.png" width="40px"> <caption> This is the caption. <legend> diff --git a/docutils/test/functional/input/data/standard.txt b/docutils/test/functional/input/data/standard.txt index 5b099a1ac..37efd1036 100644 --- a/docutils/test/functional/input/data/standard.txt +++ b/docutils/test/functional/input/data/standard.txt @@ -520,7 +520,8 @@ A left-aligned figure: :class: class1 class2 :alt: reStructuredText, the markup syntax :align: left - :width: 50 + :width: 40 px + :figwidth: 70 % This is the caption. @@ -528,14 +529,16 @@ A left-aligned figure: The legend may consist of several paragraphs. -This paragraph might flow around the figure. The specific behavior depends -upon the style sheet and the browser or rendering software used. +This paragraph might flow around the figure. + +The specific behavior depends upon the style sheet and the browser or +rendering software used. A centered figure: .. figure:: ../../../docs/user/rst/images/biohazard.png :align: center - :width: 50 + :width: 40 px This is the caption. @@ -543,14 +546,16 @@ A centered figure: The legend may consist of several paragraphs. -This paragraph might flow around the figure. The specific behavior depends -upon the style sheet and the browser or rendering software used. +This paragraph might flow around the figure. + +The specific behavior depends upon the style sheet and the browser or +rendering software used. A right-aligned figure: .. figure:: ../../../docs/user/rst/images/biohazard.png :align: right - :width: 50 + :width: 40 px This is the caption. diff --git a/docutils/test/functional/input/data/svg_images.txt b/docutils/test/functional/input/data/svg_images.txt index b620823b1..300575232 100644 --- a/docutils/test/functional/input/data/svg_images.txt +++ b/docutils/test/functional/input/data/svg_images.txt @@ -1,47 +1,51 @@ SVG Images ---------- +.. image:: ../../../docs/user/rst/images/biohazard.svg + :width: 48 px + :height: 48 px + Scalable vector graphics (SVG) images are not supported by all backends. Rendering depends partially on the backend, especially if the size is not explicitely given. +.. image:: ../../../docs/user/rst/images/title-scaling.svg + :width: 50% + :align: left + +A scaling image occupying 50% of the line width (scales with the +browser window). + Whether an SVG image is scaled or clipped/padded cannot be set in the containing HTML. It depends on the viewport declaration inside its root <svg> element. +.. |inline-svg| image:: ../../../docs/user/rst/images/biohazard-scaling.svg + :height: 0.8 em + +An inline SVG image |inline-svg| scaled to a height of 0.8 em. + +.. image:: ../../../docs/user/rst/images/title-scaling.svg + :width: 50 % + :height: 1.2 em + :align: right + +A scaling image occupying 50% of the line width and 1.2 em high, +right aligned (this SVG image keeps the aspect ratio): + .. image:: ../../../docs/user/rst/images/biohazard-scaling.svg :height: 1 em :align: left A scaling image 1 em high, left aligned. +A scaling image 5 mm x 5 mm, centered, with hyperlink reference: + .. image:: ../../../docs/user/rst/images/biohazard-scaling.svg :target: Directives_ :width: 5 mm - :align: right - -A scaling image 5 mm wide, right aligned, with hyperlink reference: - -.. image:: ../../../docs/user/rst/images/title-scaling.svg - :width: 50% - :align: left - -A scaling image occupying 50% of the line width (scales with the -browser window): - -.. image:: ../../../docs/user/rst/images/title-scaling.svg - :width: 50 % - :height: 15 px - :align: left - -A scaling image occupying 50% of the line width and 15 pixel high -(this SVG image keeps the aspect ratio): - - -.. |inline-svg| image:: ../../../docs/user/rst/images/biohazard-scaling.svg - :height: 0.8 em - -An inline image |inline-svg| scaled to match the text size. + :height: 5 mm + :align: center .. image:: ../../../docs/user/rst/images/biohazard.svg :width: 4 cm @@ -57,12 +61,9 @@ A fixed-size image in a 4 cm x 2 em box. A fixed-size image in a box 50% the line width and 15 pixle high. -SVG image in a figure: - .. figure:: ../../../docs/user/rst/images/title.svg :alt: reStructuredText, the markup syntax :width: 290 px :height: 28 px - This is the caption. - + SVG image in a figure. diff --git a/docutils/test/functional/input/data/swf_images.txt b/docutils/test/functional/input/data/swf_images.txt new file mode 100644 index 000000000..7e9664060 --- /dev/null +++ b/docutils/test/functional/input/data/swf_images.txt @@ -0,0 +1,24 @@ +SWF Images +---------- + +Shockwave Flash is an image/movie format that most modern web browsers +support via a plugin. It is sometimes blocked due to privacy/security +concerns. + +Images with extension ``.swf`` are placed inside <object> elements. +For complete control over display options use raw HTML. + +.. image:: ../../../docs/user/rst/images/biohazard.swf + :alt: [biohazard.swf] + :width: 4 cm + :height: 2 em + :align: left + +An SWF image in a 4 cm x 2 em box, left aligned. + +.. |inline-swf| image:: ../../../docs/user/rst/images/biohazard.swf + :width: 0.8 em + :height: 0.8 em + +An inline SWF image |inline-swf| scaled to 8.0 em x 0.8 em. + diff --git a/docutils/test/functional/input/standalone_rst_html4css1.txt b/docutils/test/functional/input/standalone_rst_html4css1.txt index a3c686ea7..8580daac6 100644 --- a/docutils/test/functional/input/standalone_rst_html4css1.txt +++ b/docutils/test/functional/input/standalone_rst_html4css1.txt @@ -6,4 +6,5 @@ .. include:: data/list_table.txt .. include:: data/custom_roles.txt .. include:: data/svg_images.txt +.. include:: data/swf_images.txt .. include:: data/errors.txt |
