forked from gjtorikian/html-pipeline
-
Notifications
You must be signed in to change notification settings - Fork 3
/
linuxfr.rb
34 lines (30 loc) · 887 Bytes
/
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
# encoding: utf-8
module HTML
class Pipeline
class LinuxFr
CONTEXT = {
toc_minimal_length: 5000,
toc_header: "<h2 class=\"sommaire\">Sommaire</h2>\n",
host: "linuxfr.org"
}
def self.render(text)
pipeline = HTML::Pipeline.new [
HTML::Pipeline::MarkdownFilter,
HTML::Pipeline::TableOfContentsFilter,
HTML::Pipeline::SyntaxHighlightFilter,
HTML::Pipeline::RelativeLinksFilter,
HTML::Pipeline::CustomLinksFilter,
HTML::Pipeline::SanitizationFilter
], CONTEXT
result = pipeline.call text
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