Class: PREParser
Instance Attribute Summary collapse
-
#isForJekyll ⇒ Object
Returns the value of attribute isForJekyll.
-
#nextParser ⇒ Object
Returns the value of attribute nextParser.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(isForJekyll) ⇒ PREParser
constructor
A new instance of PREParser.
- #parse(paragraph) ⇒ Object
Methods inherited from Parser
Constructor Details
#initialize(isForJekyll) ⇒ PREParser
Returns a new instance of PREParser.
9 10 11 |
# File 'lib/Parsers/PREParser.rb', line 9 def initialize(isForJekyll) @isForJekyll = isForJekyll end |
Instance Attribute Details
#isForJekyll ⇒ Object
Returns the value of attribute isForJekyll.
7 8 9 |
# File 'lib/Parsers/PREParser.rb', line 7 def isForJekyll @isForJekyll end |
#nextParser ⇒ Object
Returns the value of attribute nextParser.
7 8 9 |
# File 'lib/Parsers/PREParser.rb', line 7 def nextParser @nextParser end |
Class Method Details
.isPRE(paragraph) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/Parsers/PREParser.rb', line 13 def self.isPRE(paragraph) if paragraph.nil? false else paragraph.type == "PRE" end end |
Instance Method Details
#parse(paragraph) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/Parsers/PREParser.rb', line 21 def parse(paragraph) if PREParser.isPRE(paragraph) lang = "" if !paragraph.codeBlockMetadata.nil? lang = paragraph.codeBlockMetadata.lang end result = "```#{lang}\n" paragraph.text.each_line do |p| result += p end result = result.chomp result += "\n```" result else if !nextParser.nil? nextParser.parse(paragraph) end end end |