Module: Antwort::MarkupSanitizers
- Included in:
- Builder
- Defined in:
- lib/antwort/helpers/sanitizers_helper.rb
Instance Method Summary collapse
- #add_included_css(markup = '') ⇒ Object
- #remove_excessive_newlines(markup = '') ⇒ Object
- #remove_extra_dom(html = '') ⇒ Object
- #remove_livereload(markup = '') ⇒ Object
- #remove_roadie_flags(markup = '') ⇒ Object
Instance Method Details
#add_included_css(markup = '') ⇒ Object
8 9 10 11 12 |
# File 'lib/antwort/helpers/sanitizers_helper.rb', line 8 def add_included_css(markup = '') css = File.read("#{markup_dir}/include.css") css_markup = "</title>\n<style type=\"text/css\">\n" + css + "</style>\n" markup.gsub(%r{</title>}i, css_markup) end |
#remove_excessive_newlines(markup = '') ⇒ Object
18 19 20 |
# File 'lib/antwort/helpers/sanitizers_helper.rb', line 18 def remove_excessive_newlines(markup = '') markup.gsub(/^([ \t]*\n){3,}/m, "\n\n") end |
#remove_extra_dom(html = '') ⇒ Object
22 23 24 25 |
# File 'lib/antwort/helpers/sanitizers_helper.rb', line 22 def remove_extra_dom(html = '') html.gsub(/\<!(.*)\<body.*?\>/im, '') .gsub(%r{</body>.*?</html>}im, '') end |
#remove_livereload(markup = '') ⇒ Object
3 4 5 6 |
# File 'lib/antwort/helpers/sanitizers_helper.rb', line 3 def remove_livereload(markup = '') markup.gsub(%r{<script.*?>(\s|\S)*<\/script>}i, '') .gsub(/(<head.*?>\n)(\s*\n)*/i, '\1') end |
#remove_roadie_flags(markup = '') ⇒ Object
14 15 16 |
# File 'lib/antwort/helpers/sanitizers_helper.rb', line 14 def remove_roadie_flags(markup = '') markup.gsub(' data-roadie-ignore', '') end |