module Asciidoctor::PDF::Sanitizer
Constants
- BuiltInNamedEntities
- CharRefRx
- InverseXMLSpecialChars
- InverseXMLSpecialCharsRx
- MultibyteChars
- SanitizeXMLRx
- SiftPCDATARx
- XMLMarkupRx
- XMLSpecialChars
- XMLSpecialCharsRx
Public Instance Methods
encode_quotes(string)
click to toggle source
# File lib/asciidoctor/pdf/sanitizer.rb, line 51 def encode_quotes string (string.include? ?") ? (string.gsub ?", '"') : string end
escape_xml(string)
click to toggle source
# File lib/asciidoctor/pdf/sanitizer.rb, line 47 def escape_xml string string.gsub InverseXMLSpecialCharsRx, InverseXMLSpecialChars end
lowercase_mb(string)
click to toggle source
# File lib/asciidoctor/pdf/sanitizer.rb, line 68 def lowercase_mb string string.downcase end
sanitize(string)
click to toggle source
Strip leading, trailing and repeating whitespace, remove XML tags and resolve all entities in the specified string.
FIXME move to a module so we can mix it in elsewhere FIXME add option to control escaping entities, or a filter mechanism in general
# File lib/asciidoctor/pdf/sanitizer.rb, line 41 def sanitize string string = string.gsub(SanitizeXMLRx, '') if string.include? '<' string = string.gsub(CharRefRx) { $1 ? BuiltInNamedEntities[$1] : ([$2 ? $2.to_i : ($3.to_i 16)].pack 'U1') } if string.include? '&' string.strip.tr_s ' ', ' ' end
uppercase_mb(string)
click to toggle source
# File lib/asciidoctor/pdf/sanitizer.rb, line 64 def uppercase_mb string string.upcase end
uppercase_pcdata(string)
click to toggle source
# File lib/asciidoctor/pdf/sanitizer.rb, line 55 def uppercase_pcdata string if XMLMarkupRx.match? string string.gsub(SiftPCDATARx) { $2 ? (uppercase_mb $2) : $1 } else uppercase_mb string end end