@@ -83,8 +83,8 @@ def render(
8383
8484 for i , token in enumerate (tokens ):
8585 if token .type == "inline" :
86- assert token .children is not None
87- result += self .renderInline (token .children , options , env )
86+ if token .children :
87+ result += self .renderInline (token .children , options , env )
8888 elif token .type in self .rules :
8989 result += self .rules [token .type ](tokens , i , options , env )
9090 else :
@@ -206,8 +206,8 @@ def renderInlineAsText(
206206 if token .type == "text" :
207207 result += token .content
208208 elif token .type == "image" :
209- assert token .children is not None
210- result += self .renderInlineAsText (token .children , options , env )
209+ if token .children :
210+ result += self .renderInlineAsText (token .children , options , env )
211211 elif token .type == "softbreak" :
212212 result += "\n "
213213
@@ -305,14 +305,10 @@ def image(
305305
306306 # "alt" attr MUST be set, even if empty. Because it's mandatory and
307307 # should be placed on proper position for tests.
308-
309- assert (
310- token .attrs and "alt" in token .attrs
311- ), '"image" token\' s attrs must contain `alt`'
312-
313- # Replace content with actual value
314-
315- token .attrSet ("alt" , self .renderInlineAsText (token .children , options , env ))
308+ if token .children :
309+ token .attrSet ("alt" , self .renderInlineAsText (token .children , options , env ))
310+ else :
311+ token .attrSet ("alt" , "" )
316312
317313 return self .renderToken (tokens , idx , options , env )
318314
0 commit comments