module Rabbit::Parser::RD::Ext::CharacterReference
Constants
- TABLE
Public Class Methods
included(mod)
click to toggle source
# File lib/rabbit/parser/rd/ext/character-reference.rb, line 12 def included(mod) self.instance_methods.each do |meth| mod.method_added(meth) end end
Public Instance Methods
ext_inline_verb_character_entity_reference(label, source, content, visitor)
click to toggle source
# File lib/rabbit/parser/rd/ext/character-reference.rb, line 20 def ext_inline_verb_character_entity_reference(label, source, content, visitor) label = label.to_s return nil unless /^&([^;]+);(.*)$/ =~ label return nil unless TABLE.include?($1) key = $1 rest = $2 if rest.empty? Text.new(TABLE[key]) else rest = visitor.apply_to_Verb(::RD::Verb.new(rest)) TextContainer.new([Text.new(TABLE[key]), rest]) end end
ext_inline_verb_numeric_character_reference(label, source, content, visitor)
click to toggle source
# File lib/rabbit/parser/rd/ext/character-reference.rb, line 35 def ext_inline_verb_numeric_character_reference(label, source, content, visitor) label = label.to_s return nil unless /^&#(x?)([a-zA-Z\d]+);(.*)$/ =~ label base = $1 unicode_code_point_string = $2 rest = $3 if base == "x" unicode_code_point = unicode_code_point_string.to_i(16) else unicode_code_point = unicode_code_point_string.to_i(10) end character = [unicode_code_point].pack("U") if rest.empty? Text.new(character) else rest = visitor.apply_to_Verb(::RD::Verb.new(rest)) TextContainer.new([Text.new(character), rest]) end end