Last active
February 14, 2025 13:48
-
-
Save deanebarker/64aace9d2fe21d88f86df98a20bd22ba to your computer and use it in GitHub Desktop.
How to iterate and manipulate a parsed Markdig document
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var markdown = @" | |
| This is some text. | |
| This is a [link](http://deanebarker.net/) | |
| "; | |
| var builder = new MarkdownPipelineBuilder(); | |
| var pipeline = builder.Build(); | |
| var document = Markdown.Parse(markdown, pipeline); | |
| // Iterate the links in the doc; you can change the parsed doc here... | |
| foreach (LinkInline link in document.Descendants<LinkInline>()) | |
| { | |
| // If they're not using SSL, fix it... | |
| if(link.Url.Contains("deanebarker.net") && link.Url.StartsWith("http://")) | |
| { | |
| link.Url = link.Url.Replace("http://", "https://"); | |
| } | |
| } | |
| var result = document.ToHtml(pipeline); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment