Sha256: 157f8728fc44087313127a6479361a46d95ddea5e1a114ee424e20b52a152ff3

Contents?: true

Size: 1.85 KB

Versions: 17

Compression:

Stored size: 1.85 KB

Contents

# -*- coding: utf-8; frozen_string_literal: true -*-
#
#--
# Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
#
# This file is part of kramdown which is licensed under the MIT.
#++
#

module Kramdown
  module Parser
    class Kramdown

      TYPOGRAPHIC_SYMS = [['---', :mdash], ['--', :ndash], ['...', :hellip],
                          ['\\<<', '&lt;&lt;'], ['\\>>', '&gt;&gt;'],
                          ['<< ', :laquo_space], [' >>', :raquo_space],
                          ['<<', :laquo], ['>>', :raquo]]
      TYPOGRAPHIC_SYMS_SUBST = Hash[*TYPOGRAPHIC_SYMS.flatten]
      TYPOGRAPHIC_SYMS_RE = /#{TYPOGRAPHIC_SYMS.map {|k, _v| Regexp.escape(k) }.join('|')}/

      # Parse the typographic symbols at the current location.
      def parse_typographic_syms
        start_line_number = @src.current_line_number
        @src.pos += @src.matched_size
        val = TYPOGRAPHIC_SYMS_SUBST[@src.matched]
        if val.kind_of?(Symbol)
          @tree.children << Element.new(:typographic_sym, val, nil, location: start_line_number)
        elsif @src.matched == '\\<<'
          @tree.children << Element.new(:entity, ::Kramdown::Utils::Entities.entity('lt'),
                                        nil, location: start_line_number)
          @tree.children << Element.new(:entity, ::Kramdown::Utils::Entities.entity('lt'),
                                        nil, location: start_line_number)
        else
          @tree.children << Element.new(:entity, ::Kramdown::Utils::Entities.entity('gt'),
                                        nil, location: start_line_number)
          @tree.children << Element.new(:entity, ::Kramdown::Utils::Entities.entity('gt'),
                                        nil, location: start_line_number)
        end
      end
      define_parser(:typographic_syms, TYPOGRAPHIC_SYMS_RE, '--|\\.\\.\\.|(?:\\\\| )?(?:<<|>>)')

    end
  end
end

Version data entries

17 entries across 17 versions & 4 rubygems

Version Path
kramdown-2.5.1 lib/kramdown/parser/kramdown/typographic_symbol.rb
kramdown-2.5.0 lib/kramdown/parser/kramdown/typographic_symbol.rb
getargv-0.3.3-universal-darwin vendor/bundle/ruby/3.3.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/typographic_symbol.rb
kramdown-2.4.0 lib/kramdown/parser/kramdown/typographic_symbol.rb
kramdown-2.3.2 lib/kramdown/parser/kramdown/typographic_symbol.rb
kramdown-2.3.1 lib/kramdown/parser/kramdown/typographic_symbol.rb
daqing_kramdown-2.3.2 lib/kramdown/parser/kramdown/typographic_symbol.rb
daqing_kramdown-2.3.1 lib/kramdown/parser/kramdown/typographic_symbol.rb
zine_brewer-1.5.0 vendor/bundle/ruby/2.7.0/gems/kramdown-2.3.0/lib/kramdown/parser/kramdown/typographic_symbol.rb
zine_brewer-1.3.0 vendor/bundle/ruby/2.7.0/gems/kramdown-2.3.0/lib/kramdown/parser/kramdown/typographic_symbol.rb
kramdown-2.3.0 lib/kramdown/parser/kramdown/typographic_symbol.rb
kramdown-2.2.1 lib/kramdown/parser/kramdown/typographic_symbol.rb
kramdown-2.2.0 lib/kramdown/parser/kramdown/typographic_symbol.rb
kramdown-2.1.0 lib/kramdown/parser/kramdown/typographic_symbol.rb
kramdown-2.0.0 lib/kramdown/parser/kramdown/typographic_symbol.rb
kramdown-2.0.0.beta2 lib/kramdown/parser/kramdown/typographic_symbol.rb
kramdown-2.0.0.beta1 lib/kramdown/parser/kramdown/typographic_symbol.rb