class Redcarpet::Render::HTMLwithSyntaxHighlight
Public Class Methods
new(extensions={})
click to toggle source
Calls superclass method
# File lib/ultra_markdown/markdown_processor.rb, line 15 def initialize(extensions={}) @syntax_converter = UltraMarkdown::SyntaxConverter.new({:is_rss => is_rss}) super(extensions.merge( :xhtml => true, :no_styles => true, :filter_html => false, :hard_wrap => true )) end
Public Instance Methods
autolink(link, link_type)
click to toggle source
# File lib/ultra_markdown/markdown_processor.rb, line 51 def autolink(link, link_type) # return link if link_type.to_s == "email" ActionController::Base.helpers.mail_to(link, nil, :encode => :hex) else begin # 防止 C 的 autolink 出來的內容有編碼錯誤,萬一有就直接跳過轉換 # 比如這句: # 此版本並非線上的http://yavaeye.com的源碼. link.match(/.+?/) rescue return link end # Fix Chinese neer the URL 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)
click to toggle source
# File lib/ultra_markdown/markdown_processor.rb, line 42 def block_code(code, language) @syntax_converter.render_octopress_like_code_block(language, code, nil, nil) end
codespan(code)
click to toggle source
# File lib/ultra_markdown/markdown_processor.rb, line 46 def codespan(code) @syntax_converter.codespan(code) end
header(text, header_level, anchor = nil)
click to toggle source
Topic 裡面,所有的 head 改為 h2 顯示
# File lib/ultra_markdown/markdown_processor.rb, line 72 def header(text, header_level, anchor = nil) header_level += 1 "<h#{header_level}>#{text}</h#{header_level}>" end
postprocess(full_document)
click to toggle source
# File lib/ultra_markdown/markdown_processor.rb, line 38 def postprocess(full_document) full_document end
preprocess(full_document)
click to toggle source
# File lib/ultra_markdown/markdown_processor.rb, line 27 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