This repository has been archived by the owner on Jan 17, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the contributing guide on the landing page
- Loading branch information
Showing
13 changed files
with
156 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Xapi | ||
module Routes | ||
class Home < Core | ||
get '/' do | ||
haml :markdown, locals: {markdown: Xapi::Markdown.at('./CONTRIBUTING.md')} | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
!!! | ||
/[if lt IE 7] <html class="no-js lt-ie9 lt-ie8 lt-ie7"> | ||
/[if IE 7] <html class="no-js lt-ie9 lt-ie8"> | ||
/[if IE 8] <html class="no-js lt-ie9"> | ||
/ [if gt IE 8]><! | ||
%html.no-js | ||
/ <![endif] | ||
%head | ||
%meta{:charset => "utf-8"}/ | ||
%meta{:content => "IE=edge,chrome=1", "http-equiv" => "X-UA-Compatible"}/ | ||
%title Exercism Exercises API | ||
%meta{:content => "Interfacing with Exercism", :name => "description"}/ | ||
%meta{:content => "width=device-width, initial-scale=1.0", :name => "viewport"}/ | ||
%link{:href => "css/bootstrap.min.css", :rel => "stylesheet"}/ | ||
%link{:href => "css/bootstrap-theme.min.css", :rel => "stylesheet"}/ | ||
%link{:href => "css/main.css", :rel => "stylesheet"}/ | ||
%link{:href => "favicon.ico", :rel => "shortcut icon"}/ | ||
%body | ||
/[if lt IE 7] | ||
<p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p> | ||
%section#section-content | ||
#content-first.content-heading | ||
.container.container-narrow | ||
%a.sprite-logo-medium.pull-left{:href => "http://exercism.io"} Exercism | ||
%h1.pull-left The Exercism Exercise API | ||
#content-second | ||
%article.first.last | ||
.container.container-narrow | ||
|
||
= yield | ||
|
||
%footer#section-footer | ||
.container.text-center | ||
%p | ||
%a.sprite-brand{:href => "http://exercism.io"} Exercism.io | ||
%span.text-line | ||
\© 2013 Katrina Owen / Source: | ||
= succeed "." do | ||
%a{:href => "http://github.com/exercism/x-api"} github.com/exercism/x-api | ||
%span.text-line | ||
Report bugs and submit feedback on | ||
= succeed "." do | ||
%a{:href => "htp://github.com/exercism/x-api/issues"} GitHub | ||
Email me at | ||
= succeed "." do | ||
%a{:href => "mailto:kytrinyx@exercism.io"} kytrinyx@exercism.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
= preserve markdown.to_html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
require 'redcarpet' | ||
require 'rouge' | ||
require 'rouge/plugins/redcarpet' | ||
|
||
module Xapi | ||
class Renderer < Redcarpet::Render::XHTML | ||
def lexer | ||
Rouge::Lexers::Text | ||
end | ||
|
||
def formatter | ||
@formatter ||= Rouge::Formatters::HTML.new( | ||
:css_class => "highlight #{lexer.tag}", | ||
:line_numbers => true | ||
) | ||
end | ||
|
||
def block_code(code, _) | ||
formatter.format(lexer.lex(code)) | ||
end | ||
end | ||
|
||
class Markdown | ||
def self.at(path) | ||
new File.read(path) | ||
end | ||
|
||
attr_reader :text | ||
def initialize(text) | ||
@text = text | ||
end | ||
|
||
def to_html | ||
markdown.render(text) | ||
end | ||
|
||
private | ||
|
||
def markdown | ||
@markdown ||= Redcarpet::Markdown.new(Renderer.new(hard_wrap: true), options) | ||
end | ||
|
||
def options | ||
{ | ||
fenced_code_blocks: true, | ||
no_intra_emphasis: true, | ||
autolink: true, | ||
strikethrough: true, | ||
lax_html_blocks: true, | ||
superscript: true, | ||
tables: true, | ||
space_after_headers: true, | ||
xhtml: true | ||
} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# OHAI | ||
|
||
Watch this: | ||
|
||
``` | ||
$ go home | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require './test/test_helper' | ||
require 'xapi/markdown' | ||
|
||
class MarkdownTest < Minitest::Test | ||
def test_html_from_markdown | ||
md = Xapi::Markdown.at('./test/fixtures/TEXT.md') | ||
expected = <<-HTML | ||
<h1>OHAI</h1> | ||
<p>Watch this:</p> | ||
<pre class=\"highlight text\"><table><tbody><tr><td class=\"gutter gl\"><div class=\"lineno\">1</div></td><td class=\"code\">$ go home | ||
</td></tr></tbody></table></pre> | ||
HTML | ||
assert_equal expected.chomp, md.to_html | ||
end | ||
end |