({ href, title, text, tokens }: Tokens.Image)
| 173 | } |
| 174 | |
| 175 | image({ href, title, text, tokens }: Tokens.Image): RendererOutput { |
| 176 | if (tokens) { |
| 177 | text = this.parser.parseInline(tokens, this.parser.textRenderer) as string; |
| 178 | } |
| 179 | const cleanHref = cleanUrl(href); |
| 180 | if (cleanHref === null) { |
| 181 | return escapeHtmlEntities(text) as RendererOutput; |
| 182 | } |
| 183 | href = cleanHref; |
| 184 | |
| 185 | let out = `<img src="${href}" alt="${escapeHtmlEntities(text)}"`; |
| 186 | if (title) { |
| 187 | out += ` title="${escapeHtmlEntities(title)}"`; |
| 188 | } |
| 189 | out += '>'; |
| 190 | return out as RendererOutput; |
| 191 | } |
| 192 | |
| 193 | text(token: Tokens.Text | Tokens.Escape): RendererOutput { |
| 194 | return 'tokens' in token && token.tokens |
no test coverage detected