Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update html5.rb forwarding params syntax #3329

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 26 additions & 29 deletions lib/nokogiri/html5.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# coding: utf-8
# frozen_string_literal: true

# This file includes code from the Nokogumbo project, whose license follows.
#
# Copyright 2013-2021 Sam Ruby, Stephen Checkoway
# Copyright 2013-2021 Sam Ruby, Stephen Checkoway
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require_relative "html5/document"
Expand All @@ -23,30 +24,27 @@
require_relative "html5/builder"

module Nokogiri
# Since v1.12.0
#
# ⚠ HTML5 functionality is not available when running JRuby.
#
# Parse an HTML5 document. Convenience method for {Nokogiri::HTML5::Document.parse}
def self.HTML5(input, url = nil, encoding = nil, **options, &block)
Nokogiri::HTML5::Document.parse(input, url, encoding, **options, &block)
# Convenience method for Nokogiri::HTML5::Document.parse
def self.HTML5(...)
Nokogiri::HTML5::Document.parse(...)
end

# == Usage
#
# ⚠ HTML5 functionality is not available when running JRuby.
#
# Parse an HTML5 document:
#
# doc = Nokogiri.HTML5(string)
# doc = Nokogiri.HTML5(input)
#
# Parse an HTML5 fragment:
#
# fragment = Nokogiri::HTML5.fragment(string)
# fragment = Nokogiri::HTML5.fragment(input)
#
# ⚠ HTML5 functionality is not available when running JRuby.
#
# == Parsing options
#
# The document and fragment parsing methods support options that are different from Nokogiri's.
# The document and fragment parsing methods support options that are different from
# Nokogiri::HTML4::Document or Nokogiri::XML::Document.
#
# - <tt>Nokogiri.HTML5(html, url = nil, encoding = nil, **options)</tt>
# - <tt>Nokogiri::HTML5.parse(html, url = nil, encoding = nil, **options)</tt>
Expand Down Expand Up @@ -267,15 +265,14 @@ def self.HTML5(input, url = nil, encoding = nil, **options, &block)
# Since v1.12.0
module HTML5
class << self
# Parse an HTML 5 document. Convenience method for Nokogiri::HTML5::Document.parse
def parse(string, url = nil, encoding = nil, **options, &block)
Document.parse(string, url, encoding, **options, &block)
# Convenience method for Nokogiri::HTML5::Document.parse
def parse(...)
Document.parse(...)
end

# Parse a fragment from +string+. Convenience method for
# Nokogiri::HTML5::DocumentFragment.parse.
def fragment(string, encoding = nil, **options)
DocumentFragment.parse(string, encoding, **options)
# Convenience method for Nokogiri::HTML5::DocumentFragment.parse
def fragment(...)
DocumentFragment.parse(...)
end

# :nodoc:
Expand Down