summaryrefslogtreecommitdiff
path: root/lib/banzai/suggestions_parser.rb
blob: 09f3663502094813b6133560de2b3748e7107d5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# frozen_string_literal: true

module Banzai
  module SuggestionsParser
    # Returns the content of each suggestion code block.
    #
    def self.parse(text)
      html = Banzai.render(text, project: nil, no_original_data: true)
      doc = Nokogiri::HTML(html)

      doc.search('pre.suggestion').map { |node| node.text }
    end
  end
end