2

I used Github Pages to host my personal website and I am trying to create a post which contains code snippets with line numbers.

When I do a jekyll serve on my machine, locally I can see everything working as expected, viz.,

enter image description here

However, when I push it to my Github repo and try to view the site live, the line numbering breaks. I see the following

enter image description here

enter image description here

I am using code fences to specify the code, like so,

~```python"
import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt
import seaborn as sns
sns
.set_style("darkgrid")
~```

I have also tried the liquid syntax {% highlight python linenos %} . . . {% endhighlight %} but the problem persists.

My _config.yml has the following settings

# Conversion
markdown: kramdown
highlighter: rouge
lsi: false
excerpt_separator: "\n\n"
incremental: false


# Markdown Processing
kramdown:
  input: GFM
  hard_wrap: false
  auto_ids: true
  footnote_nr: 1
  entity_output: as_char
  toc_levels: 1..6
  smart_quotes: lsquo,rsquo,ldquo,rdquo
  enable_coderay: false
  syntax_highlighter_opts:
    block:
      line_numbers: true
# HTML Compression
# - http://jch.penibelst.de/
compress_html:
  clippings: all
  ignore:
    envs: development

and the css/scss file can be found here.

I can't understand the reason behind this discrepancy and how can I solve it?

Edit: I tried commenting out the HTML compression portion in _config.yml and I can then see the same error locally.

noir1993
  • 153
  • 5
  • Have you tried disabling HTML compression (the `compress_html` setting)? It can mess up things like that. Your production HTML nests `` tags incorrectly somehow. – Benjamin W. Oct 26 '22 at 13:52
  • You are probably right: I commented out the relevant portion and saw that locally I get the same incorrect result. I am not sure how to change it. I am adding it to the question. – noir1993 Oct 26 '22 at 14:53
  • @BenjaminW. I set `envs: [development, production]`, and apparently fixed the issue. I am unsure it that is breaking anything else atm. – noir1993 Oct 26 '22 at 15:06
  • I believe if you drop the entire `compress_html` object, it won't be compressed anywhere. – Benjamin W. Oct 26 '22 at 15:23

0 Answers0