@@ -58,18 +58,20 @@ SETTINGS = {
58
58
'sectsubtitle_xform' : True ,
59
59
'initial_header_level' : 2 ,
60
60
'report_level' : 5 ,
61
- 'syntax_highlight' : 'none' ,
62
- 'math_output' : 'latex' ,
61
+ 'syntax_highlight' : 'none' ,
62
+ 'math_output' : 'latex' ,
63
63
'field_name_limit' : 50 ,
64
64
}
65
65
66
+
66
67
class GitHubHTMLTranslator (HTMLTranslator ):
68
+
67
69
# removes the <div class="document"> tag wrapped around docs
68
70
# see also: http://bit.ly/1exfq2h (warning! sourceforge link.)
69
71
def depart_document (self , node ):
70
72
HTMLTranslator .depart_document (self , node )
71
- self .html_body .pop (0 ) # pop the starting <div> off
72
- self .html_body .pop () # pop the ending </div> off
73
+ self .html_body .pop (0 ) # pop the starting <div> off
74
+ self .html_body .pop () # pop the ending </div> off
73
75
74
76
# technique for visiting sections, without generating additional divs
75
77
# see also: http://bit.ly/NHtyRx
@@ -102,36 +104,38 @@ class GitHubHTMLTranslator(HTMLTranslator):
102
104
def visit_table (self , node ):
103
105
classes = ' ' .join (['docutils' , self .settings .table_style ]).strip ()
104
106
self .body .append (
105
- self .starttag (node , 'table' , CLASS = classes ))
107
+ self .starttag (node , 'table' , CLASS = classes ))
106
108
107
109
def depart_table (self , node ):
108
110
self .body .append ('</table>\n ' )
109
111
110
112
def depart_image (self , node ):
111
- uri = node ['uri' ]
112
- ext = os .path .splitext (uri )[1 ].lower ()
113
- # we need to swap RST's use of `object` with `img` tags
114
- # see http://git.io/5me3dA
115
- if ext == ".svg" :
116
- # preserve essential attributes
117
- atts = {}
118
- for attribute , value in node .attributes .items ():
119
- # we have no time for empty values
120
- if value :
121
- if attribute == "uri" :
122
- atts ['src' ] = value
123
- else :
124
- atts [attribute ] = value
125
-
126
- # toss off `object` tag
127
- self .body .pop ()
113
+ uri = node ['uri' ]
114
+ ext = os .path .splitext (uri )[1 ].lower ()
115
+ # we need to swap RST's use of `object` with `img` tags
116
+ # see http://git.io/5me3dA
117
+ if ext == ".svg" :
118
+ # preserve essential attributes
119
+ atts = {}
120
+ for attribute , value in node .attributes .items ():
121
+ # we have no time for empty values
122
+ if value :
123
+ if attribute == "uri" :
124
+ atts ['src' ] = value
125
+ else :
126
+ atts [attribute ] = value
127
+
128
+ # toss off `object` tag
129
+ self .body .pop ()
128
130
# add on `img` with attributes
129
- self .body .append (self .starttag (node , 'img' , ** atts ))
130
- self .body .append (self .context .pop ())
131
+ self .body .append (self .starttag (node , 'img' , ** atts ))
132
+ self .body .append (self .context .pop ())
133
+
131
134
132
135
def kbd (name , rawtext , text , lineno , inliner , options = None , content = None ):
133
136
134
- return [nodes .raw ('' , '<kbd>%s</kbd>' % text , format = 'html' )], []
137
+ return [nodes .raw ('' , '<kbd>%s</kbd>' % text , format = 'html' )], []
138
+
135
139
136
140
def main ():
137
141
"""
@@ -143,9 +147,9 @@ def main():
143
147
"""
144
148
try :
145
149
text = codecs .open (sys .argv [1 ], 'r' , 'utf-8' ).read ()
146
- except IOError : # given filename could not be found
150
+ except IOError : # given filename could not be found
147
151
return ''
148
- except IndexError : # no filename given
152
+ except IndexError : # no filename given
149
153
text = sys .stdin .read ()
150
154
151
155
writer = Writer ()
0 commit comments