Sha256: c6fb847b8489321b36bf55e6aba0300cf60fda4dec0043099deccb57fa4cdab9

Contents?: true

Size: 691 Bytes

Versions: 16

Compression:

Stored size: 691 Bytes

Contents

class Blogit::Parsers::MarkdownParser
  
  require "nokogiri"
  require "albino"
  require "blogit/renderers"
  
  def initialize(content)
    @content = content
  end

  def parsed
    renderer = Blogit::configuration.highlight_code_syntax ?  Redcarpet::Render::HTMLWithAlbino : Redcarpet::Render::HTML
    markdown = Redcarpet::Markdown.new(renderer, Blogit.configuration.redcarpet_options)
    html_content = markdown.render(@content).html_safe
  end

  private

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

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
blogit-0.7.0 lib/blogit/parsers/markdown_parser.rb
blogit-0.6.0 lib/blogit/parsers/markdown_parser.rb
blogit-0.5.1 lib/blogit/parsers/markdown_parser.rb
blogit-0.5.0 lib/blogit/parsers/markdown_parser.rb
blogit-0.4.8 lib/blogit/parsers/markdown_parser.rb
blogit-0.4.7 lib/blogit/parsers/markdown_parser.rb
blogit-0.4.6 lib/blogit/parsers/markdown_parser.rb
blogit-0.4.5 lib/blogit/parsers/markdown_parser.rb
blogit-0.4.4 lib/blogit/parsers/markdown_parser.rb
blogit-0.4.3 lib/blogit/parsers/markdown_parser.rb
blogit-0.4.2 lib/blogit/parsers/markdown_parser.rb
blogit-0.4.1 lib/blogit/parsers/markdown_parser.rb
blogit-0.4.0 lib/blogit/parsers/markdown_parser.rb
blogit-0.3.2 lib/blogit/parsers/markdown_parser.rb
blogit-0.3.1 lib/blogit/parsers/markdown_parser.rb
blogit-0.3.0 lib/blogit/parsers/markdown_parser.rb