diff options
author | Toon Claes <toon@gitlab.com> | 2017-04-03 13:04:42 +0300 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2017-04-27 14:22:17 +0300 |
commit | ef4d4446e957ecbb086859d96185a27af168d11c (patch) | |
tree | 9e7059a8d17afb3aaaef5a39720194c36e263643 /app/helpers/markup_helper.rb | |
parent | d95bffc6dad3e6d999fb4d5c8c66d7fea05c73b7 (diff) |
Move some methods from ApplicationHelper to MarkupHelper
Diffstat (limited to 'app/helpers/markup_helper.rb')
-rw-r--r-- | app/helpers/markup_helper.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/app/helpers/markup_helper.rb b/app/helpers/markup_helper.rb index a10714e81ae..f82791b88fa 100644 --- a/app/helpers/markup_helper.rb +++ b/app/helpers/markup_helper.rb @@ -1,6 +1,22 @@ require 'nokogiri' module MarkupHelper + def plain?(filename) + Gitlab::MarkupHelper.plain?(filename) + end + + def markup?(filename) + Gitlab::MarkupHelper.markup?(filename) + end + + def gitlab_markdown?(filename) + Gitlab::MarkupHelper.gitlab_markdown?(filename) + end + + def asciidoc?(filename) + Gitlab::MarkupHelper.asciidoc?(filename) + end + # Use this in places where you would normally use link_to(gfm(...), ...). # # It solves a problem occurring with nested links (i.e. @@ -110,6 +126,22 @@ module MarkupHelper end end + def render_markup(file_name, file_content) + if gitlab_markdown?(file_name) + Hamlit::RailsHelpers.preserve(markdown(file_content)) + elsif asciidoc?(file_name) + asciidoc(file_content) + elsif plain?(file_name) + content_tag :pre, class: 'plain-readme' do + file_content + end + else + other_markup(file_name, file_content) + end + rescue RuntimeError + simple_format(file_content) + end + # Returns the text necessary to reference `entity` across projects # # project - Project to reference |