xoofx / markdig

A fast, powerful, CommonMark compliant, extensible Markdown processor for .NET
BSD 2-Clause "Simplified" License
4.21k stars 444 forks source link

Question: Having code blocks show in blocks #771

Closed Pave87 closed 5 months ago

Pave87 commented 5 months ago

So when working with markdown file in VS Studio or Code preview shows code blocks (~~~ and ```) as a block. But for all I have tried with MarkDig to export this file to html it just very slightly different font and gets lost in other text.

CommonMark.org in their examples shows code block as a fenced block similar to how VS studio and Code show in their previews.

xoofx commented 5 months ago

So when working with markdown file in VS Studio or Code preview shows code blocks (~~~ and ```) as a block.

Please post the exact problem you are encountering with a proof of work/not work on https://babelmark.github.io/

Pave87 commented 5 months ago

When I enter sample from my file there is prints out as expected.

But file that I get when running in my C# project prints out code differently. Code:

var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build();
var result = Markdown.ToHtml(File.ReadAllText("doc.md"), pipeline);
File.WriteAllText("doc.html", result.ToString());

image

xoofx commented 5 months ago

I'm going to update the markdig on babelmark as the version is a bit old and will double check your case.

xoofx commented 5 months ago

The markdown you posted above:

You can also use Scanner specific defaults.
~~~
<AddMissingValues >
    <Customer>SampleCustomer</Customer>
    <Product>SampleProduct</Product>
</AddMissingValues>
~~~

Outputs the following with Markdig:

<p>You can also use Scanner specific defaults.</p>
<pre><code>&lt;AddMissingValues &gt;
    &lt;Customer&gt;SampleCustomer&lt;/Customer&gt;
    &lt;Product&gt;SampleProduct&lt;/Product&gt;
&lt;/AddMissingValues&gt;
</code></pre>

Which is correct, so I'm not sure what are you expecting, but I don't think there ia an issue with Markdig here.