Skip to content

Commit fd379b1

Browse files
committed
Merge pull request github#279 from fdr/titles-subtitles
Interpret titles and subtitles in rst
2 parents 1d3063c + 8f706f7 commit fd379b1

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

lib/github/commands/rest2html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python2 -S
1+
#!/usr/bin/env python
22
"""
33
rest2html - A small wrapper file for parsing ReST files at GitHub.
44
@@ -32,6 +32,7 @@ import os
3232

3333
# This fixes docutils failing with unicode parameters to CSV-Table. The -S
3434
# switch and the following 2 lines can be removed after upgrading to python 3.
35+
reload(sys)
3536
sys.setdefaultencoding('utf-8')
3637
import site
3738

@@ -51,7 +52,9 @@ SETTINGS = {
5152
'file_insertion_enabled': False,
5253
'raw_enabled': False,
5354
'strip_comments': True,
54-
'doctitle_xform': False,
55+
'doctitle_xform': True,
56+
'sectsubtitle_xform': True,
57+
'initial_header_level': 2,
5558
'report_level': 3,
5659
'syntax_highlight' : 'none',
5760
'math_output' : 'latex'

test/markups/README.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
Header 1
22
========
3+
--------
4+
Subtitle
5+
--------
36

47
Example text.
58

9+
.. contents:: Table of Contents
10+
611
Header 2
712
--------
813

test/markups/README.rst.html

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
<h1>Header 1</h1>
1+
<h1 class="title">Header 1</h1>
2+
<h2 class="subtitle" id="subtitle">Subtitle</h2>
23
<p>Example text.</p>
3-
<h2>Header 2</h2>
4+
<div class="contents topic" id="table-of-contents">
5+
<p class="topic-title first">Table of Contents</p>
6+
<ul class="simple">
7+
<li><a class="reference internal" href="#header-2" id="id1">Header 2</a></li>
8+
</ul>
9+
</div>
10+
<h2><a class="toc-backref" href="#id1">Header 2</a></h2>
411
<ol class="arabic simple">
512
<li>Blah blah <tt class="docutils literal">code</tt> blah</li>
613
<li>More <tt class="docutils literal">code</tt>, hooray</li>
714
<li>Somé UTF-8°</li>
815
</ol>
916
<p>The UTF-8 quote character in this table used to cause python to go boom. Now docutils just displays an error inline so the user can fix it. Upgrading to Python 3 will fix this.</p>
1017
<div class="system-message">
11-
<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">&lt;string&gt;</tt>, line 17)</p>
18+
<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">&lt;string&gt;</tt>, line 22)</p>
1219
<p>Error with CSV data in &quot;csv-table&quot; directive:
1320
&quot;quotechar&quot; must be an 1-character string</p>
1421
<pre>

test/markups/README.rst.txt.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<h1>Header 1</h1>
1+
<h1 class="title">Header 1</h1>
22
<p>Example text.</p>
33
<h2>Header 2</h2>
44
<ol class="arabic simple">

0 commit comments

Comments
 (0)