Class: BookChef

Inherits:
Object
  • Object
show all
Defined in:
lib/bookchef.rb,
lib/bookchef/tree_merger.rb,
lib/bookchef/compilers/pdf.rb,
lib/bookchef/compilers/html.rb

Defined Under Namespace

Classes: Compiler, TreeMerger

Constant Summary collapse

LIB_PATH =
File.expand_path(File.dirname(__FILE__) + "/bookchef")

Class Method Summary collapse

Class Method Details

.decode_special_chars(s) ⇒ Object



28
29
30
# File 'lib/bookchef.rb', line 28

def decode_special_chars(s)
  s.gsub(/#([a-zA-Z0-9#]*?);/, '&\1;')
end

.protect_special_chars(s) ⇒ Object

Converts XML special characrters into temporary identifiable entities for later backwards conversion by BookChef compilers.



18
19
20
21
22
23
24
25
26
# File 'lib/bookchef.rb', line 18

def protect_special_chars(s)
  # erb tags
  s.gsub!(/<%(.*?)%>/, '#lt;%\1%#gt;')
  # all xml entities
  s.gsub!(/&([a-zA-Z0-9#]*?);/, '#\1;')
  # standalone ampersand chars
  s.gsub!('&', '#amp;')
  return s
end

.replace_https_with_http(s) ⇒ Object



32
33
34
# File 'lib/bookchef.rb', line 32

def replace_https_with_http(s)
  s.gsub('href="https://', 'href="http://')
end