aboutsummaryrefslogtreecommitdiffstats
path: root/guides/rails_guides/markdown
diff options
context:
space:
mode:
authorPrem Sichanugrist <s@sikachu.com>2012-08-31 17:49:17 -0400
committerPrem Sichanugrist <s@sikac.hu>2012-09-17 15:54:21 -0400
commitefa7717b7ab71f026df4e464046519e973c31f9a (patch)
tree6787799cb4e615ccc75069443202153b45010570 /guides/rails_guides/markdown
parent544f6bcb9095cfc826f892e6bfafee6a9bafa494 (diff)
downloadrails-efa7717b7ab71f026df4e464046519e973c31f9a.tar.gz
rails-efa7717b7ab71f026df4e464046519e973c31f9a.tar.bz2
rails-efa7717b7ab71f026df4e464046519e973c31f9a.zip
4.0 release note now renders correctly with index
Diffstat (limited to 'guides/rails_guides/markdown')
-rw-r--r--guides/rails_guides/markdown/renderer.rb31
1 files changed, 26 insertions, 5 deletions
diff --git a/guides/rails_guides/markdown/renderer.rb b/guides/rails_guides/markdown/renderer.rb
index ea3b7fc044..ec0688f937 100644
--- a/guides/rails_guides/markdown/renderer.rb
+++ b/guides/rails_guides/markdown/renderer.rb
@@ -5,11 +5,23 @@ module RailsGuides
super
end
+ def block_code(code, language)
+ <<-HTML
+<notextile>
+<div class="code_container">
+<pre class="brush: #{brush_for(language)}; gutter: false; toolbar: false">
+#{ERB::Util.h(code).strip}
+</pre>
+</div>
+</notextile>
+HTML
+ end
+
def header(text, header_level)
# Always increase the heading level by, so we can use h1, h2 heading in the document
header_level += 1
- %(<h#{header_level} id="#{dom_id(text)}">#{text}</h#{header_level}>)
+ %(<h#{header_level}>#{text}</h#{header_level}>)
end
def preprocess(full_document)
@@ -18,6 +30,19 @@ module RailsGuides
private
+ def brush_for(code_type)
+ case code_type
+ when 'ruby', 'sql', 'plain'
+ code_type
+ when 'erb'
+ 'ruby; html-script: true'
+ when 'html'
+ 'xml' # html is understood, but there are .xml rules in the CSS
+ else
+ 'plain'
+ end
+ end
+
def convert_notes(body)
# The following regexp detects special labels followed by a
# paragraph, perhaps at the end of the document.
@@ -39,10 +64,6 @@ module RailsGuides
%Q(<div class="#{css_class}"><p>#{$2.strip}</p></div>\n)
end
end
-
- def dom_id(text)
- text.downcase.gsub(/[^a-z0-9]+/, '-').strip
- end
end
end
end