@@ -53,14 +53,14 @@ from docutils.writers.html4css1 import Writer, HTMLTranslator
53
53
SETTINGS = {
54
54
'cloak_email_addresses' : False ,
55
55
'file_insertion_enabled' : False ,
56
- 'raw_enabled' : False ,
56
+ 'raw_enabled' : True ,
57
57
'strip_comments' : True ,
58
58
'doctitle_xform' : True ,
59
59
'sectsubtitle_xform' : True ,
60
60
'initial_header_level' : 2 ,
61
61
'report_level' : 5 ,
62
- 'syntax_highlight' : 'none' ,
63
- 'math_output' : 'latex' ,
62
+ 'syntax_highlight' : 'none' ,
63
+ 'math_output' : 'latex' ,
64
64
'field_name_limit' : 50 ,
65
65
}
66
66
@@ -77,12 +77,13 @@ class DoctestDirective(CodeBlock):
77
77
78
78
79
79
class GitHubHTMLTranslator (HTMLTranslator ):
80
+
80
81
# removes the <div class="document"> tag wrapped around docs
81
82
# see also: http://bit.ly/1exfq2h (warning! sourceforge link.)
82
83
def depart_document (self , node ):
83
84
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
86
87
87
88
# technique for visiting sections, without generating additional divs
88
89
# see also: http://bit.ly/NHtyRx
@@ -115,36 +116,38 @@ class GitHubHTMLTranslator(HTMLTranslator):
115
116
def visit_table (self , node ):
116
117
classes = ' ' .join (['docutils' , self .settings .table_style ]).strip ()
117
118
self .body .append (
118
- self .starttag (node , 'table' , CLASS = classes ))
119
+ self .starttag (node , 'table' , CLASS = classes ))
119
120
120
121
def depart_table (self , node ):
121
122
self .body .append ('</table>\n ' )
122
123
123
124
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 ()
141
142
# 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
+
144
146
145
147
def kbd (name , rawtext , text , lineno , inliner , options = None , content = None ):
146
148
147
- return [nodes .raw ('' , '<kbd>%s</kbd>' % text , format = 'html' )], []
149
+ return [nodes .raw ('' , '<kbd>%s</kbd>' % text , format = 'html' )], []
150
+
148
151
149
152
def main ():
150
153
"""
@@ -156,9 +159,9 @@ def main():
156
159
"""
157
160
try :
158
161
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
160
163
return ''
161
- except IndexError : # no filename given
164
+ except IndexError : # no filename given
162
165
text = sys .stdin .read ()
163
166
164
167
writer = Writer ()
0 commit comments