class AocCli::Tools::Convert

Attributes

input[RW]

Public Instance Methods

array() click to toggle source
# File lib/aoc_cli/tools.rb, line 46
def array
        input.split("\n")
end
chunk(f:, t:, t_off:0, f_off:0) click to toggle source
# File lib/aoc_cli/tools.rb, line 49
def chunk(f:, t:, t_off:0, f_off:0)
        pt1 = array.index {|l| l =~ /#{f}/} + t_off
        pt2 = array.rindex{|l| l =~ /#{t}/} + f_off
        @input = array.slice(pt1, pt2 - pt1).join("\n")
        self
end
md() click to toggle source
# File lib/aoc_cli/tools.rb, line 61
def md
        PandocRuby.new(input, {f: html, t: :gfm}, 
           md_head, md_ref).convert
end
plain() click to toggle source
# File lib/aoc_cli/tools.rb, line 58
def plain
        PandocRuby.new(input, f: html, t: :plain).convert
end
raw() click to toggle source
# File lib/aoc_cli/tools.rb, line 55
def raw
        input.split("\n").join("\n")
end

Private Instance Methods

html() click to toggle source
# File lib/aoc_cli/tools.rb, line 66
def html
        "html-native_divs-native_spans"
end
md_head() click to toggle source
# File lib/aoc_cli/tools.rb, line 69
def md_head
        "--markdown-headings=setext"
end
md_ref() click to toggle source
# File lib/aoc_cli/tools.rb, line 72
def md_ref
        "--reference-links"
end