Class: Bridgetown::Utils::SmartyPantsConverter

Inherits:
Object
  • Object
show all
Defined in:
bridgetown-core/lib/bridgetown-core/utils/smarty_pants_converter.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ SmartyPantsConverter

Returns a new instance of SmartyPantsConverter.

Parameters:



24
25
26
27
# File 'bridgetown-core/lib/bridgetown-core/utils/smarty_pants_converter.rb', line 24

def initialize(config)
  @config = config["kramdown"].dup || {}
  @config[:input] = :SmartyPants
end

Instance Method Details

#convert(content) ⇒ Object

Returns String.

Parameters:

  • content (String)

Returns:

  • String



31
32
33
34
35
36
37
38
39
40
# File 'bridgetown-core/lib/bridgetown-core/utils/smarty_pants_converter.rb', line 31

def convert(content)
  document = Kramdown::Document.new(content, @config)
  html_output = document.to_html.chomp
  if @config["show_warnings"]
    document.warnings.each do |warning|
      Bridgetown.logger.warn "Kramdown warning:", warning.sub(%r!^Warning:\s+!, "")
    end
  end
  html_output
end