Class: Redcarpet::Render::HTMLwithSyntaxHighlight
- Inherits:
-
HTML
- Object
- HTML
- Redcarpet::Render::HTMLwithSyntaxHighlight
show all
- Defined in:
- lib/ultra_markdown/markdown_processor.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of HTMLwithSyntaxHighlight.
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/ultra_markdown/markdown_processor.rb', line 12
def initialize(extensions={})
@syntax_converter = UltraMarkdown::SyntaxConverter.new({:is_rss => })
super(extensions.merge(
:xhtml => true,
:no_styles => true,
:filter_html => false,
:hard_wrap => true
))
end
|
Instance Method Details
#autolink(link, link_type) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/ultra_markdown/markdown_processor.rb', line 48
def autolink(link, link_type)
if link_type.to_s == "email"
ActionController::Base.helpers.mail_to(link, nil, :encode => :hex)
else
begin
link.match(/.+?/)
rescue
return link
end
bad_text = link.match(/[^\w:\/\-\~\,\$\!\.=\?&#+\|\%]+/im).to_s
link.gsub!(bad_text, '')
"<a href=\"#{link}\" rel=\"nofollow\" target=\"_blank\">#{link}</a>#{bad_text}"
end
end
|
#block_code(code, language) ⇒ Object
39
40
41
|
# File 'lib/ultra_markdown/markdown_processor.rb', line 39
def block_code(code, language)
@syntax_converter.render_octopress_like_code_block(language, code, nil, nil)
end
|
#codespan(code) ⇒ Object
43
44
45
|
# File 'lib/ultra_markdown/markdown_processor.rb', line 43
def codespan(code)
@syntax_converter.codespan(code)
end
|
Topic 裡面,所有的 head 改為 h2 顯示
69
70
71
72
|
# File 'lib/ultra_markdown/markdown_processor.rb', line 69
def (text, , anchor = nil)
+= 1
"<h#{}>#{text}</h#{}>"
end
|
#postprocess(full_document) ⇒ Object
35
36
37
|
# File 'lib/ultra_markdown/markdown_processor.rb', line 35
def postprocess(full_document)
full_document
end
|
#preprocess(full_document) ⇒ Object
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/ultra_markdown/markdown_processor.rb', line 24
def preprocess(full_document)
@syntax_converter.convert_bbcode_img(full_document)
@syntax_converter.code_block(full_document)
@syntax_converter.liquid_code_block(full_document)
@syntax_converter.liquid_image_tag(full_document)
@syntax_converter.liquid_blockquote(full_document)
@syntax_converter.gist_tag(full_document)
full_document
end
|