diff options
| author | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2005-05-26 00:44:13 +0000 |
|---|---|---|
| committer | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2005-05-26 00:44:13 +0000 |
| commit | 20e4111fbf91ebb59ef887815dcdfbcf78dcf6d4 (patch) | |
| tree | 92f5a28ea0816056b9dd83279eb8b29be45a5ee3 /docutils | |
| parent | 4103b1549845a7f7ec6d709e5c788adbca7d24ad (diff) | |
| download | docutils-20e4111fbf91ebb59ef887815dcdfbcf78dcf6d4.tar.gz | |
added support and test for section subtitles
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@3367 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils')
| -rw-r--r-- | docutils/docutils/writers/html4css1.py | 13 | ||||
| -rw-r--r-- | docutils/docutils/writers/latex2e.py | 8 | ||||
| -rw-r--r-- | docutils/test/functional/expected/standalone_rst_html4css1.html | 13 | ||||
| -rw-r--r-- | docutils/test/functional/expected/standalone_rst_latex.tex | 2 | ||||
| -rw-r--r-- | docutils/test/functional/expected/standalone_rst_pseudoxml.txt | 12 | ||||
| -rw-r--r-- | docutils/test/functional/input/data/standard.txt | 2 | ||||
| -rw-r--r-- | docutils/tools/stylesheets/default.css | 9 |
7 files changed, 43 insertions, 16 deletions
diff --git a/docutils/docutils/writers/html4css1.py b/docutils/docutils/writers/html4css1.py index 5130bf1d4..1a7d44f0a 100644 --- a/docutils/docutils/writers/html4css1.py +++ b/docutils/docutils/writers/html4css1.py @@ -1206,6 +1206,12 @@ class HTMLTranslator(nodes.NodeVisitor): 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 @@ class HTMLTranslator(nodes.NodeVisitor): 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] diff --git a/docutils/docutils/writers/latex2e.py b/docutils/docutils/writers/latex2e.py index 3a90efb08..dc7df9731 100644 --- a/docutils/docutils/writers/latex2e.py +++ b/docutils/docutils/writers/latex2e.py @@ -1815,14 +1815,16 @@ class LaTeXTranslator(nodes.NodeVisitor): 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: diff --git a/docutils/test/functional/expected/standalone_rst_html4css1.html b/docutils/test/functional/expected/standalone_rst_html4css1.html index b2c113964..3666d6e18 100644 --- a/docutils/test/functional/expected/standalone_rst_html4css1.html +++ b/docutils/test/functional/expected/standalone_rst_html4css1.html @@ -140,7 +140,8 @@ They are transformed from section titles after parsing. --> <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 @@ section, "Docutils System Messages":</p> <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> diff --git a/docutils/test/functional/expected/standalone_rst_latex.tex b/docutils/test/functional/expected/standalone_rst_latex.tex index f618b05c5..ec682aa52 100644 --- a/docutils/test/functional/expected/standalone_rst_latex.tex +++ b/docutils/test/functional/expected/standalone_rst_latex.tex @@ -238,7 +238,9 @@ reStructuredText construct. \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. diff --git a/docutils/test/functional/expected/standalone_rst_pseudoxml.txt b/docutils/test/functional/expected/standalone_rst_pseudoxml.txt index 38167aa22..1c21abc9a 100644 --- a/docutils/test/functional/expected/standalone_rst_pseudoxml.txt +++ b/docutils/test/functional/expected/standalone_rst_pseudoxml.txt @@ -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". diff --git a/docutils/test/functional/input/data/standard.txt b/docutils/test/functional/input/data/standard.txt index 2759d88e0..a4a75b078 100644 --- a/docutils/test/functional/input/data/standard.txt +++ b/docutils/test/functional/input/data/standard.txt @@ -65,6 +65,8 @@ Structural Elements Section Title ------------- +Section Subtitle +```````````````` That's it, the text just above this line. diff --git a/docutils/tools/stylesheets/default.css b/docutils/tools/stylesheets/default.css index 2cfc4c892..cec78e53b 100644 --- a/docutils/tools/stylesheets/default.css +++ b/docutils/tools/stylesheets/default.css @@ -14,7 +14,7 @@ Default cascading style sheet for the HTML output of Docutils. .first { margin-top: 0 ! important } -.last { +.last, .with-subtitle { margin-bottom: 0 ! important } .hidden { @@ -125,6 +125,10 @@ div.system-message p.system-message-title { 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.pre { span.problematic { color: red } +span.section-subtitle { + font-size: 80% } + table.citation { border-left: solid thin gray } |
