mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-12 05:44:48 +00:00
how to extract first image url from markdown #164
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 @joeaudette on GitHub (Nov 20, 2017).
Sorry if this is a stupid question. I am trying to extract the first image url found in a markdown string and have been struggling to do it with regex. I wonder is there an easy way to do it with Markdig?
@xoofx commented on GitHub (Nov 20, 2017):
Yeah, sorry for the lack of documentation, hopefully it will come next year. In the meantime, you can achieve what you are looking for by walking the document AST:
@joeaudette commented on GitHub (Nov 20, 2017):
@xoofx thanks for the speedy response! That looks like it would get the first link, but how can I make sure I am getting the first image url not just the first link? I guess I can just check the file extension of the url but was hoping there might be a specific way to get images. I can work with that though so thanks!
@joeaudette commented on GitHub (Nov 20, 2017):
doh!, it does show how to get images, just needed to scroll your answer. Thanks again!