Class: Srx::Format::Html
- Inherits:
-
Xml
- Object
- BaseFormat
- Xml
- Srx::Format::Html
- Defined in:
- lib/srx/format/html.rb
Overview
Support for HTML. Tag grammar based on XML.
Constant Summary collapse
- ATT_VALUE =
Differs from XML in supporting unquoted values
/#{Xml::ATT_VALUE}|(?:[^<>&"'`=\u0020\u0009\u000D\u000A]|#{Xml::REFERENCE})+/.freeze
- ATTRIBUTE =
Differs from XML in supporting empty attributes
/#{Xml::NAME}(?:#{Xml::EQUALS}#{ATT_VALUE})?/.freeze
- START_TAG =
/<(?<name>#{Xml::NAME})(?:#{Xml::SPACE}#{ATTRIBUTE})*#{Xml::SPACE}?>/.freeze
- EMPTY_ELEM_TAG =
%r{<#{Xml::NAME}(?:#{Xml::SPACE}#{ATTRIBUTE})*#{Xml::SPACE}?/>}.freeze
- TAG =
/#{START_TAG}|#{Xml::END_TAG}|#{EMPTY_ELEM_TAG}/.freeze
- VOID_ELEMENTS =
A set of HTML tags that are “void elements”, meaning they do not need a paired closing tag.
Set[ 'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'menuitem', 'param', 'source', 'track', 'wbr' ].freeze
Constants inherited from Xml
Xml::CHAR_REF, Xml::END_TAG, Xml::ENTITY_REF, Xml::EQUALS, Xml::NAME, Xml::NAME_CHAR, Xml::NAME_START_CHAR, Xml::REFERENCE, Xml::SPACE
Instance Method Summary collapse
- #extract_markups(str) ⇒ Object
- #isolated_formatting?(markup) ⇒ Boolean
- #start_formatting?(markup) ⇒ Boolean
Methods inherited from Xml
Methods inherited from BaseFormat
Instance Method Details
#extract_markups(str) ⇒ Object
38 39 40 |
# File 'lib/srx/format/html.rb', line 38 def extract_markups(str) extract_markups_by_pattern(str, TAG) end |
#isolated_formatting?(markup) ⇒ Boolean
48 49 50 51 52 53 54 |
# File 'lib/srx/format/html.rb', line 48 def isolated_formatting?(markup) return true if EMPTY_ELEM_TAG.match?(markup) START_TAG.match(markup) do |m| VOID_ELEMENTS.include?(m['name']) end end |
#start_formatting?(markup) ⇒ Boolean
42 43 44 45 46 |
# File 'lib/srx/format/html.rb', line 42 def start_formatting?(markup) START_TAG.match(markup) do |m| !VOID_ELEMENTS.include?(m['name']) end end |