pandoc md html 菜单,python - pyPandoc md to html conversion lose code-block style - Stack Overflow

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:

SuD5e.png

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

var UID = loadUID()

;

class="cf">if

(UID != false)

{

var create_article_btn

= window.

parent.document

.getElementById(

class="st">'create_article_btn'

);

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值