Class: Commonmarker::Merge::Backend::Parser

Inherits:
TreeHaver::Base::Parser
  • Object
show all
Defined in:
lib/commonmarker/merge/backend.rb

Overview

Commonmarker parser wrapper

Instance Method Summary collapse

Instance Method Details

#parse(source) ⇒ Tree

Parse Markdown source code

Parameters:

  • source (String)

    Markdown source to parse

Returns:

  • (Tree)

    Parsed tree



118
119
120
121
122
123
124
125
# File 'lib/commonmarker/merge/backend.rb', line 118

def parse(source)
  raise "Language not set" unless language
  Backend.available? or raise "Commonmarker not available"

  opts = language.options || {}
  doc = ::Commonmarker.parse(source, options: opts)
  Tree.new(doc, source)
end