module MdInc::Commands

Public Instance Methods

highlight(path, language) click to toggle source

Public: Jekyll command to include code that should be highlighted from a file.

path - Path to the file to be included. language - Language identifier

Examples

.highlight 'snippets/stub-spec.rb', 'ruby'
# =>
# {% highlight ruby %}
# contents of snippets/stub-spec.rb
# {% endhighlight %}

Returns the Jekyll tag as a String Array.

# File lib/md_inc/jekyll_commands.rb, line 29
def highlight(path, language)
  jekyll_tag(:highlight, [language], inc(path))
end
jekyll_tag(name, attrs=[], lines=[]) click to toggle source
# File lib/md_inc/jekyll_commands.rb, line 4
def jekyll_tag(name, attrs=[], lines=[])
  output = []
  output << "{% #{([name] + attrs).join(" ")} %}"
  unless lines.empty?
    output += lines
    output << "{% end#{name} %}"
  end
  output
end