Sha256: bcc16a682ebd4c877bb1d9b20125e9ee0e649e94d3a740c84b379c4e5dec7428
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
require 'forwardable' module Murdoc class FormattedParagraph extend Forwardable def_delegators :paragraph, :annotation, :source, :starting_line, :source_type, :metadata 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.1 | lib/murdoc/formatted_paragraph.rb |