Method: MarkdownLint::Doc#initialize
- Defined in:
- lib/mdl/doc.rb
#initialize(text, ignore_front_matter = false) ⇒ Doc
Create a new document given a string containing the markdown source
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/mdl/doc.rb', line 36 def initialize(text, ignore_front_matter = false) regex = /^---\n(.*?)---\n/m if ignore_front_matter and regex.match(text) @offset = regex.match(text).to_s.split("\n").length text.sub!(regex,'') else @offset = 0 end @lines = text.split("\n") @parsed = Kramdown::Document.new(text, :input => 'MarkdownLint') @elements = @parsed.root.children add_levels(@elements) end |