lib/utils/xml.rb in metanorma-utils-1.10.0 vs lib/utils/xml.rb in metanorma-utils-1.10.1

- old
+ new

@@ -97,18 +97,18 @@ doc = ::Nokogiri::XML.parse(NOKOHEAD) doc.fragment(xml) end def ns(xpath) - xpath.gsub(%r{/([a-zA-z])}, "/xmlns:\\1") - .gsub(%r{::([a-zA-z])}, "::xmlns:\\1") - .gsub(%r{\[([a-zA-z][a-z0-9A-Z@/-]* ?=)}, "[xmlns:\\1") - .gsub(%r{\[([a-zA-z][a-z0-9A-Z@/-]*[/\[\]])}, "[xmlns:\\1") + xpath.gsub(%r{/([a-zA-Z])}, "/xmlns:\\1") + .gsub(%r{::([a-zA-Z])}, "::xmlns:\\1") + .gsub(%r{\[([a-zA-Z][a-z0-9A-Z@/-]* ?=)}, "[xmlns:\\1") + .gsub(%r{\[([a-zA-Z][a-z0-9A-Z@/-]*[/\[\]])}, "[xmlns:\\1") end def numeric_escapes(xml) c = HTMLEntities.new - xml.split(/(&[^ \r\n\t#;]+;)/).map do |t| + xml.split(/(&[^ \r\n\t#&;]+;)/).map do |t| if /^(&[^ \t\r\n#;]+;)/.match?(t) c.encode(c.decode(t), :hexadecimal) else t end end.join