xoofx / markdig

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

Azure devops support #652

Open ProCoderMatt opened 1 year ago

ProCoderMatt commented 1 year ago

Hi! I saw this issue and wanted to mention it here. https://github.com/madskristensen/MarkdownEditor2022/issues/46

I'm writing my docs in visual studio and use the Azure DevOps wiki to read my docs. When I'm trying to create a mermaid diagram I use the ``` mermaid. But on the devops wiki it need to start with ::: mermaid. Can we support ::: for mermaid diagrams so we can see the diagram both in visual studio and Azure DevOps?

Thanks!

xoofx commented 1 year ago

Not sure how Azure DevOps is working for :::, but markdig supports Custom Containers :::. Might be enough?

ProCoderMatt commented 1 year ago

Thanks for your quick response.

I looked into the custom containers and I found that the below converts to html that throws an exception in mermaid.js

::: mermaid
  graph LR
:::

I think it's because the custom container adds <p> element for each line.

<div class="mermaid">
    <p id="pragma-line-2">graph LR</p>
</div>

We need to dump the text between the colons without any tags.

xoofx commented 1 year ago

Oh, right, so it's a fenced code block with a different escape.

There is nothing built-in. You will have to create an extension/modify the pipeline to e.g add the : to the OpeningCharacters of the existing FencedCodeBlockParser and modify the associated renderer to add mermaid here (Edit: And also, you should not enable the Custom Container extension to avoid the conflict)

ProCoderMatt commented 1 year ago

Hi xoofx,

Thanks for your answer!

When I have time I will create a PR :)