IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    octopress notebox plugin

    studentdeng (studentdeng@hotmail.com)发表于 2014-04-04 16:48:00
    love 0

    用了这么长时间的octopress总该扩展一点点事情了,在Blogging的时候,总有一些信息是需要被特殊标记的,但是我并不喜欢简单的加粗或是斜体。类似的东西在Apple Document中有很多

    Apple Document Note sample

    这里我就把这个功能照搬到octopress中了。

    1.在plugins目录创建一个notebox.rb

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    
    module Jekyll
      class Notebox < Liquid::Block
    
        def initialize(name, id, tokens)
          super
          @id = id
        end
    
        def render(context)
          stressText = paragraphize(super)
    
          source = "

    Note:

    #{stressText}
    " source end def paragraphize(input) "#{input.lstrip.rstrip.gsub(/\n\n/, '

    '

    ).gsub(/\n/, '
    '
    )}"
    end end end Liquid::Template.register_tag('notebox', Jekyll::Notebox)

    2.在sass/custom中的文件_stype.scss的最后添加下面的代码

    1
    2
    3
    4
    5
    6
    7
    8
    9
    
    .notebox {
      border:1px;
      border-style: solid;
      border-color: #5088C5;
      background-color:#fff;
      margin:.75em 0 1.5em;
      padding:.75em .667em .75em .750em;
      text-align:left;
    }
    

    3.markdown的语法(因为格式问题写成了%,需要替换成%)

    {% notebox %}
    the text to note
    {% endnotebox %}
    

    效果

    Note: text



沪ICP备19023445号-2号
友情链接