forked from gjtorikian/html-pipeline
-
Notifications
You must be signed in to change notification settings - Fork 3
/
linuxfr.rb
37 lines (33 loc) · 1.06 KB
/
linuxfr.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
module HTML
class Pipeline
class LinuxFr
CONTEXT = {
toc_minimal_length: 5000,
toc_header: "<h2 class=\"sommaire\">Sommaire</h2>\n",
svgtex_url: "http://localhost:16000",
host: "linuxfr.org"
}.freeze
def self.render(text, context = {})
pipeline = HTML::Pipeline.new [
HTML::Pipeline::SVGTeX::PreFilter,
HTML::Pipeline::MarkdownFilter,
HTML::Pipeline::SanitizationFilter,
HTML::Pipeline::TableOfContentsFilter,
HTML::Pipeline::SVGTeX::PostFilter,
HTML::Pipeline::SyntaxHighlightFilter,
HTML::Pipeline::NoFollowLinksFilter,
HTML::Pipeline::RelativeLinksFilter,
HTML::Pipeline::CustomLinksFilter,
], CONTEXT
result = pipeline.call text, context
result[:output].to_s
end
def self.sanitize(html)
return "" if html.nil?
pipeline = HTML::Pipeline.new [HTML::Pipeline::SanitizationFilter]
result = pipeline.call html
result[:output].to_s
end
end
end
end