Class: Markyboot::Document

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contents) ⇒ Document

Returns a new instance of Document.



12
13
14
15
# File 'lib/markyboot.rb', line 12

def initialize(contents)
  marker = Redcarpet::Markdown.new(HTMLwithAlbino, :fenced_code_blocks => true)
  @html = marker.render(contents)
end

Instance Attribute Details

#htmlObject

Returns the value of attribute html.



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

def html
  @html
end

Instance Method Details

#layoutObject



17
18
19
20
21
22
23
24
25
26
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
# File 'lib/markyboot.rb', line 17

def layout
  layout = <<-HTML.gsub(/^ {6}/, '')
  <!DOCTYPE html>
  <html lang="en">
    <head>
      <title>Preview</title>
      <meta charset="utf-8">
      <link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" />
      <link rel="stylesheet" href="http://yandex.st/highlightjs/6.1/styles/zenburn.min.css" />
      <style type="text/css">
        body {
          background-color: #eee;
        }
        .container {
          background-color: #fff;
          width: 650px;
          margin: 2em auto;
          padding: 2em;
        }
        pre code.ruby {
          line-height: 1.45em;
        }
      </style>
    </head>
    <body>
      <div class="container">
        REPLACE_ME
      </div>
      <script src="http://yandex.st/highlightjs/6.1/highlight.min.js"></script>
      <script>hljs.initHighlightingOnLoad();</script>
    </body>
  </html>
  HTML
  layout
end

#renderObject



53
54
55
# File 'lib/markyboot.rb', line 53

def render
  layout.gsub(/REPLACE_ME/, @html)
end