I'm trying to convert a string with markdown formatting into an html
text = """
# To be approved
This is a markdown editor, Type here your article body and use the tools or markdown code to style it.
If you need help or you want to know more about markdown, click on the **light bulb** icon in the bottom left of this form.
You can preview your `article ` by clicking on the icons in the bottom right of this form.
**Click here to begin writing**
\```js
var UID = loadUID();
if (UID != false){
var create_article_btn = window.parent.document.getElementById('create_article_btn');
create_article_btn.style.display = 'block';
}
\```
"""
text = pypandoc.convert_text(text,'html',format='md')
text = text.replace('"',"'")
text = text.replace('\n','')
It all works fine except for code blocks and inline codes which are displayed oddly:

the htmlgenerated by pypandoc is:
To be approved
Please
, begin
your
article with a title like this:
This is a markdown editor, Type here your article body and use the tools or markdown code to style it. If you need help or you want to know more about markdown, click on the
light bulb
icon in the bottom left of this form. You can preview your
article
by clicking on the icons in the bottom right of this form.
Click here to begin writing
;
class="cf">if
(UID != false)
{
var create_article_btn
= window.
parent.document
.getElementById(
class="st">'create_article_btn'
);
style.display
= 'block';
Is there something I'm missing in the pypandoc conversion? How do I stylise the code block with syntax highlight and proper indentation?
Judging by the presence of classes such as source code etc. it seems that there should be a style associated to that.
本文讨论了使用pypandoc将Markdown格式转换为HTML时遇到的问题,特别是代码块显示不正常的情况,并寻求解决方法来实现语法高亮和正确的缩进。
2078

被折叠的 条评论
为什么被折叠?



