Class: Redcarpet::Render::HTMLwithSyntaxHighlight
- Inherits:
-
HTML
- Object
- HTML
- Redcarpet::Render::HTMLwithSyntaxHighlight
show all
- Includes:
- Rouge::Plugins::Redcarpet
- Defined in:
- lib/ultra_markdown/markdown_processor.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of HTMLwithSyntaxHighlight.
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/ultra_markdown/markdown_processor.rb', line 16
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/ultra_markdown/markdown_processor.rb', line 52
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
43
44
45
|
# File 'lib/ultra_markdown/markdown_processor.rb', line 43
def block_code(code, language)
@syntax_converter.render_octopress_like_code_block(language, code, nil, nil)
end
|
#codespan(code) ⇒ Object
47
48
49
|
# File 'lib/ultra_markdown/markdown_processor.rb', line 47
def codespan(code)
@syntax_converter.codespan(code)
end
|
Topic 裡面,所有的 head 改為 h2 顯示
73
74
75
76
|
# File 'lib/ultra_markdown/markdown_processor.rb', line 73
def (text, , anchor = nil)
+= 1
"<h#{header_level}>#{text}</h#{header_level}>"
end
|
#postprocess(full_document) ⇒ Object
39
40
41
|
# File 'lib/ultra_markdown/markdown_processor.rb', line 39
def postprocess(full_document)
full_document
end
|
#preprocess(full_document) ⇒ Object
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/ultra_markdown/markdown_processor.rb', line 28
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
|