forked from github/markup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
markups.rb
62 lines (52 loc) · 1.63 KB
/
markups.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
52
53
54
55
56
57
58
59
60
61
62
MD_FILES = /md|mkdn?|mdwn|mdown|markdown|litcoffee/
if markup('github/markdown', MD_FILES) do |content|
GitHub::Markdown.render(content)
end
elsif markup(:redcarpet, MD_FILES) do |content|
RedcarpetCompat.new(content).to_html
end
elsif markup(:rdiscount, MD_FILES) do |content|
RDiscount.new(content).to_html
end
elsif markup(:maruku, MD_FILES) do |content|
Maruku.new(content).to_html
end
elsif markup(:kramdown, MD_FILES) do |content|
Kramdown::Document.new(content).to_html
end
elsif markup(:bluecloth, MD_FILES) do |content|
BlueCloth.new(content).to_html
end
end
markup(:redcloth, /textile/) do |content|
RedCloth.new(content).to_html
end
markup('github/markup/rdoc', /rdoc/) do |content|
GitHub::Markup::RDoc.new(content).to_html
end
markup('org-ruby', /org/) do |content|
Orgmode::Parser.new(content).to_html
end
markup(:creole, /creole/) do |content|
Creole.creolize(content)
end
markup(:wikicloth, /mediawiki|wiki/) do |content|
WikiCloth::WikiCloth.new(:data => content).to_html(:noedit => true)
end
markup(:literati, /lhs/) do |content|
Literati.render(content)
end
markup(:asciidoctor, /asc|adoc|asciidoc/) do |content|
Asciidoctor::Document.new(content).render
end
command(:rest2html, /re?st(\.txt)?/)
# pod2html is nice enough to generate a full-on HTML document for us,
# so we return the favor by ripping out the good parts.
#
# Any block passed to `command` will be handed the command's STDOUT for
# post processing.
command("/usr/bin/env perl -MPod::Simple::HTML -e Pod::Simple::HTML::go", /pod/) do |rendered|
if rendered =~ /<!-- start doc -->\s*(.+)\s*<!-- end doc -->/mi
$1
end
end