For Nokogiri 1.4.0 compatibility
11711
def make_node(html, doc)
		result = Nokogiri::XML::Node.new('div', doc)
		result.inner_html = html
		return result.children[0]
	end
680996
def with_workaround_for_notextile(body)
      code_blocks = []

      body.gsub!(%r{<(#{JaxGuides.code_aliases})>(.*?)</\1>}m) do |m|
        brush = case $1
#          when 'ruby', 'sql', 'plain'
#            $1
          when 'erb'
            'ruby; html-script: true'
          when 'html'
            'xml' # html is understood, but there are .xml rules in the CSS
          when 'yaml', 'shell'
            'plain'
          else
            $1
            #'plain'
        end

        code_blocks.push(<<HTML)
<notextile>
<div class="code_container">
<pre class="brush: #{brush}; gutter: false; toolbar: false">
#{ERB::Util.h($2).strip}
</pre>
</div>
</notextile>
HTML
        "\ndirty_workaround_for_notextile_#{code_blocks.size - 1}\n"
      end

      body = yield body

      body.gsub(%r{<p>dirty_workaround_for_notextile_(\d+)</p>}) do |_|
        code_blocks[$1.to_i]
      end
    end
1190097
def parse_element(ele)
      if ele.is_a? Nokogiri::XML::Text
        return "#{ele.text}\n"
      else
        if (children = ele.children).count > 0
          return wrap_node(ele,children.map {|ele| parse_element(ele)}.join )
        else
          return wrap_node(ele,ele.text)
        end
      end
    end
610836
function normVersion(tag) {
    var parts = new semver.SemVer(tag);
    var prerelease = "";

    if (parts.prerelease && parts.prerelease.length > 0) {
        prerelease = hashPrerelease(parts.prerelease);
    }

    return [
        parts.major,
        parts.minor,
        parts.patch
    ].join('.') + (prerelease? '.'+prerelease : '');
}
428234
def parse_symbol attr_name, xpath
      v = parse_value xpath
      v = v.to_sym unless v.nil?
      send("#{attr_name}=", v)
    end
1275321
def proppatch(path, xml_snippet)
      path = @uri.merge(path).path
      headers = {'Depth' => '1'}
      body =  '<?xml version="1.0"?>' +
      '<d:propertyupdate xmlns:d="DAV:">' +
         xml_snippet +
      '</d:propertyupdate>'
      res = @handler.request(:proppatch, path, body, headers.merge(@headers))
      Nokogiri::XML.parse(res.body)
    end
484275
def to_hash
      doc = ::Nokogiri::XML( self.response )
      hash = {}
      doc.at_css("Response").element_children.each do |attribute|
        hash[attribute.name.underscore.to_sym] = attribute.inner_text
      end
      hash[:valid] = doc.at_css("Response")['valid']
      hash
    end
365620
def handle_xhtml_file(file_path)
      html_doc = Nokogiri::XML(File.open(file_path))

      add_file_to_head(:js, html_doc, 'vendor/bower/jquery/jquery.min.js')
      add_file_to_head(:js, html_doc, 'vendor/bower/spin/spin.js')
      add_file_to_head(:js, html_doc, 'vendor/bower/cookies/cookies.min.js')
      add_file_to_head(:js, html_doc, 'vendor/bower/uri/URI.min.js')
      add_file_to_head(:js, html_doc, 'vendor/bower/keymaster/keymaster.js')
      add_file_to_head(:style, html_doc, 'book_content.styl')

      add_file_to_head(:js, html_doc, 'support.coffee')
      add_meta_to_head(:viewport, 'width=device-width, initial-scale=1.0', html_doc)
      add_auto_refresh_script(html_doc)

      unless file_resolver.nil?
        current_index = file_resolver.spine_files.index { |file| file.final_destination_path == file_path }

        unless current_index.nil?
          previous_path = spine_file_at(current_index - 1).try(:pkg_destination_path)
          next_path     = spine_file_at(current_index + 1).try(:pkg_destination_path)
          add_keyboard_control_script(html_doc, previous_path, next_path)
        end
      end

      [200, html_doc.to_xhtml]
    end
1212493
def to_xml(options = {})
      doc = Nokogiri::XML::Document.new
      root = doc.create_element(tag_name)
      self.class.keys.each do |name|
        value = read_attribute(name)
        next if value.blank?
        root[name.to_s.camelize] = value
      end
      self.class.elements.each do |name, field|
        next if options[:only] && !options[:only].include?(name)
        next if field.options[:readonly]
        value = read_attribute(name)
        next if field.type.is_a?(Array) && value.blank?
        next if new_record? && field.type == Identifier
        next if new_record? && value.blank?
        if name == :text
          root << value.to_s
        else
          root << field.to_xml(value)
        end
      end
      root
    end
145455
def imode_browser_version
      case @request.env['HTTP_USER_AGENT']
      when %r{^DoCoMo/1.0/}
        ver = '1.0'
      when %r{^DoCoMo/2.0 }
        @request.env['HTTP_USER_AGENT'] =~ / (\w+)\(c(\d+);/
        model = Regexp.last_match(1)
        cache_size = Regexp.last_match(2).to_i

        ver = if cache_size >= 500
                (%w[P03B P05B L01B].member?(model) ? '2.0LE' : '2.0')
              else
                '1.0'
              end
      else
        # DoCoMo/3.0以降等は、とりあえず非v1.0扱い
        ver = '2.0'
      end

      ver
    end
859261
def xpathRegisterNs(self, prefix, ns_uri):
        
        ret = libxml2mod.xmlXPathRegisterNs(self._o, prefix, ns_uri)
        return ret
802181
def wrap_with type, content, options = {} #:nodoc:
      type_tag, type_html_options = apply_html type, options
      if type_tag
        @template.content_tag type_tag, content, type_html_options
      else
        content
      end
    end
199615
def document
      if !@document
        @document = Nokogiri::HTML(self.class.request_sncf(number, date))
        if !itinerary_available?
          @document = Nokogiri::HTML(self.class.request_sncf_itinerary(0))
        end
      end
      if @document.at('#no_results')
        fail TrainNotFound, @document.at('#no_results b').inner_html
      end
      @document
    end
36247
def register_html_tag(tag_name, type = :inline, **options)
      tag = HTMLTag.new(tag_name, type, **options)
      @permitted_html_tags[tag.name] = tag
    end
729430
def parse(string)
      if string.blank?
        {}
      else
        doc = Nokogiri::XML(string)
        raise doc.errors.first if doc.errors.length > 0
        doc.to_hash
      end
    end
1222440
def html_factory(tag, **defaults):
    '''

    '''
    def html_input(*children, **params):
        p = defaults.copy()
        p.update(params)
        return Html(tag, *children, **p)
    return html_input
259083
def to_xml
      db = @local_db || @db || return
      Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
        xml.documents do
          xml.parent.add_child db.all.join(" ")
        end
      end.to_xml
    end