You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. Yesterday, I tested converting an MD file to HTML (html1 below). This worked fine. Then I decided to try parsing the markdown so I could make changes to it. Before spending a bunch of time on that (new to Markdig), I wanted to make sure that I could get it to output correctly (html2 below). This did not work. Below is the code I'm using. I would expect html1 and html2 to be identical, however, they are not.
string markdown = File.ReadAllText($@"{mdPath}\Documentation.md");
var document = Markdown.Parse(markdown);
var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build();
string html1 = Markdown.ToHtml(markdown, pipeline);
string html2 = document.ToHtml(pipeline);
If the Documentation.md file in the example above only contains "# General" (no quotes), html1 is <h1 id="general">General</h1> and html2 is <h1>General</h1>.
The ToHtml source formats are different (markdown vs MarkdownDocument), but both ultimately came from the same source markdown. And they run through the same pipeline, which I assume is where all the logic is. What am I missing? Why does one H1 have an ID but the other does not?
The text was updated successfully, but these errors were encountered:
I would have expected one of the pipeline "passes" to be redundant, but as you showed, that is how the code works. Suppose that would come into play if, like I'm trying, the document is changed after the initial parse.
At any rate, thank you for the quick and detailed response.
Hello. Yesterday, I tested converting an MD file to HTML (html1 below). This worked fine. Then I decided to try parsing the markdown so I could make changes to it. Before spending a bunch of time on that (new to Markdig), I wanted to make sure that I could get it to output correctly (html2 below). This did not work. Below is the code I'm using. I would expect html1 and html2 to be identical, however, they are not.
If the Documentation.md file in the example above only contains "# General" (no quotes), html1 is
<h1 id="general">General</h1>
and html2 is<h1>General</h1>
.The ToHtml source formats are different (markdown vs MarkdownDocument), but both ultimately came from the same source markdown. And they run through the same pipeline, which I assume is where all the logic is. What am I missing? Why does one H1 have an ID but the other does not?
The text was updated successfully, but these errors were encountered: