mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-11 05:44:45 +00:00
How to get ALT text of image? #197
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ckome on GitHub (Mar 4, 2018).
hi all~
I'v use this code get images node list
var links = md.Descendants<ParagraphBlock>().SelectMany(x => x.Inline.Descendants<LinkInline>()).ToList(); foreach (var node in links) { if (node.IsImage) { Debug.WriteLine(node.Url); } }and how to get the alt text?
@xoofx commented on GitHub (Apr 4, 2018):
Unfortunately, there is no easy way to get the real alt text, as it is actually given by the potential multiple children rendered without the HTML tags.
7620b2b760/src/Markdig/Renderers/Html/Inlines/LinkInlineRenderer.cs (L30-L40)You can come with a hack to fetch this by using similar code (or if you expect a single
LiteralInlineas a child)