Method: IsoDoc::Function::Utils#header_strip
- Defined in:
- lib/isodoc/function/utils.rb
#header_strip(hdr) ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/isodoc/function/utils.rb', line 131 def header_strip(hdr) h1 = to_xhtml_fragment(hdr.to_s.gsub(%r{<br\s*/>}, " ") .gsub(%r{</?p(\s[^<>]+)?>}, "") .gsub(/<\/?h[123456][^<>]*>/, "").gsub(/<\/?b[^<>]*>/, "").dup) h1.traverse do |x| if x.name == "span" && x["style"]&.include?("mso-tab-count") x.replace(" ") elsif header_strip_elem?(x) then x.remove elsif x.name == "a" then x.replace(x.children) end end from_xhtml(h1) end |