@@ -6,7 +6,7 @@ class Renderer
6
6
rules if you create plugin and adds new token types.
7
7
"""
8
8
import inspect
9
- from typing import List
9
+ from typing import Sequence
10
10
11
11
from .common .utils import unescapeAll , escapeHtml
12
12
from .token import Token
@@ -51,7 +51,7 @@ def __init__(self, parser=None):
51
51
if not (k .startswith ("render" ) or k .startswith ("_" ))
52
52
}
53
53
54
- def render (self , tokens : List [Token ], options , env ) -> str :
54
+ def render (self , tokens : Sequence [Token ], options , env ) -> str :
55
55
"""Takes token stream and generates HTML.
56
56
57
57
:param tokens: list on block tokens to render
@@ -73,7 +73,7 @@ def render(self, tokens: List[Token], options, env) -> str:
73
73
74
74
return result
75
75
76
- def renderInline (self , tokens : List [Token ], options , env ) -> str :
76
+ def renderInline (self , tokens : Sequence [Token ], options , env ) -> str :
77
77
"""The same as ``render``, but for single token of `inline` type.
78
78
79
79
:param tokens: list on block tokens to render
@@ -91,7 +91,7 @@ def renderInline(self, tokens: List[Token], options, env) -> str:
91
91
return result
92
92
93
93
def renderToken (
94
- self , tokens : List [Token ], idx : int , options : dict , env : dict
94
+ self , tokens : Sequence [Token ], idx : int , options : dict , env : dict
95
95
) -> str :
96
96
"""Default token renderer.
97
97
@@ -169,7 +169,7 @@ def renderAttrs(token):
169
169
170
170
return result
171
171
172
- def renderInlineAsText (self , tokens : List [Token ], options , env ) -> str :
172
+ def renderInlineAsText (self , tokens : Sequence [Token ], options , env ) -> str :
173
173
"""Special kludge for image `alt` attributes to conform CommonMark spec.
174
174
175
175
Don't try to use it! Spec requires to show `alt` content with stripped markup,
@@ -192,7 +192,7 @@ def renderInlineAsText(self, tokens: List[Token], options, env) -> str:
192
192
193
193
###################################################
194
194
195
- def code_inline (self , tokens , idx , options , env ):
195
+ def code_inline (self , tokens : Sequence [ Token ] , idx , options , env ):
196
196
token = tokens [idx ]
197
197
return (
198
198
"<code"
@@ -202,7 +202,7 @@ def code_inline(self, tokens, idx, options, env):
202
202
+ "</code>"
203
203
)
204
204
205
- def code_block (self , tokens , idx , options , env ):
205
+ def code_block (self , tokens : Sequence [ Token ] , idx , options , env ):
206
206
token = tokens [idx ]
207
207
208
208
return (
@@ -213,7 +213,7 @@ def code_block(self, tokens, idx, options, env):
213
213
+ "</code></pre>\n "
214
214
)
215
215
216
- def fence (self , tokens , idx , options , env ):
216
+ def fence (self , tokens : Sequence [ Token ] , idx , options , env ):
217
217
token = tokens [idx ]
218
218
info = unescapeAll (token .info ).strip () if token .info else ""
219
219
langName = ""
@@ -262,7 +262,7 @@ def fence(self, tokens, idx, options, env):
262
262
+ "</code></pre>\n "
263
263
)
264
264
265
- def image (self , tokens , idx , options , env ):
265
+ def image (self , tokens : Sequence [ Token ] , idx , options , env ):
266
266
token = tokens [idx ]
267
267
268
268
# "alt" attr MUST be set, even if empty. Because it's mandatory and
@@ -276,19 +276,19 @@ def image(self, tokens, idx, options, env):
276
276
277
277
return self .renderToken (tokens , idx , options , env )
278
278
279
- def hardbreak (self , tokens , idx , options , * args ):
279
+ def hardbreak (self , tokens : Sequence [ Token ] , idx , options , * args ):
280
280
return "<br />\n " if options .xhtmlOut else "<br>\n "
281
281
282
- def softbreak (self , tokens , idx , options , * args ):
282
+ def softbreak (self , tokens : Sequence [ Token ] , idx , options , * args ):
283
283
return (
284
284
("<br />\n " if options .xhtmlOut else "<br>\n " ) if options .breaks else "\n "
285
285
)
286
286
287
- def text (self , tokens , idx , * args ):
287
+ def text (self , tokens : Sequence [ Token ] , idx , * args ):
288
288
return escapeHtml (tokens [idx ].content )
289
289
290
- def html_block (self , tokens , idx , * args ):
290
+ def html_block (self , tokens : Sequence [ Token ] , idx , * args ):
291
291
return tokens [idx ].content
292
292
293
- def html_inline (self , tokens , idx , * args ):
293
+ def html_inline (self , tokens : Sequence [ Token ] , idx , * args ):
294
294
return tokens [idx ].content
0 commit comments