Class: Murdoc::FormattedParagraph
- Inherits:
-
Object
- Object
- Murdoc::FormattedParagraph
- Extended by:
- Forwardable
- Defined in:
- lib/murdoc/formatted_paragraph.rb
Instance Attribute Summary collapse
-
#highlight ⇒ Object
readonly
Returns the value of attribute highlight.
-
#paragraph ⇒ Object
readonly
Returns the value of attribute paragraph.
Instance Method Summary collapse
- #formatted_annotation ⇒ Object
- #formatted_source ⇒ Object
-
#initialize(paragraph, highlight = true) ⇒ FormattedParagraph
constructor
A new instance of FormattedParagraph.
Constructor Details
#initialize(paragraph, highlight = true) ⇒ FormattedParagraph
Returns a new instance of FormattedParagraph.
11 12 13 14 |
# File 'lib/murdoc/formatted_paragraph.rb', line 11 def initialize(paragraph, highlight = true) @paragraph = paragraph @highlight = highlight end |
Instance Attribute Details
#highlight ⇒ Object (readonly)
Returns the value of attribute highlight.
9 10 11 |
# File 'lib/murdoc/formatted_paragraph.rb', line 9 def highlight @highlight end |
#paragraph ⇒ Object (readonly)
Returns the value of attribute paragraph.
8 9 10 |
# File 'lib/murdoc/formatted_paragraph.rb', line 8 def paragraph @paragraph end |
Instance Method Details
#formatted_annotation ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/murdoc/formatted_paragraph.rb', line 16 def formatted_annotation if defined?(Markdown) Markdown.new(annotation, :smart).to_html else Kramdown::Document.new(annotation, :input => :markdown).to_html end end |
#formatted_source ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/murdoc/formatted_paragraph.rb', line 24 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 |