Pandoc:将markdown转换为HTML,语法突出显示 [英] Pandoc: Converting markdown to HTML, syntax highlighter

查看:463
本文介绍了Pandoc:将markdown转换为HTML,语法突出显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将markdown转换为HTML,并且我希望包含语法突出显示的代码.

I'm converting markdown to HTML, and I want to include syntax-highlighted code.

我正在使用某些降价促销,其中包含如下语法:

I'm working from some markdown that contains syntax like:

  ~~~ {.c}
  long factorial (int n)
  {
    long result = 1;
    while (n > 1)
      result *= n--;
    return result;
  }
  ~~~

但是我不知道使用哪个语法突出显示扩展名来处理此语法.什么是好的扩展名?

but I don't know which syntax highlighting extension was used to process this syntax. What's a good extension?

推荐答案

评论有误,请在给予负面评价之前进行编辑.

Answer from comments, please edit before giving negative rating.

解决方案

Pandoc会自动突出显示语法.您不需要外部扩展程序.

Solution

Pandoc does syntax highlighting automatically. You don't need an external extension.

只需确保使用-s标志,即可获得带有突出显示所需CSS的斯坦达拉HTML文件.您也可以使用--highlight-style选项调整配色方案.

Just be sure to use the -s flag so you get a standalane HTML file with the CSS needed for highlighting. You can also use the --highlight-style option to adjust the coloring scheme.

注意:这些注释假设您使用的是最新的pandoc, 1.9.4.2.

当我添加-s选项时,出现以下错误消息:pandoc -m -t -s slidy 7-functional-design.md -o 7-functional-design.hpart.如果尝试改为添加--highlight-style=haddock,则会收到相同的错误消息.

When I add the -s option, I get this error message: pandoc -m -t -s slidy 7-functional-design.md -o 7-functional-design.hpart. I get the same error message if I try adding --highlight-style=haddock instead.

您要使用-s -t slidy而不是-t -s slidy.

slidy是-t选项的参数,需要紧随其后.

slidy is the argument for the -t option and needs to come right after it.

这篇关于Pandoc:将markdown转换为HTML,语法突出显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆