Class: Redmine::WikiFormatting::Markdown::HTML

Inherits:
Redcarpet::Render::HTML
  • Object
show all
Includes:
ActionView::Helpers::TagHelper, Helpers::URL
Defined in:
lib/redmine/wiki_formatting/markdown/formatter.rb

Instance Method Summary collapse

Methods included from Helpers::URL

#uri_with_link_safe_scheme?, #uri_with_safe_scheme?

Instance Method Details

#block_code(code, language) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/redmine/wiki_formatting/markdown/formatter.rb', line 39

def block_code(code, language)
  if language.present? && Redmine::SyntaxHighlighting.language_supported?(language)
    html = Redmine::SyntaxHighlighting.highlight_by_language(code, language)
    classattr = " class=\"#{CGI.escapeHTML language} syntaxhl\""
  else
    html = CGI.escapeHTML(code)
  end
  # original language for extension development
  langattr = " data-language=\"#{CGI.escapeHTML language}\"" if language.present?
  "<pre><code#{classattr}#{langattr}>#{html}</code></pre>"
end

#image(link, title, alt_text) ⇒ Object



51
52
53
54
55
# File 'lib/redmine/wiki_formatting/markdown/formatter.rb', line 51

def image(link, title, alt_text)
  return unless uri_with_safe_scheme?(link)

  tag('img', :src => link, :alt => alt_text || "", :title => title)
end


29
30
31
32
33
34
35
36
37
# File 'lib/redmine/wiki_formatting/markdown/formatter.rb', line 29

def link(link, title, content)
  return nil unless uri_with_safe_scheme?(link)

  css = nil
  unless link && link.starts_with?('/')
    css = 'external'
  end
  ('a', content.to_s.html_safe, :href => link, :title => title, :class => css)
end