Module: Metanorma::Plugin::Lutaml::Liquid::CustomFilters

Includes:
Content
Defined in:
lib/metanorma/plugin/lutaml/liquid/custom_filters/values.rb,
lib/metanorma/plugin/lutaml/liquid/custom_filters/loadfile.rb,
lib/metanorma/plugin/lutaml/liquid/custom_filters/html2adoc.rb,
lib/metanorma/plugin/lutaml/liquid/custom_filters/file_exist.rb,
lib/metanorma/plugin/lutaml/liquid/custom_filters/replace_regex.rb

Instance Method Summary collapse

Instance Method Details

#file_exist(path) ⇒ Object



6
7
8
# File 'lib/metanorma/plugin/lutaml/liquid/custom_filters/file_exist.rb', line 6

def file_exist(path)
  File.exist?(path)
end

#html2adoc(input) ⇒ Object



8
9
10
11
# File 'lib/metanorma/plugin/lutaml/liquid/custom_filters/html2adoc.rb', line 8

def html2adoc(input)
  # Coradoc::ReverseAdoc.convert(input)
  Coradoc::Input::Html.convert(input)
end

#identify(input) ⇒ Object



18
19
20
# File 'lib/metanorma/plugin/lutaml/liquid/custom_filters/html2adoc.rb', line 18

def identify(input)
  input.split(/(?=[A-Z])/).map(&:downcase).join("-")
end

#interpolate(input) ⇒ Object



13
14
15
16
# File 'lib/metanorma/plugin/lutaml/liquid/custom_filters/html2adoc.rb', line 13

def interpolate(input)
  sub = ::Liquid::Template.parse(input)
  sub.render(@context)
end

#loadfile(path, parent_folder = ".") ⇒ Object



10
11
12
13
# File 'lib/metanorma/plugin/lutaml/liquid/custom_filters/loadfile.rb', line 10

def loadfile(path, parent_folder = ".")
  resolved_file_path = File.expand_path(path, parent_folder)
  load_content_from_file(resolved_file_path)
end

#replace_regex(text, regex_search, replace_value) ⇒ Object



6
7
8
9
# File 'lib/metanorma/plugin/lutaml/liquid/custom_filters/replace_regex.rb', line 6

def replace_regex(text, regex_search, replace_value)
  regex = /#{regex_search}/
  text.to_s.gsub(regex, replace_value)
end

#values(list) ⇒ Object



6
7
8
# File 'lib/metanorma/plugin/lutaml/liquid/custom_filters/values.rb', line 6

def values(list)
  list.values
end