jekyll syntax highlighter not working

2019-06-08 17:17发布

I'm using jekyll and Github Pages to build my website. And I followed all the instructions on http://jekyllrb.com/docs/templates/#code-snippet-highlighting, however, the syntax highlighter within my post won't render. Below is the code:

{% highlight ruby %}
def print_hi(name)
  puts "Hi, #{name}"
end
print_hi('Tom')
#=> prints 'Hi, Tom' to STDOUT.
{% endhighlight %}

And I think the markdown file doesn't render properly, either. Can anyone tell me where I did wrong? You can check the post here: https://amir0320.github.io/blog/welcome-to-jekyll/

2条回答
霸刀☆藐视天下
2楼-- · 2019-06-08 18:05

try this in markdown file.

```ruby
YOUR CODE
```

if you can see <code> in output html source, but still highlight not working, that is css problem.

查看更多
老娘就宠你
3楼-- · 2019-06-08 18:10

This is happening because you are have a stale file called main.css inside the css folder of your Jekyll project, which is replacing the file generated by Jekyll from the SASS file.

i.e. Jekyll builds the css\main.scss and creates a file _site\css\main.css, but then it sees the file css\main.css and copies it to _site\css\main.css, replacing the initial file that was generated via SASS.

Solution: Delete this file css\main.css.

查看更多
登录 后发表回答