Class: Markdown::Server

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/markdown/server.rb

Constant Summary collapse

PUBLIC_FOLDER =
"#{Markdown.root}/lib/markdown/server/public"
VIEWS_FOLDER =
"#{Markdown.root}/lib/markdown/server/views"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details



25
26
27
# File 'lib/markdown/server.rb', line 25

def self.banner
  "markdown-service #{Markdown::VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] on Sinatra/#{Sinatra::VERSION} (#{ENV['RACK_ENV']})"
end

Instance Method Details

#markdownify(params, opts = {}) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/markdown/server.rb', line 106

def markdownify( params, opts={} )
  pp params
  text = params[:text]
  lib  = params[:lib]   # optional
  pp text
  pp lib

  # fix: use activesupport -> .present?
  if lib.nil? == false && lib.empty? == false
    Markdown.lib = lib
  end

  Markdown.new( text, opts ).to_html
end

#welcome_markdownObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/markdown/server.rb', line 54

def welcome_markdown
<<EOS
# Header 1

## Header 2

### Header 3
  
Welcome to [Markdown](#{request.url}). We hope you **really** enjoy using this.

Just type some [markdown](http://daringfireball.net/projects/markdown) on the left and see it on the right. *Simple as that.*

> Quote goes here.

A list:

- One
- Two
- Three

Some inline code `to_html` and a preformatted code block:

```
Markdown.new( 'Hello Markdown!' ).to_html
```
EOS
end