summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2006-01-22 16:54:10 +0000
committerwiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2006-01-22 16:54:10 +0000
commit9ebd6008d5748fbefa4ffe74576354907508ce74 (patch)
tree8486319e15e932361550fc6cfd8f1765c67468f8
parent75a6f005791e52d0c6317911bd70b0daeb59a1ff (diff)
downloaddocutils-address-rendering.tar.gz
moved r4311 to address-rendering branchaddress-rendering
git-svn-id: http://svn.code.sf.net/p/docutils/code/branches/address-rendering@4314 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
-rw-r--r--HISTORY.txt5
-rw-r--r--docutils/writers/html4css1/__init__.py12
-rw-r--r--docutils/writers/html4css1/html4css1.css6
-rw-r--r--docutils/writers/pep_html/pep.css6
-rw-r--r--test/functional/expected/dangerous.html12
-rw-r--r--test/functional/expected/standalone_rst_html4css1.html29
6 files changed, 24 insertions, 46 deletions
diff --git a/HISTORY.txt b/HISTORY.txt
index 15b3c40ab..0361fb2af 100644
--- a/HISTORY.txt
+++ b/HISTORY.txt
@@ -15,6 +15,11 @@
Changes Since 0.4
=================
+* docutils/writers/html4css1/__init__.py:
+
+ - Addresses are no longer enclosed in ``<pre>`` tags.
+ - Literal blocks are now rendered in a single line of HTML code.
+
Release 0.4 (2006-01-09)
========================
diff --git a/docutils/writers/html4css1/__init__.py b/docutils/writers/html4css1/__init__.py
index 02833d66a..50269f327 100644
--- a/docutils/writers/html4css1/__init__.py
+++ b/docutils/writers/html4css1/__init__.py
@@ -407,6 +407,16 @@ class HTMLTranslator(nodes.NodeVisitor):
encoded = self.encode(text)
if self.in_mailto and self.settings.cloak_email_addresses:
encoded = self.cloak_email(encoded)
+ preserve_space = 0
+ parent = node.parent
+ while parent:
+ if parent.get('xml:space') == 'preserve':
+ preserve_space = 1
+ break
+ parent = parent.parent
+ if preserve_space:
+ encoded = encoded.replace('\n', '<br />')
+ encoded = encoded.replace(' ', ' &nbsp;')
self.body.append(encoded)
def depart_Text(self, node):
@@ -428,10 +438,8 @@ class HTMLTranslator(nodes.NodeVisitor):
def visit_address(self, node):
self.visit_docinfo_item(node, 'address', meta=None)
- self.body.append(self.starttag(node, 'pre', CLASS='address'))
def depart_address(self, node):
- self.body.append('\n</pre>\n')
self.depart_docinfo_item()
def visit_admonition(self, node, name=''):
diff --git a/docutils/writers/html4css1/html4css1.css b/docutils/writers/html4css1/html4css1.css
index e94df1546..0af8fc34d 100644
--- a/docutils/writers/html4css1/html4css1.css
+++ b/docutils/writers/html4css1/html4css1.css
@@ -206,12 +206,6 @@ p.sidebar-subtitle {
p.topic-title {
font-weight: bold }
-pre.address {
- margin-bottom: 0 ;
- margin-top: 0 ;
- font-family: serif ;
- font-size: 100% }
-
pre.literal-block, pre.doctest-block {
margin-left: 2em ;
margin-right: 2em ;
diff --git a/docutils/writers/pep_html/pep.css b/docutils/writers/pep_html/pep.css
index 014d3e423..b4f89eff1 100644
--- a/docutils/writers/pep_html/pep.css
+++ b/docutils/writers/pep_html/pep.css
@@ -269,12 +269,6 @@ p.topic-title {
font-family: sans-serif ;
font-weight: bold }
-pre.address {
- margin-bottom: 0 ;
- margin-top: 0 ;
- font-family: serif ;
- font-size: 100% }
-
pre.literal-block, pre.doctest-block {
margin-left: 2em ;
margin-right: 2em ;
diff --git a/test/functional/expected/dangerous.html b/test/functional/expected/dangerous.html
index c185815b1..ebdd72ead 100644
--- a/test/functional/expected/dangerous.html
+++ b/test/functional/expected/dangerous.html
@@ -21,27 +21,21 @@
<p class="system-message-title">System Message: WARNING/2 (<tt class="docutils">functional/input/dangerous.txt</tt>, line 4)</p>
<p>&quot;raw&quot; directive disabled.</p>
<pre class="literal-block">
-.. raw:: html
- :file: /etc/passwd
+.. raw:: html<br /> &nbsp; :file: /etc/passwd
</pre>
</div>
<div class="system-message">
<p class="system-message-title">System Message: WARNING/2 (<tt class="docutils">functional/input/dangerous.txt</tt>, line 6)</p>
<p>&quot;raw&quot; directive disabled.</p>
<pre class="literal-block">
-.. raw:: html
- :url: file:///etc/passwd
+.. raw:: html<br /> &nbsp; :url: file:///etc/passwd
</pre>
</div>
<div class="system-message">
<p class="system-message-title">System Message: WARNING/2 (<tt class="docutils">functional/input/dangerous.txt</tt>, line 8)</p>
<p>&quot;raw&quot; directive disabled.</p>
<pre class="literal-block">
-.. raw:: html
-
- &lt;script&gt;
- that does something really nasty
- &lt;/script&gt;
+.. raw:: html<br /><br /> &nbsp; &lt;script&gt;<br /> &nbsp; &nbsp; &nbsp; that does something really nasty<br /> &nbsp; &lt;/script&gt;
</pre>
</div>
<div class="system-message">
diff --git a/test/functional/expected/standalone_rst_html4css1.html b/test/functional/expected/standalone_rst_html4css1.html
index aa7d26d76..691a370ca 100644
--- a/test/functional/expected/standalone_rst_html4css1.html
+++ b/test/functional/expected/standalone_rst_html4css1.html
@@ -29,12 +29,7 @@ Document header
<tr><th class="docinfo-name">Author:</th>
<td>David Goodger</td></tr>
<tr><th class="docinfo-name">Address:</th>
-<td><pre class="address">
-123 Example Street
-Example, EX Canada
-A1B 2C3
-</pre>
-</td></tr>
+<td>123 Example Street<br />Example, EX &nbsp;Canada<br />A1B 2C3</td></tr>
<tr><th class="docinfo-name">Contact:</th>
<td><a class="first last reference" href="mailto:goodger&#64;users.sourceforge.net">goodger&#64;users.sourceforge.net</a></td></tr>
<tr><th class="docinfo-name">Authors:</th>
@@ -338,16 +333,11 @@ description.</p>
<p>Literal blocks are indicated with a double-colon (&quot;::&quot;) at the end of
the preceding paragraph (over there <tt class="docutils literal"><span class="pre">--&gt;</span></tt>). They can be indented:</p>
<pre class="literal-block">
-if literal_block:
- text = 'is left as-is'
- spaces_and_linebreaks = 'are preserved'
- markup_processing = None
+if literal_block:<br /> &nbsp; &nbsp;text = 'is left as-is'<br /> &nbsp; &nbsp;spaces_and_linebreaks = 'are preserved'<br /> &nbsp; &nbsp;markup_processing = None
</pre>
<p>Or they can be quoted without indentation:</p>
<pre class="literal-block">
-&gt;&gt; Great idea!
-&gt;
-&gt; Why didn't I think of that?
+&gt;&gt; Great idea!<br />&gt;<br />&gt; Why didn't I think of that?
</pre>
</div>
<div class="section">
@@ -424,10 +414,7 @@ own it, and what it is too.</p>
<div class="section">
<h2><a class="toc-backref" href="#id47" id="doctest-blocks" name="doctest-blocks">2.10&nbsp;&nbsp;&nbsp;Doctest Blocks</a></h2>
<pre class="doctest-block">
-&gt;&gt;&gt; print 'Python-specific usage examples; begun with &quot;&gt;&gt;&gt;&quot;'
-Python-specific usage examples; begun with &quot;&gt;&gt;&gt;&quot;
-&gt;&gt;&gt; print '(cut and pasted from interactive Python sessions)'
-(cut and pasted from interactive Python sessions)
+&gt;&gt;&gt; print 'Python-specific usage examples; begun with &quot;&gt;&gt;&gt;&quot;'<br />Python-specific usage examples; begun with &quot;&gt;&gt;&gt;&quot;<br />&gt;&gt;&gt; print '(cut and pasted from interactive Python sessions)'<br />(cut and pasted from interactive Python sessions)
</pre>
</div>
<div class="section">
@@ -725,8 +712,7 @@ Compound 2, literal.
</div>
<div class="compound">
<pre class="compound-first literal-block">
-Compound 4.
-This one starts with a literal block.
+Compound 4.<br />This one starts with a literal block.
</pre>
<p class="compound-last">Compound 4, a paragraph.</p>
</div>
@@ -773,10 +759,7 @@ paragraph.</td>
<div class="section">
<h3><a class="toc-backref" href="#id79" id="parsed-literal-blocks" name="parsed-literal-blocks">2.14.8&nbsp;&nbsp;&nbsp;Parsed Literal Blocks</a></h3>
<pre class="literal-block">
-This is a parsed literal block.
- This line is indented. The next line is blank.
-
-Inline markup is supported, e.g. <em>emphasis</em>, <strong>strong</strong>, <tt class="docutils literal"><span class="pre">literal</span>
+This is a parsed literal block.<br /> &nbsp; &nbsp;This line is indented. &nbsp;The next line is blank.<br /><br />Inline markup is supported, e.g. <em>emphasis</em>, <strong>strong</strong>, <tt class="docutils literal"><span class="pre">literal</span>
<span class="pre">text</span></tt>, footnotes <a class="footnote-reference" href="#id8" id="id21" name="id21">[1]</a>, <span class="target" id="id22">targets</span>, and <a class="reference" href="http://www.python.org/">references</a>.
</pre>
</div>