Sha256: cb13e6004ce2853876c1d6e68dcbec91d9e5afca200411ec15c938db4fe974a9
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
require 'forwardable' module Murdoc class FormattedParagraph extend Forwardable def_delegators :paragraph, :annotation, :source, :starting_line, :source_type attr_reader :paragraph attr_reader :highlight def initialize(paragraph, highlight = true) @paragraph = paragraph @highlight = highlight end def formatted_annotation if defined?(Markdown) Markdown.new(annotation, :smart).to_html else Kramdown::Document.new(annotation, :input => :markdown).to_html end end def formatted_source @formatted_source ||= if pygments_installed? && highlight && source_type != :base IO.popen("pygmentize -l #{source_type} -O encoding=UTF8 -f html -O nowrap", "w+") do |pipe| pipe.puts source pipe.close_write pipe.read end else CGI.escapeHTML(source) end end protected def pygments_installed? @@pygments_installed ||= ENV['PATH'].split(':').any? { |dir| File.exist?("#{dir}/pygmentize") } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
murdoc-0.2.0 | lib/murdoc/formatted_paragraph.rb |