Class: DocRepo::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/doc_repo/page.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Page

Returns a new instance of Page.



7
8
9
# File 'lib/doc_repo/page.rb', line 7

def initialize(file)
  @body = GithubFile.new(default_ext(file)).read_remote_file
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



5
6
7
# File 'lib/doc_repo/page.rb', line 5

def body
  @body
end

Instance Method Details

#default_ext(file) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/doc_repo/page.rb', line 11

def default_ext(file)
  if File.extname(file).empty?
    "#{file}.md"
  else
    file
  end
end

#to_htmlObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/doc_repo/page.rb', line 19

def to_html
  Converters::MarkdownParser.new(
    extensions: %i[
      no_intra_emphasis
      tables
      fenced_code_blocks
      autolink
      strikethrough
      lax_spacing
      superscript
      with_toc_data
    ]
  ).convert(body)
end