Class: Govspeak::HtmlSanitizer::TableCellTextAlignWhitelister
- Inherits:
-
Object
- Object
- Govspeak::HtmlSanitizer::TableCellTextAlignWhitelister
- Defined in:
- lib/govspeak/html_sanitizer.rb
Instance Method Summary collapse
Instance Method Details
#call(sanitize_context) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/govspeak/html_sanitizer.rb', line 21 def call(sanitize_context) return unless %w[td th].include?(sanitize_context[:node_name]) node = sanitize_context[:node] # Kramdown uses text-align to allow table cells to be aligned # http://kramdown.gettalong.org/quickref.html#tables if invalid_style_attribute?(node["style"]) node.remove_attribute("style") end end |
#invalid_style_attribute?(style) ⇒ Boolean
33 34 35 |
# File 'lib/govspeak/html_sanitizer.rb', line 33 def invalid_style_attribute?(style) style && !style.match(/^text-align:\s*(center|left|right)$/) end |