Code highlighting with line numbers
Jekyll 3 and 4 produce invalid HTML from highlighted code with line numbers. Validation of the produced HTML may report:
Error: Element
table
not allowed as child of elementcode
[…]
-
Turn off HTML compression with the following setting in
_config.yml
:compress_html: ignore: envs: all
-
Check that HTML validation reports no errors on this page.
-
Remove the setting for HTML compression, to get the default compression provided by the theme.
-
Check that HTML validation now reports an error that refers to the second example below. The error may also produce incorrect formatting.
The examples below are from a Jekyll docs page.
The first example uses the workaround explained in the theme docs:
1
2
3
def foo
puts 'foo'
end
The second example doesn’t use the workaround:
>
1
2
3
def foo
puts 'foo'
end