Quantcast
Channel: Add proper syntax name to code blocks when converting from HTML to Markdown with Pandoc - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Add proper syntax name to code blocks when converting from HTML to Markdown with Pandoc

$
0
0

I need to convert some HTML to Markdown with Pandoc. All is fine except the code blocks in my document are not converted properly. I need them to appear in the resulting Markdown document as backtick-code blocks with syntax definition.

For example, if I have such source HTML:

<pre class="python"><code>    def myfunc(param):'''Description of myfunc'''        return do_something(param)</code></pre>

I want Pandoc to convert it into:

```python    def myfunc(param):'''Description of myfunc'''        return do_something(param)```

But what I am getting is:

``` {.python}    def myfunc(param):'''Description of myfunc'''        return do_something(param)```

It's almost there, but the syntax definition is in curly braces and with a dot, which is not recognised by my Markdown parser. How can I get ```python instead of ``` {.python} when converting HTML to Markdown?

I have control over the source HTML, so I can change it the way needed. If there's an option to insert "raw markdown" into the HTML which will be ignored by Pandoc, that would work for me too, I can embed those blocks into the source HTML the way I need, but I need to tell Pandoc not to touch them. But I can't find such option in the docs.


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images