From: <fel...@us...> - 2005-05-26 00:44:39
|
Author: felixwiemann Date: 2005-05-26 02:44:13 +0200 (Thu, 26 May 2005) New Revision: 3367 Modified: trunk/docutils/docutils/writers/html4css1.py trunk/docutils/docutils/writers/latex2e.py trunk/docutils/test/functional/expected/standalone_rst_html4css1.html trunk/docutils/test/functional/expected/standalone_rst_latex.tex trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt trunk/docutils/test/functional/input/data/standard.txt trunk/docutils/tools/stylesheets/default.css Log: added support and test for section subtitles Modified: trunk/docutils/docutils/writers/html4css1.py =================================================================== --- trunk/docutils/docutils/writers/html4css1.py 2005-05-25 23:59:45 UTC (rev 3366) +++ trunk/docutils/docutils/writers/html4css1.py 2005-05-26 00:44:13 UTC (rev 3367) @@ -1206,6 +1206,12 @@ self.body.append(self.starttag(node, 'h2', '', CLASS='subtitle')) self.context.append('</h2>\n') self.in_document_title = len(self.body) + elif isinstance(node.parent, nodes.section): + tag = 'h%s' % (self.section_level + self.initial_header_level - 1) + self.body.append( + self.starttag(node, tag, '', CLASS='section-subtitle') + + self.starttag({}, 'span', '', CLASS='section-subtitle')) + self.context.append('</span></%s>\n' % tag) def depart_subtitle(self, node): self.body.append(self.context.pop()) @@ -1354,9 +1360,14 @@ self.context.append('</h1>\n') self.in_document_title = len(self.body) else: + assert isinstance(node.parent, nodes.section) h_level = self.section_level + self.initial_header_level - 1 + atts = {} + if (len(node.parent) >= 2 and + isinstance(node.parent[1], nodes.subtitle)): + atts['CLASS'] = 'with-subtitle' self.body.append( - self.starttag(node, 'h%s' % h_level, '')) + self.starttag(node, 'h%s' % h_level, '', **atts)) atts = {} if node.parent['ids']: atts['name'] = node.parent['ids'][0] Modified: trunk/docutils/docutils/writers/latex2e.py =================================================================== --- trunk/docutils/docutils/writers/latex2e.py 2005-05-25 23:59:45 UTC (rev 3366) +++ trunk/docutils/docutils/writers/latex2e.py 2005-05-26 00:44:13 UTC (rev 3367) @@ -1815,14 +1815,16 @@ if isinstance(node.parent, nodes.sidebar): self.body.append('~\\\\\n\\textbf{') self.context.append('}\n\\smallskip\n') - else: + elif isinstance(node.parent, nodes.document): self.title = self.title + \ '\\\\\n\\large{%s}\n' % self.encode(node.astext()) raise nodes.SkipNode + elif isinstance(node.parent, nodes.section): + self.body.append('\\textbf{') + self.context.append('}\\vspace{0.2cm}\n\n\\noindent ') def depart_subtitle(self, node): - if isinstance(node.parent, nodes.sidebar): - self.body.append(self.context.pop()) + self.body.append(self.context.pop()) def visit_system_message(self, node): if node['level'] < self.document.reporter.report_level: Modified: trunk/docutils/test/functional/expected/standalone_rst_html4css1.html =================================================================== --- trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2005-05-25 23:59:45 UTC (rev 3366) +++ trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2005-05-26 00:44:13 UTC (rev 3367) @@ -140,7 +140,8 @@ <div class="section" id="structural-elements"> <h1><a class="toc-backref" href="#id25" name="structural-elements">1 Structural Elements</a></h1> <div class="section" id="section-title"> -<h2><a class="toc-backref" href="#id26" name="section-title">1.1 Section Title</a></h2> +<h2 class="with-subtitle"><a class="toc-backref" href="#id26" name="section-title">1.1 Section Title</a></h2> +<h2 class="section-subtitle" id="section-subtitle"><span class="section-subtitle">Section Subtitle</span></h2> <p>That's it, the text just above this line.</p> </div> <div class="section" id="empty-section"> @@ -924,19 +925,19 @@ <div class="system-messages section"> <h1><a>Docutils System Messages</a></h1> <div class="system-message" id="id19"> -<p class="system-message-title">System Message: <a name="id19">ERROR/3</a> (<tt class="docutils">functional/input/data/standard.txt</tt>, line 98); <em><a href="#id20">backlink</a></em></p> +<p class="system-message-title">System Message: <a name="id19">ERROR/3</a> (<tt class="docutils">functional/input/data/standard.txt</tt>, line 100); <em><a href="#id20">backlink</a></em></p> Undefined substitution referenced: "problematic".</div> <div class="system-message" id="id69"> -<p class="system-message-title">System Message: <a name="id69">ERROR/3</a> (<tt class="docutils">functional/input/standalone_rst_html4css1.txt</tt>, line 352); <em><a href="#id70">backlink</a></em></p> +<p class="system-message-title">System Message: <a name="id69">ERROR/3</a> (<tt class="docutils">functional/input/standalone_rst_html4css1.txt</tt>, line 354); <em><a href="#id70">backlink</a></em></p> Unknown target name: "5".</div> <div class="system-message" id="id71"> -<p class="system-message-title">System Message: <a name="id71">ERROR/3</a> (<tt class="docutils">functional/input/data/standard.txt</tt>, line 361); <em><a href="#id72">backlink</a></em></p> +<p class="system-message-title">System Message: <a name="id71">ERROR/3</a> (<tt class="docutils">functional/input/data/standard.txt</tt>, line 363); <em><a href="#id72">backlink</a></em></p> Unknown target name: "nonexistent".</div> <div class="system-message" id="id73"> -<p class="system-message-title">System Message: <a name="id73">ERROR/3</a> (<tt class="docutils">functional/input/data/standard.txt</tt>, line 388); <em><a href="#id74">backlink</a></em></p> +<p class="system-message-title">System Message: <a name="id73">ERROR/3</a> (<tt class="docutils">functional/input/data/standard.txt</tt>, line 390); <em><a href="#id74">backlink</a></em></p> Unknown target name: "hyperlink reference without a target".</div> <div class="system-message" id="id75"> -<p class="system-message-title">System Message: <a name="id75">ERROR/3</a> (<tt class="docutils">functional/input/data/standard.txt</tt>, line 401); <em><a href="#id76">backlink</a></em></p> +<p class="system-message-title">System Message: <a name="id75">ERROR/3</a> (<tt class="docutils">functional/input/data/standard.txt</tt>, line 403); <em><a href="#id76">backlink</a></em></p> Duplicate target name, cannot be used as a unique reference: "duplicate target names".</div> </div> </div> Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex =================================================================== --- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2005-05-25 23:59:45 UTC (rev 3366) +++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2005-05-26 00:44:13 UTC (rev 3367) @@ -238,7 +238,9 @@ \hypertarget{section-title}{} \pdfbookmark[1]{1.1~~~Section Title}{section-title} \subsection*{1.1~~~Section Title} +\textbf{Section Subtitle}\vspace{0.2cm} +\noindent That's it, the text just above this line. Modified: trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt =================================================================== --- trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt 2005-05-25 23:59:45 UTC (rev 3366) +++ trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt 2005-05-26 00:44:13 UTC (rev 3367) @@ -326,6 +326,8 @@ <generated classes="sectnum"> 1.1 Section Title + <subtitle ids="section-subtitle" names="section subtitle"> + Section Subtitle <paragraph> That's it, the text just above this line. <section ids="empty-section" names="empty section"> @@ -1707,18 +1709,18 @@ <section classes="system-messages"> <title> Docutils System Messages - <system_message backrefs="id20" ids="id19" level="3" line="98" source="functional/input/data/standard.txt" type="ERROR"> + <system_message backrefs="id20" ids="id19" level="3" line="100" source="functional/input/data/standard.txt" type="ERROR"> <paragraph> Undefined substitution referenced: "problematic". - <system_message backrefs="id70" ids="id69" level="3" line="352" source="functional/input/standalone_rst_html4css1.txt" type="ERROR"> + <system_message backrefs="id70" ids="id69" level="3" line="354" source="functional/input/standalone_rst_html4css1.txt" type="ERROR"> <paragraph> Unknown target name: "5". - <system_message backrefs="id72" ids="id71" level="3" line="361" source="functional/input/data/standard.txt" type="ERROR"> + <system_message backrefs="id72" ids="id71" level="3" line="363" source="functional/input/data/standard.txt" type="ERROR"> <paragraph> Unknown target name: "nonexistent". - <system_message backrefs="id74" ids="id73" level="3" line="388" source="functional/input/data/standard.txt" type="ERROR"> + <system_message backrefs="id74" ids="id73" level="3" line="390" source="functional/input/data/standard.txt" type="ERROR"> <paragraph> Unknown target name: "hyperlink reference without a target". - <system_message backrefs="id76" ids="id75" level="3" line="401" source="functional/input/data/standard.txt" type="ERROR"> + <system_message backrefs="id76" ids="id75" level="3" line="403" source="functional/input/data/standard.txt" type="ERROR"> <paragraph> Duplicate target name, cannot be used as a unique reference: "duplicate target names". Modified: trunk/docutils/test/functional/input/data/standard.txt =================================================================== --- trunk/docutils/test/functional/input/data/standard.txt 2005-05-25 23:59:45 UTC (rev 3366) +++ trunk/docutils/test/functional/input/data/standard.txt 2005-05-26 00:44:13 UTC (rev 3367) @@ -65,6 +65,8 @@ Section Title ------------- +Section Subtitle +```````````````` That's it, the text just above this line. Modified: trunk/docutils/tools/stylesheets/default.css =================================================================== --- trunk/docutils/tools/stylesheets/default.css 2005-05-25 23:59:45 UTC (rev 3366) +++ trunk/docutils/tools/stylesheets/default.css 2005-05-26 00:44:13 UTC (rev 3367) @@ -14,7 +14,7 @@ .first { margin-top: 0 ! important } -.last { +.last, .with-subtitle { margin-bottom: 0 ! important } .hidden { @@ -125,6 +125,10 @@ div.topic { margin: 2em } +h1.section-subtitle, h2.section-subtitle, h3.section-subtitle, +h4.section-subtitle, h5.section-subtitle, h6.section-subtitle { + margin-top: 0.4em } + h1.title { text-align: center } @@ -219,6 +223,9 @@ span.problematic { color: red } +span.section-subtitle { + font-size: 80% } + table.citation { border-left: solid thin gray } |