class Srx::Format::Html

Support for HTML. Tag grammar based on XML.

@see www.w3.org/TR/xml/ @see html.spec.whatwg.org/multipage/syntax.html

Constants

ATTRIBUTE

Differs from XML in supporting empty attributes @see html.spec.whatwg.org/multipage/syntax.html#attributes-2

ATT_VALUE

Differs from XML in supporting unquoted values @see html.spec.whatwg.org/multipage/syntax.html#attributes-2

EMPTY_ELEM_TAG
START_TAG
TAG
VOID_ELEMENTS

A set of HTML tags that are “void elements”, meaning they do not need a paired closing tag.

@see html.spec.whatwg.org/#void-elements @see developer.mozilla.org/en-US/docs/Web/HTML/Element/command @see developer.mozilla.org/en-US/docs/Web/HTML/Element/keygen @see developer.mozilla.org/en-US/docs/Web/HTML/Element/menuitem

Public Instance Methods

extract_markups(str) click to toggle source
# File lib/srx/format/html.rb, line 38
def extract_markups(str)
  extract_markups_by_pattern(str, TAG)
end
isolated_formatting?(markup) click to toggle source
# 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) click to toggle source
# 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