Sha256: 94ae963a3eeda2166da61a1ce26dafb042a9e17cc84cb5b09fc66fe4500db24d

Contents?: true

Size: 597 Bytes

Versions: 12

Compression:

Stored size: 597 Bytes

Contents

class Blogit::Parsers::MarkdownParser

  def initialize(content)
    @content = content
  end

  def parsed
    html_content = Redcarpet.new(@content, *Blogit.configuration.redcarpet_options).to_html
    if Blogit::configuration.highlight_code_syntax
      syntax_highlighter(html_content)
    else
      html_content
    end
  end



  require "nokogiri"
  require "albino"

  private

  def syntax_highlighter(html)
    doc = Nokogiri::HTML(html)
    doc.search("//pre[@lang]").each do |pre|
      pre.replace Albino.colorize(pre.text.rstrip, pre[:lang])
    end
    doc.inner_html
  end  

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
blogit-0.2.1 lib/blogit/parsers/markdown_parser.rb
blogit-0.2.0 lib/blogit/parsers/markdown_parser.rb
blogit-0.1.0 lib/blogit/parsers/markdown_parser.rb
blogit-0.0.13 lib/blogit/parsers/markdown_parser.rb
blogit-0.0.12 lib/blogit/parsers/markdown_parser.rb
blogit-0.0.11 lib/blogit/parsers/markdown_parser.rb
blogit-0.0.10 lib/blogit/parsers/markdown_parser.rb
blogit-0.0.9 lib/blogit/parsers/markdown_parser.rb
blogit-0.0.8 lib/blogit/parsers/markdown_parser.rb
blogit-0.0.7 lib/blogit/parsers/markdown_parser.rb
blogit-0.0.6 lib/blogit/parsers/markdown_parser.rb
blogit-0.0.5 lib/blogit/parsers/markdown_parser.rb