jekyll syntax highlighter not working

时间秒杀一切 提交于 2019-12-08 12:15:51

问题


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/


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/38233170/jekyll-syntax-highlighter-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!