Class: GfmLivePreview::Server

Inherits:
Sinatra::Application
  • Object
show all
Defined in:
lib/gfm_live_preview/server.rb

Instance Method Summary collapse

Instance Method Details

#doc_pathObject



22
23
24
# File 'lib/gfm_live_preview/server.rb', line 22

def doc_path
  File.expand_path '..', ::GfmLivePreview.file
end

#render_readme_htmlObject



16
17
18
19
20
# File 'lib/gfm_live_preview/server.rb', line 16

def render_readme_html
  readme_md = File.read ::GfmLivePreview.file
  syntax_highlight! readme_md
  GitHub::Markdown.render_gfm readme_md
end

#syntax_highlight!(str) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/gfm_live_preview/server.rb', line 7

def syntax_highlight! str
  SyntaxHighlighter.highlight! str do |string, hexcolor|
    "<span style=\"color:##{hexcolor}\">#{string}</span>"
  end
rescue => e
  puts "Exception during syntax highlighting: #{e}"
  e.backtrace.each do |line| puts line; end
end