Open rprouse opened 10 years ago
+1 I need this too. I now need to send it through Pandoc to get my Markdown to HTML conversion.
+1 here, too. Yes, this would be very useful.
+1
Is this not covered by this:
https://github.com/toptensoftware/markdowndeep/commit/4faf39fe06f49571d20dce65a5c08d8a874f6a0d
@toptensoftware I don't think it is covered. It looks like that commit covers the single backtick around inline code like this code
. I don't think it covers the code blocks which start with three backticks and optionally a language identifier ```C# on a line and then ended by three backticks.
I think it is covered, at least in the C# version, because you can hook the FormatCodeBlock
extension point to handle the language identifier.
No it's not covered as the FormatCodeBlock only get the actual code and not any language specifier.
// Callback to format a code block (ie: apply syntax highlighting)
// string FormatCodeBlock(code)
// Code = code block content (ie: the code to format)
// Return the formatted code, including <pre> and <code> tags
public Func<Markdown, string, string> FormatCodeBlock;
I've solved it by using a pre processor which runs before MarkdownDeep get's the source code: https://github.com/jgauffin/markdownweb/blob/master/src/MarkdownWeb/PreFilters/GithubCodeBlocks.cs
It would have helped if t least the position in the complete text block had been specified, as then you could manually found the backticks and the language specifier.
@jgauffin Thanks for sharing your solution!
I implemented this in my fork of MarkdownDeep which is part of DocNet (https://github.com/FransBouma/DocNet/tree/master/src/MarkdownDeep) server side only.
Markdowndeep and Github support indented blocks as
<pre>
or code blocks. Github also has the Syntax Highlighting format.MarkdownDeep doesn't need to do the syntax highlighting, but it should at least treat it like a code block.