aboutsummaryrefslogtreecommitdiffstats
path: root/guides/rails_guides/markdown.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2016-08-06 19:21:59 +0200
committerXavier Noria <fxn@hashref.com>2016-08-06 19:21:59 +0200
commit6b3719b7577ab81171bab94a0492ae383dd279fe (patch)
treedda0bb85b771cafd16acf5bea1288233feca8e09 /guides/rails_guides/markdown.rb
parent8b4e6bf23338e2080af537ea4f295e65a1d11388 (diff)
downloadrails-6b3719b7577ab81171bab94a0492ae383dd279fe.tar.gz
rails-6b3719b7577ab81171bab94a0492ae383dd279fe.tar.bz2
rails-6b3719b7577ab81171bab94a0492ae383dd279fe.zip
applies new string literal convention in guides
The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
Diffstat (limited to 'guides/rails_guides/markdown.rb')
-rw-r--r--guides/rails_guides/markdown.rb28
1 files changed, 14 insertions, 14 deletions
diff --git a/guides/rails_guides/markdown.rb b/guides/rails_guides/markdown.rb
index 69c7cd5136..6c44353b3b 100644
--- a/guides/rails_guides/markdown.rb
+++ b/guides/rails_guides/markdown.rb
@@ -1,6 +1,6 @@
-require 'redcarpet'
-require 'nokogiri'
-require 'rails_guides/markdown/renderer'
+require "redcarpet"
+require "nokogiri"
+require "rails_guides/markdown/renderer"
module RailsGuides
class Markdown
@@ -8,7 +8,7 @@ module RailsGuides
@view = view
@layout = layout
@index_counter = Hash.new(0)
- @raw_header = ''
+ @raw_header = ""
@node_ids = {}
end
@@ -47,10 +47,10 @@ module RailsGuides
def dom_id_text(text)
escaped_chars = Regexp.escape('\\/`*_{}[]()#+-.!:,;|&<>^~=\'"')
- text.downcase.gsub(/\?/, '-questionmark')
- .gsub(/!/, '-bang')
- .gsub(/[#{escaped_chars}]+/, ' ').strip
- .gsub(/\s+/, '-')
+ text.downcase.gsub(/\?/, "-questionmark")
+ .gsub(/!/, "-bang")
+ .gsub(/[#{escaped_chars}]+/, " ").strip
+ .gsub(/\s+/, "-")
end
def engine
@@ -87,15 +87,15 @@ module RailsGuides
doc.children.each do |node|
if node.name =~ /^h[3-6]$/
case node.name
- when 'h3'
+ when "h3"
hierarchy = [node]
@headings_for_index << [1, node, node.inner_html]
- when 'h4'
+ when "h4"
hierarchy = hierarchy[0, 1] + [node]
@headings_for_index << [2, node, node.inner_html]
- when 'h5'
+ when "h5"
hierarchy = hierarchy[0, 2] + [node]
- when 'h6'
+ when "h6"
hierarchy = hierarchy[0, 3] + [node]
end
@@ -109,7 +109,7 @@ module RailsGuides
def generate_index
if @headings_for_index.present?
- raw_index = ''
+ raw_index = ""
@headings_for_index.each do |level, node, label|
if level == 1
raw_index += "1. [#{label}](##{node[:id]})\n"
@@ -119,7 +119,7 @@ module RailsGuides
end
@index = Nokogiri::HTML.fragment(engine.render(raw_index)).tap do |doc|
- doc.at('ol')[:class] = 'chapters'
+ doc.at("ol")[:class] = "chapters"
end.to_html
@index = <<-INDEX.html_safe