Sha256: 2f730e7aacaf0f41aa3163db1a078b70a97c52dd364022212c3411ac44f27f57

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

require 'nori/parser/nokogiri'

# В текущей реализации парсер пропускает пробелы между
# представленными в виде xml character entities non-ASCII словами,
# считая их мусором:
# <ns0:ASSIGNEDGROUP>&#x414;&#x435;&#x436;&#x443;&#x440;&#x43D;&#x430;&#x44F; &#x441;&#x43C;&#x435;&#x43D;&#x430; &#x41B;&#x41F;1.5</ns0:ASSIGNEDGROUP>
# Ожидается: "ns0:ASSIGNEDGROUP"=>"Дежурная смена ЛП1.5"
# Имеется в nori-2.4.0: "ns0:ASSIGNEDGROUP"=>"ДежурнаясменаЛП1.5"
class Nori::Parser::Nokogiri::Document

  def characters(string)
    last = stack.last
    if last and last.children.last.is_a?(String) or string.strip.size > 0
      last.add_node(string)
    end
  end
  alias cdata_block characters

  def end_element(name)
    if stack.size > 1
      last = stack.pop
      maybe_string = last.children.last
      if maybe_string.is_a?(String) and maybe_string.strip.empty?
        last.children.pop
      end
      stack.last.add_node last
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tehportal-0.1.3 lib/nori_patch.rb
tehportal-0.1.0 lib/nori_patch.rb