Class: MarkupEmail::HTMLify

Inherits:
Object
  • Object
show all
Defined in:
lib/markup_email/meta.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ HTMLify

Returns a new instance of HTMLify.



11
12
13
# File 'lib/markup_email/meta.rb', line 11

def initialize content
  @content = content
end

Instance Attribute Details

#titleObject

Returns the value of attribute title.



10
11
12
# File 'lib/markup_email/meta.rb', line 10

def title
  @title
end

Instance Method Details

#contentObject



59
# File 'lib/markup_email/meta.rb', line 59

def content; @content; end

#documentizeObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/markup_email/meta.rb', line 15

def documentize
  @content = "<!DOCTYPE html>\n<html>\n  <head></head>\n  <body>\n<article class=\"markdown-body\">\#{@content}</article>\n  </body>\n</html>\n"
end

#metaObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/markup_email/meta.rb', line 27

def meta
  document = Nokogiri::HTML(@content)
  document.css('html')[0]['xmlns'  ] = "http://www.w3.org/1999/xhtml"
  document.css('html')[0]['xmlns:v'] = "urn:schemas-microsoft-com:vml"
  document.css('html')[0]['xmlns:o'] = "urn:schemas-microsoft-com:office:office"

  document.at_css('head') << "<!-- NAME: 1:2:1 COLUMN -->\n<!--[if gte mso 15]>\n<xml>\n  <o:OfficeDocumentSettings>\n  <o:AllowPNG/>\n  <o:PixelsPerInch>96</o:PixelsPerInch>\n  </o:OfficeDocumentSettings>\n</xml>\n<![endif]-->\n"
  #github_framework = Net::HTTP.get(URI.parse("https://assets-cdn.github.com/assets/frameworks-2d2d4c150f7000385741c6b992b302689ecd172246c6428904e0813be9bceca6.css"))
  #github_primercss = Net::HTTP.get(URI.parse("https://assets-cdn.github.com/assets/github-0522ae8d3b3bdc841d2f91f90efd5f1fd9040d910905674cd134ced43a6dfea6.css"))

  # Include: #{Rouge::Themes::Tulip.render(scope: '.highlight')} in a style tag for rouge font rendering
  document.at_css('head') << "<title>\#{@title}</title>\n<meta charset=\"UTF-8\">\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n"

  #
  @content = document.to_s
end