module Loofah
Strings and IO Objects as Input¶ ↑
The following methods accept any IO object in addition to accepting a string:
That IO object could be a file, or a socket, or a StringIO, or anything that responds to read
and close
.
Constants
- HTML
Alias for
Loofah::HTML4
- VERSION
The version of
Loofah
you are using
Public Class Methods
Shortcut for Loofah::HTML4::Document.parse(*args, &block)
This method accepts the same parameters as Nokogiri::HTML4::Document.parse
# File lib/loofah.rb, line 76 def html4_document(*args, &block) Loofah::HTML4::Document.parse(*args, &block) end
Shortcut for Loofah::HTML4::DocumentFragment.parse(*args, &block)
This method accepts the same parameters as Nokogiri::HTML4::DocumentFragment.parse
# File lib/loofah.rb, line 83 def html4_fragment(*args, &block) Loofah::HTML4::DocumentFragment.parse(*args, &block) end
Shortcut for Loofah::HTML5::Document.parse(*args, &block)
This method accepts the same parameters as Nokogiri::HTML5::Document.parse
# File lib/loofah.rb, line 101 def html5_document(*args, &block) Loofah::HTML5::Document.parse(*args, &block) end
Shortcut for Loofah::HTML5::DocumentFragment.parse(*args, &block)
This method accepts the same parameters as Nokogiri::HTML5::DocumentFragment.parse
# File lib/loofah.rb, line 108 def html5_fragment(*args, &block) Loofah::HTML5::DocumentFragment.parse(*args, &block) end
# File lib/loofah.rb, line 7 def html5_support? # Note that Loofah can only support HTML5 in Nokogiri >= 1.14.0 because it requires the # subclassing fix from https://github.com/sparklemotion/nokogiri/pull/2534 return @html5_support if defined? @html5_support @html5_support = Gem::Version.new(Nokogiri::VERSION) > Gem::Version.new("1.14.0") && Nokogiri.uses_gumbo? end
A helper to remove extraneous whitespace from text-ified HTML
# File lib/loofah.rb, line 169 def remove_extraneous_whitespace(string) string.gsub(/\n\s*\n\s*\n/, "\n\n") end
Shortcut for Loofah::HTML4::Document.parse(string_or_io).scrub!(method)
# File lib/loofah.rb, line 88 def scrub_html4_document(string_or_io, method) Loofah::HTML4::Document.parse(string_or_io).scrub!(method) end
Shortcut for Loofah::HTML4::DocumentFragment.parse(string_or_io).scrub!(method)
# File lib/loofah.rb, line 93 def scrub_html4_fragment(string_or_io, method) Loofah::HTML4::DocumentFragment.parse(string_or_io).scrub!(method) end
Shortcut for Loofah::HTML5::Document.parse(string_or_io).scrub!(method)
# File lib/loofah.rb, line 113 def scrub_html5_document(string_or_io, method) Loofah::HTML5::Document.parse(string_or_io).scrub!(method) end
Shortcut for Loofah::HTML5::DocumentFragment.parse(string_or_io).scrub!(method)
# File lib/loofah.rb, line 118 def scrub_html5_fragment(string_or_io, method) Loofah::HTML5::DocumentFragment.parse(string_or_io).scrub!(method) end
Shortcut for Loofah.xml_document(string_or_io)
.scrub!(method)
# File lib/loofah.rb, line 164 def scrub_xml_document(string_or_io, method) Loofah.xml_document(string_or_io).scrub!(method) end
Shortcut for Loofah.xml_fragment(string_or_io)
.scrub!(method)
# File lib/loofah.rb, line 159 def scrub_xml_fragment(string_or_io, method) Loofah.xml_fragment(string_or_io).scrub!(method) end
Shortcut for Loofah::XML::Document.parse(*args, &block)
This method accepts the same parameters as Nokogiri::XML::Document.parse
# File lib/loofah.rb, line 147 def xml_document(*args, &block) Loofah::XML::Document.parse(*args, &block) end
Shortcut for Loofah::XML::DocumentFragment.parse
(*args, &block)
This method accepts the same parameters as Nokogiri::XML::DocumentFragment.parse
# File lib/loofah.rb, line 154 def xml_fragment(*args, &block) Loofah::XML::DocumentFragment.parse(*args, &block) end