美文网首页
Jekyll markdown 设置语法高亮

Jekyll markdown 设置语法高亮

作者: 偷油考拉 | 来源:发表于2021-09-10 10:20 被阅读0次

    Jekyll 默认的 markdown 引擎是kramdown。Rouge提供markdown的语法高亮功能。

    Syntax highlighting with Jekyll – McPride's thougths

    安装 rouge

    gem install kramdown rouge
    

    配置_config.yml如下:

    markdown: kramdown
    highlighter: rouge
    
    kramdown:
      input: GFM
      syntax_highlighter: rouge
    

    rouge创建css文件到对应的theme目录

    root@VM-0-8-freebsd:/usr/local/www/myblog # bundle info --path minima
    /usr/local/lib/ruby/gems/2.7/gems/minima-2.5.1
    root@VM-0-8-freebsd:/usr/local/www/myblog # cd /usr/local/lib/ruby/gems/2.7/gems/minima-2.5.1
    root@VM-0-8-freebsd:/usr/local/lib/ruby/gems/2.7/gems/minima-2.5.1 # ls
    LICENSE.txt README.md   _includes   _layouts    _sass       assets
    
    
    root@VM-0-8-freebsd:/usr/local/lib/ruby/gems/2.7/gems/minima-2.5.1 # mkdir -p assets/css/
    root@VM-0-8-freebsd:/usr/local/lib/ruby/gems/2.7/gems/minima-2.5.1 # rougify style github > assets/css/syntax.css
    root@VM-0-8-freebsd:/usr/local/lib/ruby/gems/2.7/gems/minima-2.5.1 # ls assets/css/
    syntax.css
    
    

    个人测试了下, thankful_eyes style 看起来蛮舒服

    修改_includes/head.html , 引用rouge创建的css文件。添加如下

    <head>
        ...
      <link rel="stylesheet" href="/assets/css/syntax.css" />
    </head>
    

    相关文章

      网友评论

          本文标题:Jekyll markdown 设置语法高亮

          本文链接:https://www.haomeiwen.com/subject/vtbbrltx.html