Skip to content

Commit 58389ca

Browse files
committed
Merge branch 'kakwa-raw_html_rst'
2 parents c4c6603 + b90deae commit 58389ca

File tree

1 file changed

+31
-28
lines changed

1 file changed

+31
-28
lines changed

lib/github/commands/rest2html

+31-28
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ from docutils.writers.html4css1 import Writer, HTMLTranslator
5353
SETTINGS = {
5454
'cloak_email_addresses': False,
5555
'file_insertion_enabled': False,
56-
'raw_enabled': False,
56+
'raw_enabled': True,
5757
'strip_comments': True,
5858
'doctitle_xform': True,
5959
'sectsubtitle_xform': True,
6060
'initial_header_level': 2,
6161
'report_level': 5,
62-
'syntax_highlight' : 'none',
63-
'math_output' : 'latex',
62+
'syntax_highlight': 'none',
63+
'math_output': 'latex',
6464
'field_name_limit': 50,
6565
}
6666

@@ -77,12 +77,13 @@ class DoctestDirective(CodeBlock):
7777

7878

7979
class GitHubHTMLTranslator(HTMLTranslator):
80+
8081
# removes the <div class="document"> tag wrapped around docs
8182
# see also: http://bit.ly/1exfq2h (warning! sourceforge link.)
8283
def depart_document(self, node):
8384
HTMLTranslator.depart_document(self, node)
84-
self.html_body.pop(0) # pop the starting <div> off
85-
self.html_body.pop() # pop the ending </div> off
85+
self.html_body.pop(0) # pop the starting <div> off
86+
self.html_body.pop() # pop the ending </div> off
8687

8788
# technique for visiting sections, without generating additional divs
8889
# see also: http://bit.ly/NHtyRx
@@ -115,36 +116,38 @@ class GitHubHTMLTranslator(HTMLTranslator):
115116
def visit_table(self, node):
116117
classes = ' '.join(['docutils', self.settings.table_style]).strip()
117118
self.body.append(
118-
self.starttag(node, 'table', CLASS=classes))
119+
self.starttag(node, 'table', CLASS=classes))
119120

120121
def depart_table(self, node):
121122
self.body.append('</table>\n')
122123

123124
def depart_image(self, node):
124-
uri = node['uri']
125-
ext = os.path.splitext(uri)[1].lower()
126-
# we need to swap RST's use of `object` with `img` tags
127-
# see http://git.io/5me3dA
128-
if ext == ".svg":
129-
# preserve essential attributes
130-
atts = {}
131-
for attribute, value in node.attributes.items():
132-
# we have no time for empty values
133-
if value:
134-
if attribute == "uri":
135-
atts['src'] = value
136-
else:
137-
atts[attribute] = value
138-
139-
# toss off `object` tag
140-
self.body.pop()
125+
uri = node['uri']
126+
ext = os.path.splitext(uri)[1].lower()
127+
# we need to swap RST's use of `object` with `img` tags
128+
# see http://git.io/5me3dA
129+
if ext == ".svg":
130+
# preserve essential attributes
131+
atts = {}
132+
for attribute, value in node.attributes.items():
133+
# we have no time for empty values
134+
if value:
135+
if attribute == "uri":
136+
atts['src'] = value
137+
else:
138+
atts[attribute] = value
139+
140+
# toss off `object` tag
141+
self.body.pop()
141142
# add on `img` with attributes
142-
self.body.append(self.starttag(node, 'img', **atts))
143-
self.body.append(self.context.pop())
143+
self.body.append(self.starttag(node, 'img', **atts))
144+
self.body.append(self.context.pop())
145+
144146

145147
def kbd(name, rawtext, text, lineno, inliner, options=None, content=None):
146148

147-
return [nodes.raw('', '<kbd>%s</kbd>' % text, format='html')], []
149+
return [nodes.raw('', '<kbd>%s</kbd>' % text, format='html')], []
150+
148151

149152
def main():
150153
"""
@@ -156,9 +159,9 @@ def main():
156159
"""
157160
try:
158161
text = codecs.open(sys.argv[1], 'r', 'utf-8').read()
159-
except IOError: # given filename could not be found
162+
except IOError: # given filename could not be found
160163
return ''
161-
except IndexError: # no filename given
164+
except IndexError: # no filename given
162165
text = sys.stdin.read()
163166

164167
writer = Writer()

0 commit comments

Comments
 (0)