Highlighting tag incompatible with ISO-8859-1 encoding?

I’m generating an HTML file from my Jekyll site that I’m rendering into an e-book for Kindle. The format of the HTML file needs to be in ISO-8859-1 rather than UTF-8 (which is the default)

According to the Encoding entry in the Jekyll Configurations documentation, I should be able to add this to my config file:

encoding: ISO-8859-1

And then the resulting HTML file will be ISO-8859-1 instead of UTF-8.

However, when I do this, I get this error:

Liquid Exception: Bad encoding: ISO-8859-1,ISO8859-1. Please convert your string to UTF-8. in /Users/tomjoht/projects/idratherbewriting/_restapicourse/docapis_answers.md

I looked at the problematic page. It turns out the highlight tag is the problem. When I converted all of these highlight tags to 3 backticks, I no longer got the error, and the file correctly rendered as ISO-8859-1.

I have two questions:

  • Why is the highlight tag problematic with ISO-8859-1 encoding?
  • If I have an HTML page and want to inject syntax highlighting, how can I do this without using the highlight tag? Can I add <pre class="json"> or something to the code block to have syntax highlighting inserted when Jekyll builds the site?

will need to investigate…

have you tried using bacticks?:

``` json
{
 }
```

Backticks are always my first approach, but when the content is inside HTML tags or is on an HTML page, I usually use the highlight tags. What would you do to highlight a code sample on an HTML page without backticks or highlight tags?

Prism.js might be an option if you don’t mind a small JavaScript dependency.

http://prismjs.com/

Thanks for the tip! I’ll check it out.