diff options
Diffstat (limited to 'guides/rails_guides/markdown')
-rw-r--r-- | guides/rails_guides/markdown/renderer.rb | 31 |
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 |