Special kludge for image `alt` attributes to conform CommonMark spec. Don't try to use it! Spec requires to show `alt` content with stripped markup, instead of simple escaping. :param tokens: list on block tokens to render :param options: params of parser instance
(
self,
tokens: Sequence[Token] | None,
options: OptionsDict,
env: EnvType,
)
| 180 | return result |
| 181 | |
| 182 | def renderInlineAsText( |
| 183 | self, |
| 184 | tokens: Sequence[Token] | None, |
| 185 | options: OptionsDict, |
| 186 | env: EnvType, |
| 187 | ) -> str: |
| 188 | """Special kludge for image `alt` attributes to conform CommonMark spec. |
| 189 | |
| 190 | Don't try to use it! Spec requires to show `alt` content with stripped markup, |
| 191 | instead of simple escaping. |
| 192 | |
| 193 | :param tokens: list on block tokens to render |
| 194 | :param options: params of parser instance |
| 195 | :param env: additional data from parsed input |
| 196 | """ |
| 197 | result = "" |
| 198 | |
| 199 | for token in tokens or []: |
| 200 | if token.type == "text": |
| 201 | result += token.content |
| 202 | elif token.type == "image": |
| 203 | if token.children: |
| 204 | result += self.renderInlineAsText(token.children, options, env) |
| 205 | elif token.type == "softbreak": |
| 206 | result += "\n" |
| 207 | |
| 208 | return result |
| 209 | |
| 210 | ################################################### |
| 211 |