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_safe_scheme?

Instance Method Details

#block_code(code, language) ⇒ Object


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

def block_code(code, language)
  if language.present? && Redmine::SyntaxHighlighting.language_supported?(language)
    "<pre><code class=\"#{CGI.escapeHTML language} syntaxhl\">" +
      Redmine::SyntaxHighlighting.highlight_by_language(code, language) +
      "</code></pre>"
  else
    "<pre>" + CGI.escapeHTML(code) + "</pre>"
  end
end

#image(link, title, alt_text) ⇒ Object


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

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