Class: Obsidian::ParsedMarkdownDocument

Inherits:
Object
  • Object
show all
Defined in:
lib/obsidian/parser/parsed_markdown_document.rb

Instance Method Summary collapse

Constructor Details

#initialize(document, renderer:) ⇒ ParsedMarkdownDocument

Returns a new instance of ParsedMarkdownDocument.



5
6
7
8
# File 'lib/obsidian/parser/parsed_markdown_document.rb', line 5

def initialize(document, renderer:)
  @document = document
  @renderer = renderer
end

Instance Method Details



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/obsidian/parser/parsed_markdown_document.rb', line 10

def extract_links
  results = []

  document.walk do |node|
    if node.type == :link
      text = _extract_text_content(node)
      href = node.url
      results << [href, text]
    end
  end

  results
end

#to_htmlObject



24
25
26
# File 'lib/obsidian/parser/parsed_markdown_document.rb', line 24

def to_html
  renderer.render(document)
end