Sha256: 15b17238128631e67ce5190e33bfc7e5a3dc304507cdb3e4e36c2e4d3e9f1d86

Contents?: true

Size: 889 Bytes

Versions: 5

Compression:

Stored size: 889 Bytes

Contents

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

require 'kramdown/parser/html'

module Kramdown
  module Parser
    class Kramdown

      # Parse the HTML entity at the current location.
      def parse_html_entity
        @src.pos += @src.matched_size
        begin
          @tree.children << Element.new(:entity, ::Kramdown::Utils::Entities.entity(@src[1] || (@src[2] && @src[2].to_i) || @src[3].hex),
                                        nil, :original => @src.matched)
        rescue ::Kramdown::Error
          @tree.children << Element.new(:entity, ::Kramdown::Utils::Entities.entity('amp'))
          add_text(@src.matched[1..-1])
        end
      end
      define_parser(:html_entity, Kramdown::Parser::Html::Constants::HTML_ENTITY_RE, '&')

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
kramdown-1.2.0 lib/kramdown/parser/kramdown/html_entity.rb
kramdown-1.1.0 lib/kramdown/parser/kramdown/html_entity.rb
kramdown-1.0.2 lib/kramdown/parser/kramdown/html_entity.rb
kramdown-1.0.1 lib/kramdown/parser/kramdown/html_entity.rb
kramdown-1.0.0 lib/kramdown/parser/kramdown/html_entity.rb