1

I'm trying to generate a highlighting theme for my site created with pandoc framework.

I followed this guide : guide

I create my theme this way:

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

and then I add it to my command like this:

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

The problem is that when I go to fill it out, I get this error back, and the code doesn't get colored:

Could not read highlighting theme my_style.theme

What's the problem?

EDIT: i try adding this:

--highlight-style=breezedark

but my code doesn't get colored in html view.. i try this:

```bash
java -version
```

~~~bash
java -version
~~~

This is the source code of 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>
Difettoso
  • 51
  • 1
  • 1
  • 10
  • 1
    Everything written above seems correct, assuming that `my_style.theme` is really in the directory from which you run pandoc. The most likely explanation is that a syntax error was introduced into the style while editing. Please check for that, e.g. by running `jq` or similar tools. – tarleb Aug 05 '20 at 13:46
  • 1
    Regarding your edit: call pandoc with `--standalone` (or `-s`) to get highlighting – tarleb Aug 05 '20 at 13:47
  • I don't see any color in the html file output – Difettoso Aug 05 '20 at 13:52

2 Answers2

1

The reason is the encoding of file. By default, the theme file output by pandoc is UTF-16 LE (seen from vscode). Saving the file with encoding UTF-8 will help.

Simon Yang
  • 21
  • 2
  • Good answer, just one comment: it's not pandoc that's creating UTF-16 output, but the Windows shell. The following does not pipe the output through the shell, so the file `my-theme.json` will be UTF-8 encoded: `pandoc -o my-theme.json --print-highlight-style=breezedark` – tarleb Mar 30 '22 at 12:45
0

I encountered the same problem. I wrote color names in the theme file such as chartreuse and crimson. This was the reason of the failure: one has to enter the hex codes of the colors.

Stéphane Laurent
  • 75,186
  • 15
  • 119
  • 225