diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/helpers/application_helper.rb | 12 | ||||
| -rw-r--r-- | app/helpers/gitlab_markdown_helper.rb | 15 | ||||
| -rw-r--r-- | app/helpers/tree_helper.rb | 2 | 
3 files changed, 26 insertions, 3 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ea9722b9bef..bc07c09cd4a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -222,8 +222,12 @@ module ApplicationHelper    end    def render_markup(file_name, file_content) -    GitHub::Markup.render(file_name, file_content). -      force_encoding(file_content.encoding).html_safe +    if asciidoc?(file_name) +      asciidoc(file_content) +    else +      GitHub::Markup.render(file_name, file_content). +        force_encoding(file_content.encoding).html_safe +    end    rescue RuntimeError      simple_format(file_content)    end @@ -236,6 +240,10 @@ module ApplicationHelper      Gitlab::MarkdownHelper.gitlab_markdown?(filename)    end +  def asciidoc?(filename) +    Gitlab::MarkdownHelper.asciidoc?(filename) +  end +    # Overrides ActionView::Helpers::UrlHelper#link_to to add `rel="nofollow"` to    # external links    def link_to(name = nil, options = nil, html_options = {}) diff --git a/app/helpers/gitlab_markdown_helper.rb b/app/helpers/gitlab_markdown_helper.rb index 846aded4bda..7bcc011fd5f 100644 --- a/app/helpers/gitlab_markdown_helper.rb +++ b/app/helpers/gitlab_markdown_helper.rb @@ -56,6 +56,16 @@ module GitlabMarkdownHelper      @markdown.render(text).html_safe    end +  def asciidoc(text) +    Gitlab::Asciidoc.render(text, { +      commit: @commit, +      project: @project, +      project_wiki: @project_wiki, +      requested_path: @path, +      ref: @ref +    }) +  end +    # Return the first line of +text+, up to +max_chars+, after parsing the line    # as Markdown.  HTML tags in the parsed output are not counted toward the    # +max_chars+ limit.  If the length limit falls within a tag's contents, then @@ -67,8 +77,11 @@ module GitlabMarkdownHelper    end    def render_wiki_content(wiki_page) -    if wiki_page.format == :markdown +    case wiki_page.format +    when :markdown        markdown(wiki_page.content) +    when :asciidoc +      asciidoc(wiki_page.content)      else        wiki_page.formatted_content.html_safe      end diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb index 6dd9b6f017c..c03564a71ab 100644 --- a/app/helpers/tree_helper.rb +++ b/app/helpers/tree_helper.rb @@ -27,6 +27,8 @@ module TreeHelper    def render_readme(readme)      if gitlab_markdown?(readme.name)        preserve(markdown(readme.data)) +    elsif asciidoc?(readme.name) +      asciidoc(readme.data)      elsif markup?(readme.name)        render_markup(readme.name, readme.data)      else  | 
