Sha256: 432f74928fb30ed89a7c280e9bf39a3302049265b0968b69e297b0c034b6204c

Contents?: true

Size: 1.06 KB

Versions: 15

Compression:

Stored size: 1.06 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.
#++
#

require 'kramdown/parser/html'

module Kramdown
  module Parser
    class Kramdown

      # Parse the HTML entity at the current location.
      def parse_html_entity
        start_line_number = @src.current_line_number
        @src.pos += @src.matched_size
        begin
          value = ::Kramdown::Utils::Entities.entity(@src[1] || (@src[2]&.to_i) || @src[3].hex)
          @tree.children << Element.new(:entity, value,
                                        nil, original: @src.matched, location: start_line_number)
        rescue ::Kramdown::Error
          @tree.children << Element.new(:entity, ::Kramdown::Utils::Entities.entity('amp'),
                                        nil, location: start_line_number)
          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

15 entries across 15 versions & 4 rubygems

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