Module: JekyllAeo::Utils::HtmlConverter
- Defined in:
- lib/jekyll-aeo/utils/html_converter.rb
Constant Summary collapse
- STRIP_ELEMENTS =
%w[script style nav header footer].freeze
Class Method Summary collapse
Class Method Details
.convert(html, config = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/jekyll-aeo/utils/html_converter.rb', line 11 def self.convert(html, config = {}) return "" if html.nil? || html.strip.empty? doc = Nokogiri::HTML(html) content_node = extract_content(doc, config) return "" unless content_node STRIP_ELEMENTS.each { |tag| content_node.css(tag).each(&:remove) } promote_code_languages(content_node) ReverseMarkdown.convert(content_node.inner_html, unknown_tags: :bypass, github_flavored: true).strip end |