Commit 2e8b5ebe authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #1386 from tsigo/github_markup

Use GitHub::Markup to parse markup files
parents ebd2a5d0 1814ee0c
......@@ -44,7 +44,8 @@ gem "ffaker"
gem "seed-fu"
# Markdown to HTML
gem "redcarpet", "~> 2.1.1"
gem "redcarpet", "~> 2.1.1"
gem "github-markup", "~> 0.7.4"
# Servers
gem "thin"
......
......@@ -178,6 +178,7 @@ GEM
gherkin (2.11.0)
json (>= 1.4.6)
git (1.2.5)
github-markup (0.7.4)
gitlab_meta (2.9)
grape (0.2.1)
hashie (~> 1.2)
......@@ -396,6 +397,7 @@ DEPENDENCIES
ffaker
foreman
git
github-markup (~> 0.7.4)
gitlab_meta (= 2.9)
gitolite!
grack!
......
require 'github/markup'
class RefsController < ApplicationController
include Gitlab::Encode
before_filter :project
......
......@@ -24,4 +24,14 @@ module TreeHelper
content.name
end
end
# Public: Determines if a given filename is compatible with GitHub::Markup.
#
# filename - Filename string to check
#
# Returns boolean
def markup?(filename)
filename.end_with?(*%w(.mdown .md .markdown .textile .rdoc .org .creole
.mediawiki .rst .asciidoc .pod))
end
end
......@@ -43,11 +43,7 @@
%i.icon-file
= content.name
.file_content.wiki
- if content.name =~ /\.(md|markdown)$/i
= preserve do
= markdown(content.data)
- else
= simple_format(content.data)
= raw GitHub::Markup.render(content.name, content.data)
:javascript
$(function(){
......
......@@ -9,10 +9,9 @@
= link_to "history", project_commits_path(@project, path: params[:path], ref: @ref), class: "btn very_small"
= link_to "blame", blame_file_project_ref_path(@project, @ref, path: params[:path]), class: "btn very_small"
- if file.text?
- if name =~ /\.(md|markdown)$/i
- if markup?(name)
.file_content.wiki
= preserve do
= markdown(file.data)
= raw GitHub::Markup.render(name, file.data)
- else
.file_content.code
- unless file.empty?
......
require 'spec_helper'
describe TreeHelper do
describe '#markup?' do
%w(mdown md markdown textile rdoc org creole mediawiki rst asciidoc pod).each do |type|
it "returns true for #{type} files" do
markup?("README.#{type}").should be_true
end
end
it "returns false when given a non-markup filename" do
markup?('README.rb').should_not be_true
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment