Sha256: 034513cff92019730cde703473d1035c23aa450314336ea6a0f59fd11a6700aa
Contents?: true
Size: 609 Bytes
Versions: 1
Compression:
Stored size: 609 Bytes
Contents
class Slacken::DocumentComponent module ElimLineBreaks # Private: Reject blank elements def elim_line_breaks case type.name when :text new_content = attrs[:content].gsub(/[\r\n]/, '') derive(children, attrs: attrs.merge(content: new_content)) when :pre self else derive(children.map(&:elim_line_breaks)) end end def has_no_line_breaks? case type.name when :text !attrs[:content].match(/[\r\n]/) when :pre true else children.all?(&:has_no_line_breaks?) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
slacken-0.1.0 | lib/slacken/document_component/elim_line_breaks.rb |