【问题标题】:Pandoc highlighting themePandoc突出主题
【发布时间】:2020-08-05 11:49:15
【问题描述】:

我正在尝试为使用 pandoc 框架创建的网站生成突出显示主题。

我遵循了这个指南:guide

我以这种方式创建我的主题:

pandoc --print-highlight-style breezedark > my_style.theme 

然后我像这样将它添加到我的命令中:

pandoc ..\articles\$_ 
-f markdown 
-t html --template=..\template\article.html 
--defaults=..\defaults\params_$($_.BaseName).yaml 
--highlight-style my_style.theme <-------------------
--output ..\articles\$($_.BaseName).html 

问题是当我去填写时,我得到这个错误,并且代码没有被着色:

Could not read highlighting theme my_style.theme

有什么问题?

编辑: 我尝试添加这个:

--highlight-style=breezedark

但我的代码在 html 视图中没有着色.. 我试试这个:

```bash
java -version
```

~~~bash
java -version
~~~

这是html的源代码:

       <div class="sourceCode" id="cb2">
           <pre class="sourceCode bash">
               <code class="sourceCode bash">
                   <span id="cb2-1">
                       <a href="#cb2-1"></a>
                       <span class="ex">java</span> -version</span>
                    </code>
                </pre>
            </div>
       <div class="sourceCode" id="cb3">
           <pre class="sourceCode python">
               <code class="sourceCode python">
                   <span id="cb3-1">
                       <a href="#cb3-1"></a>
                       <span class="bu">print</span>(<span class="st">&quot;Hello, world!&quot;</span>)
                    </span>
                </code>
            </pre>
        </div>

【问题讨论】:

  • 上面写的一切似乎都是正确的,假设 my_style.theme 真的在你运行 pandoc 的目录中。最可能的解释是在编辑时向样式中引入了语法错误。请检查,例如通过运行jq 或类似工具。
  • 关于您的编辑:使用--standalone(或-s)调用pandoc以获得突出显示
  • 我在 html 文件输出中看不到任何颜色

标签: pandoc


【解决方案1】:

原因是文件的编码。默认情况下,pandoc 输出的主题文件是 UTF-16 LE(从 vscode 看)。使用编码 UTF-8 保存文件会有所帮助。

【讨论】:

  • 好答案,只有一条评论:创建 UTF-16 输出的不是 pandoc,而是 Windows shell。以下不通过 shell 管道输出,因此文件 my-theme.json 将被 UTF-8 编码:pandoc -o my-theme.json --print-highlight-style=breezedark
【解决方案2】:

我遇到了同样的问题。我在主题文件中写了颜色名称,例如chartreusecrimson。这就是失败的原因:必须输入颜色的十六进制代码。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-09
    • 1970-01-01
    相关资源
    最近更新 更多