Module: ReVIEW::HTMLUtils
- Included in:
- HTMLBuilder, IDGXMLBuilder, MARKDOWNBuilder, WEBTOCPrinter
- Defined in:
- lib/review/htmlutils.rb
Instance Method Summary collapse
- #escape(str) ⇒ Object (also: #escape_html, #h)
- #escape_comment(str) ⇒ Object
- #highlight(ops) ⇒ Object
- #highlight? ⇒ Boolean
- #strip_html(str) ⇒ Object
- #unescape(str) ⇒ Object (also: #unescape_html)
Instance Method Details
#escape(str) ⇒ Object Also known as: escape_html, h
22 23 24 |
# File 'lib/review/htmlutils.rb', line 22 def escape(str) CGI.escapeHTML(str) end |
#escape_comment(str) ⇒ Object
40 41 42 |
# File 'lib/review/htmlutils.rb', line 40 def escape_comment(str) str.gsub('-', '-') end |
#highlight(ops) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/review/htmlutils.rb', line 48 def highlight(ops) if @book.config['pygments'].present? raise ReVIEW::ConfigError, %Q('pygments:' in config.yml is obsoleted.) end highlighter.highlight( body: ops[:body], lexer: ops[:lexer], format: 'html', linenum: ops[:linenum], options: ops[:options] || {} ) end |
#highlight? ⇒ Boolean
44 45 46 |
# File 'lib/review/htmlutils.rb', line 44 def highlight? highlighter.highlight?('html') end |
#strip_html(str) ⇒ Object
36 37 38 |
# File 'lib/review/htmlutils.rb', line 36 def strip_html(str) str.gsub(%r{</?[^>]*>}, '') end |
#unescape(str) ⇒ Object Also known as: unescape_html
29 30 31 32 |
# File 'lib/review/htmlutils.rb', line 29 def unescape(str) # FIXME: better code str.gsub('"', '"').gsub('>', '>').gsub('<', '<').gsub('&', '&') end |