Skip to content

Commit 802316b

Browse files
committed
Merge pull request github#502 from github/fix-dat-rst
Fix a couple of RST issues
2 parents 4691aec + 07cf187 commit 802316b

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

lib/github/commands/rest2html

+9-1
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ except:
4444

4545
import codecs
4646

47+
from docutils import nodes
48+
from docutils.parsers.rst import roles
4749
from docutils.core import publish_parts
4850
from docutils.writers.html4css1 import Writer, HTMLTranslator
4951

5052
SETTINGS = {
51-
'cloak_email_addresses': True,
53+
'cloak_email_addresses': False,
5254
'file_insertion_enabled': False,
5355
'raw_enabled': False,
5456
'strip_comments': True,
@@ -127,6 +129,10 @@ class GitHubHTMLTranslator(HTMLTranslator):
127129
self.body.append(self.starttag(node, 'img', **atts))
128130
self.body.append(self.context.pop())
129131

132+
def kbd(name, rawtext, text, lineno, inliner, options=None, content=None):
133+
134+
return [nodes.raw('', '<kbd>%s</kbd>' % text, format='html')], []
135+
130136
def main():
131137
"""
132138
Parses the given ReST file or the redirected string input and returns the
@@ -145,6 +151,8 @@ def main():
145151
writer = Writer()
146152
writer.translator_class = GitHubHTMLTranslator
147153

154+
roles.register_canonical_role('kbd', kbd)
155+
148156
parts = publish_parts(text, writer=writer, settings_overrides=SETTINGS)
149157
if 'html_body' in parts:
150158
html = parts['html_body']

test/markups/README.rst

+4
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,7 @@ Field list
5555
but no problem!
5656
:123456789 12345: this is not so long, but long enough for the default!
5757
:123456789 1234: this should work even with the default :)
58+
59+
60+
61+
Press :kbd:`Ctrl+C` to quit

test/markups/README.rst.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,8 @@ <h2><a href="#id2">Field list</a></h2>
7272
<td>this should work even with the default :)</td>
7373
</tr>
7474
</tbody>
75-
</table>
75+
</table>
76+
77+
<p><a href="mailto:[email protected]">[email protected]</a></p>
78+
79+
<p>Press <kbd>Ctrl+C</kbd> to quit</p>

0 commit comments

Comments
 (0)