MCPcopy
hub / github.com/markedjs/marked / image

Method image

src/Renderer.ts:175–191  ·  view source on GitHub ↗
({ href, title, text, tokens }: Tokens.Image)

Source from the content-addressed store, hash-verified

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

Callers 2

ExtendedRendererClass · 0.45
parseInlineMethod · 0.45

Calls 3

cleanUrlFunction · 0.90
escapeHtmlEntitiesFunction · 0.90
parseInlineMethod · 0.80

Tested by

no test coverage detected