Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output <code> instead of <tt> for inline literals in rst files #370

Merged
merged 2 commits into from
Nov 21, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/github/commands/rest2html
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ class GitHubHTMLTranslator(HTMLTranslator):
else:
self.body.append(self.starttag(node, 'pre'))

# always wrap two-backtick rst inline literals in <code>, not <tt>
# this also avoids the generation of superfluous <span> tags
def visit_literal(self, node):
self.body.append(self.starttag(node, 'code', suffix=''))

def depart_literal(self, node):
self.body.append('</code>')

def visit_table(self, node):
classes = ' '.join(['docutils', self.settings.table_style]).strip()
self.body.append(
Expand Down
4 changes: 2 additions & 2 deletions test/markups/README.rst.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ <h2 class="subtitle" id="subtitle">Subtitle</h2>
</div>
<h2><a class="toc-backref" href="#id1">Header 2</a></h2>
<ol class="arabic simple">
<li>Blah blah <tt class="docutils literal">code</tt> blah</li>
<li>More <tt class="docutils literal">code</tt>, hooray</li>
<li>Blah blah <code>code</code> blah</li>
<li>More <code>code</code>, hooray</li>
<li>Somé UTF-8°</li>
</ol>
<p>The UTF-8 quote character in this table used to cause python to go boom. Now docutils just silently ignores it.</p>
Expand Down
4 changes: 2 additions & 2 deletions test/markups/README.rst.txt.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ <h1 class="title">Header 1</h1>
<p>Example text.</p>
<h2>Header 2</h2>
<ol class="arabic simple">
<li>Blah blah <tt class="docutils literal">code</tt> blah</li>
<li>More <tt class="docutils literal">code</tt>, hooray</li>
<li>Blah blah <code>code</code> blah</li>
<li>More <code>code</code>, hooray</li>
<li>Somé UTF-8°</li>
</ol>
<table class="docutils">
Expand Down