Sha256: 8a762cc3a4500f85957074b66eb952192d8358233f1d2d1de8d87770ae05967c

Contents?: true

Size: 1.83 KB

Versions: 15

Compression:

Stored size: 1.83 KB

Contents

# -*- coding: utf-8 -*-
#
#--
# Copyright (C) 2009-2015 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

15 entries across 14 versions & 6 rubygems

Version Path
able-neo4j-1.0.0 vendor/bundle/jruby/1.9/gems/kramdown-1.8.0/lib/kramdown/parser/kramdown/typographic_symbol.rb
kramdown-1.10.0 lib/kramdown/parser/kramdown/typographic_symbol.rb
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/kramdown-1.8.0/lib/kramdown/parser/kramdown/typographic_symbol.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/kramdown-1.8.0/lib/kramdown/parser/kramdown/typographic_symbol.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/kramdown-1.8.0/lib/kramdown/parser/kramdown/typographic_symbol.rb
logstash-input-beats-2.0.2 vendor/jruby/1.9/gems/kramdown-1.9.0/lib/kramdown/parser/kramdown/typographic_symbol.rb
logstash-input-beats-2.0.2 vendor/jruby/1.9/gems/logstash-codec-json-2.0.3/vendor/gems/kramdown-1.9.0/lib/kramdown/parser/kramdown/typographic_symbol.rb
logstash-codec-json-2.0.3 vendor/gems/kramdown-1.9.0/lib/kramdown/parser/kramdown/typographic_symbol.rb
logstash-input-beats-0.9.2 vendor/jruby/1.9/gems/kramdown-1.9.0/lib/kramdown/parser/kramdown/typographic_symbol.rb
logstash-input-beats-0.9.1 vendor/jruby/1.9/gems/kramdown-1.9.0/lib/kramdown/parser/kramdown/typographic_symbol.rb
kramdown-1.9.0 lib/kramdown/parser/kramdown/typographic_symbol.rb
kramdown-1.8.0 lib/kramdown/parser/kramdown/typographic_symbol.rb
kramdown-1.7.0 lib/kramdown/parser/kramdown/typographic_symbol.rb
motion-kramdown-0.6.0 lib/kramdown/parser/kramdown/typographic_symbol.rb
kramdown-1.6.0 lib/kramdown/parser/kramdown/typographic_symbol.rb