Skip to main content

parse_markdown_attachments

Function parse_markdown_attachments 

Source
pub fn parse_markdown_attachments(markdown: &str) -> Vec<MarkdownAttachment>
Expand description

Extract attachments embedded in a markdown string.

Recognizes both image syntax (![alt](url)) and link syntax ([text](url)). The result is deduplicated by URL and returned in the order the references appear in the source. Inputs without any markdown links produce an empty vector.

This helper is used by providers like GitLab and GitHub that embed attachments directly into issue / MR bodies and comments rather than exposing a dedicated attachments API.

No filtering is applied — every [text](url) and ![alt](url) reference is returned, including plain web links. Callers that only want downloadable files should filter by scheme, host, or file extension as appropriate for their provider. The extracted filename is derived from the markdown alt text / link text when available and falls back to the final path segment of the URL.