Skip to content

Commit 6279d2d

Browse files
committed
Added full tutorial, based off the official React tutorial
1 parent 3410846 commit 6279d2d

File tree

9 files changed

+1064
-1
lines changed

9 files changed

+1064
-1
lines changed

site/jekyll/_layouts/default.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<footer class="wrap">
5151
<div class="right">
5252
&copy; 2014 Facebook Inc.
53-
<a href="https://github.com/reactjs/React.NET/blob/master/site/jekyll{{ page.url | replace:'.html','.md' }}" target="_blank">
53+
<a href="https://github.com/reactjs/React.NET/blob/master/site/jekyll/{{ page.path }}" target="_blank">
5454
Edit this page on GitHub
5555
</a>
5656
</div>

site/jekyll/_plugins/header_links.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require 'redcarpet'
2+
require 'sanitize'
3+
4+
# Simple converter that is probably better than RedCarpet's built in TOC id
5+
# generator (which ends up with things lik id="toc_1"... terrible).
6+
7+
class Redcarpet::Render::HTML
8+
def header(title, level)
9+
clean_title = Sanitize.clean(title)
10+
.downcase
11+
.gsub(/\s+/, "-")
12+
.gsub(/[^A-Za-z0-9\-_.]/, "")
13+
14+
return "<h#{level}><a class=\"anchor\" name=\"#{clean_title}\"></a>#{title} <a class=\"hash-link\" href=\"##{clean_title}\">#</a></h#{level}>"
15+
end
16+
end
17+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Replace Jekyll's handling of the Redcarpet code_block (which already adds
2+
# support for highlighting, but needs support for the very non-standard
3+
# "code fences with line highlights" extension).
4+
# Since this is currently depending on Redcarpet to cooperate, we are going to
5+
# be naive, and only allow line highlighting when a language is specified. If
6+
# you don't want any syntax highlighting but want to highlight lines, then you
7+
# need to specify text as your language, like:
8+
# ```text{4}
9+
10+
11+
module Jekyll
12+
module Converters
13+
class Markdown
14+
class RedcarpetParser
15+
module WithPygments
16+
def block_code(code, lang)
17+
require 'pygments'
18+
lang_parts = lang && lang.split('{')
19+
lang = lang_parts && !lang_parts[0].empty? && lang_parts[0] || 'text'
20+
hl_lines = ''
21+
if lang_parts && lang_parts.size >= 2
22+
hl_lines = lang_parts[1].gsub(/[{}]/, '').split(',').map do |ln|
23+
if matches = /(\d+)-(\d+)/.match(ln)
24+
ln = Range.new(matches[1], matches[2]).to_a.join(' ')
25+
end
26+
ln
27+
end.join(' ')
28+
end
29+
output = add_code_tags(
30+
Pygments.highlight(code, :lexer => lang,
31+
:options => { :encoding => 'utf-8', :hl_lines => hl_lines }),
32+
lang
33+
)
34+
end
35+
end
36+
end
37+
end
38+
end
39+
end

0 commit comments

Comments
 (0)