1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
# frozen_string_literal: true
require "set"
module Loofah
module Elements
STRICT_BLOCK_LEVEL_HTML4 = Set.new([
"address",
"blockquote",
"center",
"dir",
"div",
"dl",
"fieldset",
"form",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"hr",
"isindex",
"menu",
"noframes",
"noscript",
"ol",
"p",
"pre",
"table",
"ul",
])
# https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
STRICT_BLOCK_LEVEL_HTML5 = Set.new([
"address",
"article",
"aside",
"blockquote",
"canvas",
"dd",
"div",
"dl",
"dt",
"fieldset",
"figcaption",
"figure",
"footer",
"form",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"header",
"hgroup",
"hr",
"li",
"main",
"nav",
"noscript",
"ol",
"output",
"p",
"pre",
"section",
"table",
"tfoot",
"ul",
"video",
])
# The following elements may also be considered block-level
# elements since they may contain block-level elements
LOOSE_BLOCK_LEVEL = Set.new([
"dd",
"dt",
"frameset",
"li",
"tbody",
"td",
"tfoot",
"th",
"thead",
"tr",
])
# Elements that aren't block but should generate a newline in #to_text
INLINE_LINE_BREAK = Set.new(["br"])
STRICT_BLOCK_LEVEL = STRICT_BLOCK_LEVEL_HTML4 + STRICT_BLOCK_LEVEL_HTML5
BLOCK_LEVEL = STRICT_BLOCK_LEVEL + LOOSE_BLOCK_LEVEL
LINEBREAKERS = BLOCK_LEVEL + INLINE_LINE_BREAK
end
::Loofah::MetaHelpers.add_downcased_set_members_to_all_set_constants(::Loofah::Elements)
end
|