Sha256: 8fdf95cd713c1c25a6b939eb33d1fdfa613109c01a7d056ba35373d49f5534ea

Contents?: true

Size: 1.09 KB

Versions: 18

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

module Kramdown
  module Parser
    class SmartyPants < Kramdown::Parser::Kramdown
      def initialize(source, options)
        super
        @block_parsers = [:block_html, :content]
        @span_parsers =  [:smart_quotes, :html_entity, :typographic_syms, :span_html]
      end

      def parse_content
        add_text @src.scan(%r!\A.*\n!)
      end
      define_parser(:content, %r!\A!)
    end
  end
end

module Bridgetown
  module Utils
    class SmartyPantsConverter
      # @param config [Bridgetown::Configuration]
      def initialize(config)
        @config = config["kramdown"].dup || {}
        @config[:input] = :SmartyPants
      end

      # @param content [String]
      # @return String
      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
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
bridgetown-core-2.0.0.beta4 lib/bridgetown-core/utils/smarty_pants_converter.rb
bridgetown-core-2.0.0.beta3 lib/bridgetown-core/utils/smarty_pants_converter.rb
bridgetown-core-2.0.0.beta2 lib/bridgetown-core/utils/smarty_pants_converter.rb
bridgetown-core-2.0.0.beta1 lib/bridgetown-core/utils/smarty_pants_converter.rb
bridgetown-core-1.3.4 lib/bridgetown-core/utils/smarty_pants_converter.rb
bridgetown-core-1.3.3 lib/bridgetown-core/utils/smarty_pants_converter.rb
bridgetown-core-1.3.2 lib/bridgetown-core/utils/smarty_pants_converter.rb
bridgetown-core-1.3.1 lib/bridgetown-core/utils/smarty_pants_converter.rb
bridgetown-core-1.3.0 lib/bridgetown-core/utils/smarty_pants_converter.rb
bridgetown-core-1.3.0.beta3 lib/bridgetown-core/utils/smarty_pants_converter.rb
bridgetown-core-1.3.0.beta2 lib/bridgetown-core/utils/smarty_pants_converter.rb
bridgetown-core-1.3.0.beta1 lib/bridgetown-core/utils/smarty_pants_converter.rb
bridgetown-core-1.2.0 lib/bridgetown-core/utils/smarty_pants_converter.rb
bridgetown-core-1.2.0.beta5 lib/bridgetown-core/utils/smarty_pants_converter.rb
bridgetown-core-1.2.0.beta4 lib/bridgetown-core/utils/smarty_pants_converter.rb
bridgetown-core-1.2.0.beta3 lib/bridgetown-core/utils/smarty_pants_converter.rb
bridgetown-core-1.2.0.beta2 lib/bridgetown-core/utils/smarty_pants_converter.rb
bridgetown-core-1.2.0.beta1 lib/bridgetown-core/utils/smarty_pants_converter.rb