Pandoc:荧光笔的可用语法是什么?

use*_*119 37 syntax-highlighting pandoc

http://pandoc.org/demos.html#examples的子弹点18 显示了如何通过给出参数来更改使用的语法高亮显示器--highlight-style.例如:

pandoc code.text -s --highlight-style pygments -o example18a.html
pandoc code.text -s --highlight-style kate -o example18b.html
pandoc code.text -s --highlight-style monochrome -o example18c.html
pandoc code.text -s --highlight-style espresso -o example18d.html
pandoc code.text -s --highlight-style haddock -o example18e.html
pandoc code.text -s --highlight-style tango -o example18f.html
pandoc code.text -s --highlight-style zenburn -o example18g.html
Run Code Online (Sandbox Code Playgroud)

我想知道这些是否是唯一可用的配色方案.如果没有,我如何加载不同的语法荧光笔?我可以定义自己的吗?

Kur*_*fle 22

如果您pandoc --version指示1.15.1(2015年10月15日)或更新版本,则可以检查该--bash-completion参数是否适用于您获取可用内置突出显示样式的完整列表.

pandoc --bash-completion
Run Code Online (Sandbox Code Playgroud)

如果它有效,你会看到很多输出.它将超出上面的原始问题而有用......

如果--bash-completion有效,那么将此行放在${HOME}/.bashrc文件的末尾(在Mac OS X或Linux上 - 在Windows上不起作用):

eval "$(pandoc --bash-completion)"
Run Code Online (Sandbox Code Playgroud)

打开新终端后,可以使用pandoc带有"tab completion"的命令:

pandoc --h[tab]
Run Code Online (Sandbox Code Playgroud)

会屈服

--help     --highlight-style  --html-q-tags

pandoc --hi[tab]
Run Code Online (Sandbox Code Playgroud)

会屈服

pandoc --highlight-style
Run Code Online (Sandbox Code Playgroud)

回答原始问题:

现在[tab]再次按下键,你会看到

espresso   haddock   kate   monochrome  pygments    tango    zenburn
Run Code Online (Sandbox Code Playgroud)

它是所有可用语法荧光笔的列表.要缩短预期,您也可以输入

pandoc --hi[tab][tab]
Run Code Online (Sandbox Code Playgroud)

得到相同的结果.

Pandoc标签完成超出原始问题的有用性:

Pandoc的bash选项卡完成也适用于所有其他命令行开关:

pandoc -h[tab]
Run Code Online (Sandbox Code Playgroud)

得到这个 - 所有可能的命令行参数的列表:

Display all 108 possibilities? (y or n)
--ascii                    --indented-code-classes    --template
--asciimathml              --jsmath                   --title-prefix
--atx-headers              --katex                    --to
--base-header-level        --katex-stylesheet         --toc
--bash-completion          --latex-engine             --toc-depth
--biblatex                 --latex-engine-opt         --trace
--bibliography             --latexmathml              --track-changes
--chapters                 --listings                 --variable
--citation-abbreviations   --mathjax                  --verbose
--columns                  --mathml                   --version
--csl                      --metadata                 --webtex
--css                      --mimetex                  --wrap
--data-dir                 --natbib                   --write
--default-image-extension  --no-highlight             -A
--dpi                      --no-tex-ligatures         -B
--dump-args                --no-wrap                  -D
--email-obfuscation        --normalize                -F
--epub-chapter-level       --number-offset            -H
--epub-cover-image         --number-sections          -M
--epub-embed-font          --old-dashes               -N
--epub-metadata            --output                   -R
--epub-stylesheet          --parse-raw                -S
--extract-media            --preserve-tabs            -T
--file-scope               --print-default-data-file  -V
--filter                   --print-default-template   -c
--from                     --read                     -f
--gladtex                  --reference-docx           -h
--help                     --reference-links          -i
--highlight-style          --reference-odt            -m
--html-q-tags              --section-divs             -o
--id-prefix                --self-contained           -p
--ignore-args              --slide-level              -r
--include-after-body       --smart                    -s
--include-before-body      --standalone               -t
--include-in-header        --tab-stop                 -v
--incremental              --table-of-contents        -w
Run Code Online (Sandbox Code Playgroud)

Pandoc选项卡完成的一个有趣用例是:

pandoc --print-default-d[tab][tab]
Run Code Online (Sandbox Code Playgroud)

给出完成的输出列表pandoc --print-default-data-file.通过此列表,您可以深入了解Pandoc实例在执行其工作时将加载哪些数据文件.例如,您可以调查Pandoc的默认ODT(OpenDocument文本文件)输出样式的详细信息,如下所示:

pandoc --print-default-data-file odt/content.xml \
 | tr " " "\n" \
 | tr "<" "\n" \
 | grep --color "style"
Run Code Online (Sandbox Code Playgroud)


mb2*_*b21 18

Pandoc自述说:

--highlight-style=STYLE|FILE

指定要在突出显示的源代码中使用的着色样式.选项pygments(默认), ,kate,monochrome, breezeDark,espresso,zenburn,haddocktango.有关pandoc中语法突出显示的更多信息,请参阅 下面的语法突出显示.另见 --list-highlight-styles.

可以提供具有扩展名的JSON文件,而不是STYLE名称 .theme.这将被解析为KDE语法高亮主题和(如果有效)用作突出显示样式.要查看可以修改的示例主题,pandoc --print-default-data-file default.theme.

天窗(在旧版本中突出显示-kate)用于突出显示.如果您不喜欢任何提供的配色方案,您可以:

  • 指定.theme上面提到的文件,
  • 导出为HTML时,<span>会生成可以使用自定义CSS设置样式的标记,或者
  • 导出到LaTeX/PDF时,您需要使用自定义Pandoc LaTeX 模板$highlighting-macros$使用自定义颜色定义替换该部件,如本期中所述.


Clé*_*ent 18

pandoc 2.0.5开始,您还可以使用--print-highlight-style输出theme文件并对其进行编辑.

对我来说,使用此选项的最佳方法是

  1. 选择一个愉快的风格

  2. 输出其theme文件

  3. 编辑theme文件

  4. 用它!

1.可用样式

选择你已经存在的风格:

breezedark

单色

凯特

zenburn

浓咖啡

黑线鳕

探戈舞

2.输出其theme文件

一旦确定哪种样式最接近您的需要,您可以theme使用(例如pygments,默认样式)输出其文件:

pandoc --print-highlight-style pygments
Run Code Online (Sandbox Code Playgroud)

以便您可以将此样式存储在文件中,例如,

pandoc --print-highlight-style pygments > my_style.theme
Run Code Online (Sandbox Code Playgroud)

3.编辑文件

使用Skylighting JSON主题指南,根据您的需要/品味编辑文件.

4.使用该文件

在右侧文件夹中,只需使用

pandoc my_file.md --highlight-style my_style.theme -o doc.html
Run Code Online (Sandbox Code Playgroud)

  • 这是天赐之物.我一直在找这样的东西.谢谢! (2认同)

Kur*_*fle 12

如果您使用的是Pandoc 1.18版(2016年10月发布)或更高版本,则可以获得新的答案:

  pandoc --list-highlight-languages
Run Code Online (Sandbox Code Playgroud)

  pandoc --list-highlight-styles
Run Code Online (Sandbox Code Playgroud)

将为您提供您要求的所有信息.

添加到v1.18的其他新信息命令行参数是:

  pandoc --list-input-formats
  pandoc --list-output-formats
  pandoc --list-extensions
Run Code Online (Sandbox Code Playgroud)