aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPrem Sichanugrist <s@sikac.hu>2012-09-07 00:09:56 -0400
committerPrem Sichanugrist <s@sikac.hu>2012-09-17 15:55:17 -0400
commit5e2866cc3445646d8df049413aa5fbf03fa605ef (patch)
treecdb9f799120a0b7516309affa9248e6f0980fe58
parent7a0dad25f3be77211160560dc76a8f37963051d7 (diff)
downloadrails-5e2866cc3445646d8df049413aa5fbf03fa605ef.tar.gz
rails-5e2866cc3445646d8df049413aa5fbf03fa605ef.tar.bz2
rails-5e2866cc3445646d8df049413aa5fbf03fa605ef.zip
No more Textile guide generation support
-rw-r--r--Gemfile1
-rw-r--r--guides/Rakefile2
-rw-r--r--guides/rails_guides.rb10
-rw-r--r--guides/rails_guides/generator.rb75
-rw-r--r--guides/rails_guides/textile_extensions.rb67
-rw-r--r--guides/source/form_helpers.md2
-rw-r--r--guides/source/ruby_on_rails_guides_guidelines.md4
7 files changed, 14 insertions, 147 deletions
diff --git a/Gemfile b/Gemfile
index 3df8a70aa3..f0c06a19e2 100644
--- a/Gemfile
+++ b/Gemfile
@@ -35,7 +35,6 @@ group :doc do
# for some weeks unapplied. As a temporary solution
# this is our own fork with the fix.
gem 'sdoc', github: 'fxn/sdoc'
- gem 'RedCloth', '~> 4.2'
gem 'redcarpet', '~> 2.1.1'
gem 'w3c_validators'
end
diff --git a/guides/Rakefile b/guides/Rakefile
index be46bbae79..7881a3d9b3 100644
--- a/guides/Rakefile
+++ b/guides/Rakefile
@@ -1,6 +1,6 @@
namespace :guides do
- desc 'Generate guides (for authors), use ONLY=foo to process just "foo.textile"'
+ desc 'Generate guides (for authors), use ONLY=foo to process just "foo.md"'
task :generate => 'generate:html'
namespace :generate do
diff --git a/guides/rails_guides.rb b/guides/rails_guides.rb
index d3ae019a8c..ab890f202c 100644
--- a/guides/rails_guides.rb
+++ b/guides/rails_guides.rb
@@ -21,14 +21,14 @@ rescue LoadError
end
begin
- require 'redcloth'
+ require 'redcarpet'
rescue Gem::LoadError
# This can happen if doc:guides is executed in an application.
- $stderr.puts('Generating guides requires RedCloth 4.1.1+.')
+ $stderr.puts('Generating guides requires Redcarpet 2.1.1+.')
$stderr.puts(<<ERROR) if bundler?
Please add
- gem 'RedCloth', '~> 4.2'
+ gem 'redcarpet', '~> 2.1.1'
to the Gemfile, run
@@ -40,9 +40,5 @@ ERROR
end
require 'rails_guides/markdown'
-
-require "rails_guides/textile_extensions"
-RedCloth.send(:include, RailsGuides::TextileExtensions)
-
require "rails_guides/generator"
RailsGuides::Generator.new.generate
diff --git a/guides/rails_guides/generator.rb b/guides/rails_guides/generator.rb
index f7c0ee3bd7..eda9fd03a6 100644
--- a/guides/rails_guides/generator.rb
+++ b/guides/rails_guides/generator.rb
@@ -15,7 +15,7 @@
#
# Internal links (anchors) are checked. If a reference is broken levenshtein
# distance is used to suggest an existing one. This is useful since IDs are
-# generated by Textile from headers and thus edits alter them.
+# generated by Markdown from headers and thus edits alter them.
#
# Also detects duplicated IDs. They happen if there are headers with the same
# text. Please do resolve them, if any, so guides are valid XHTML.
@@ -65,7 +65,7 @@ module RailsGuides
class Generator
attr_reader :guides_dir, :source_dir, :output_dir, :edge, :warnings, :all
- GUIDES_RE = /\.(?:textile|erb|md|markdown)$/
+ GUIDES_RE = /\.(?:erb|md|markdown)$/
def initialize(output=nil)
set_flags_from_environment
@@ -172,8 +172,8 @@ module RailsGuides
end
def output_file_for(guide)
- if guide =~ /\.(textile|markdown|md)$/
- guide.sub(/\.(textile|markdown|md)$/, '.html')
+ if guide =~ /\.(markdown|md)$/
+ guide.sub(/\.(markdown|md)$/, '.html')
else
guide.sub(/\.erb$/, '')
end
@@ -202,17 +202,9 @@ module RailsGuides
# Generate the special pages like the home.
# Passing a template handler in the template name is deprecated. So pass the file name without the extension.
result = view.render(:layout => layout, :formats => [$1], :file => $`)
- elsif guide =~ /\.(md|markdown)$/
- body = File.read(File.join(source_dir, guide))
- result = RailsGuides::Markdown.new(view, layout).render(body)
-
- warn_about_broken_links(result) if @warnings
else
body = File.read(File.join(source_dir, guide))
- body = set_header_section(body, view)
- body = set_index(body, view)
-
- result = view.render(:layout => layout, :text => textile(body))
+ result = RailsGuides::Markdown.new(view, layout).render(body)
warn_about_broken_links(result) if @warnings
end
@@ -221,70 +213,17 @@ module RailsGuides
end
end
- def set_header_section(body, view)
- new_body = body.gsub(/(.*?)endprologue\./m, '').strip
- header = $1
-
- header =~ /h2\.(.*)/
- page_title = "Ruby on Rails Guides: #{$1.strip}"
-
- header = textile(header)
-
- view.content_for(:page_title) { page_title.html_safe }
- view.content_for(:header_section) { header.html_safe }
- new_body
- end
-
- def set_index(body, view)
- index = <<-INDEX
- <div id="subCol">
- <h3 class="chapter"><img src="images/chapters_icon.gif" alt="" />Chapters</h3>
- <ol class="chapters">
- INDEX
-
- i = Indexer.new(body, warnings)
- i.index
-
- # Set index for 2 levels
- i.level_hash.each do |key, value|
- link = view.content_tag(:a, :href => key[:id]) { textile(key[:title], true).html_safe }
-
- children = value.keys.map do |k|
- view.content_tag(:li,
- view.content_tag(:a, :href => k[:id]) { textile(k[:title], true).html_safe })
- end
-
- children_ul = children.empty? ? "" : view.content_tag(:ul, children.join(" ").html_safe)
-
- index << view.content_tag(:li, link.html_safe + children_ul.html_safe)
- end
-
- index << '</ol>'
- index << '</div>'
-
- view.content_for(:index_section) { index.html_safe }
-
- i.result
- end
-
- def textile(body, lite_mode=false)
- t = RedCloth.new(body)
- t.hard_breaks = false
- t.lite_mode = lite_mode
- t.to_html(:notestuff, :plusplus, :code)
- end
-
def warn_about_broken_links(html)
anchors = extract_anchors(html)
check_fragment_identifiers(html, anchors)
end
def extract_anchors(html)
- # Textile generates headers with IDs computed from titles.
+ # Markdown generates headers with IDs computed from titles.
anchors = Set.new
html.scan(/<h\d\s+id="([^"]+)/).flatten.each do |anchor|
if anchors.member?(anchor)
- puts "*** DUPLICATE ID: #{anchor}, please use an explicit ID, e.g. h4(#explicit-id), or consider rewording"
+ puts "*** DUPLICATE ID: #{anchor}, please make sure that there're no headings with the same name at the same level."
else
anchors << anchor
end
diff --git a/guides/rails_guides/textile_extensions.rb b/guides/rails_guides/textile_extensions.rb
deleted file mode 100644
index 1faddd4ca0..0000000000
--- a/guides/rails_guides/textile_extensions.rb
+++ /dev/null
@@ -1,67 +0,0 @@
-module RedCloth::Formatters::HTML
- def emdash(opts)
- "--"
- end
-end
-
-module RailsGuides
- module TextileExtensions
- def notestuff(body)
- # The following regexp detects special labels followed by a
- # paragraph, perhaps at the end of the document.
- #
- # It is important that we do not eat more than one newline
- # because formatting may be wrong otherwise. For example,
- # if a bulleted list follows the first item is not rendered
- # as a list item, but as a paragraph starting with a plain
- # asterisk.
- body.gsub!(/^(TIP|IMPORTANT|CAUTION|WARNING|NOTE|INFO)[.:](.*?)(\n(?=\n)|\Z)/m) do |m|
- css_class = case $1
- when 'CAUTION', 'IMPORTANT'
- 'warning'
- when 'TIP'
- 'info'
- else
- $1.downcase
- end
- %Q(<div class="#{css_class}"><p>#{$2.strip}</p></div>)
- end
- end
-
- def plusplus(body)
- body.gsub!(/\+(.*?)\+/) do |m|
- "<notextile><tt>#{$1}</tt></notextile>"
- end
-
- # The real plus sign
- body.gsub!('<plus>', '+')
- end
-
- 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 code(body)
- body.gsub!(%r{<(yaml|shell|ruby|erb|html|sql|plain)>(.*?)</\1>}m) do |m|
- <<HTML
-<notextile>
-<div class="code_container">
-<pre class="brush: #{brush_for($1)}; gutter: false; toolbar: false">
-#{ERB::Util.h($2).strip}
-</pre>
-</div>
-</notextile>
-HTML
- end
- end
- end
-end
diff --git a/guides/source/form_helpers.md b/guides/source/form_helpers.md
index e8e8a97791..ec1f1d4df1 100644
--- a/guides/source/form_helpers.md
+++ b/guides/source/form_helpers.md
@@ -201,7 +201,7 @@ Dealing with Model Objects
### Model Object Helpers
-A particularly common task for a form is editing or creating a model object. While the `*_tag` helpers can certainly be used for this task they are somewhat verbose as for each tag you would have to ensure the correct parameter name is used and set the default value of the input appropriately. Rails provides helpers tailored to this task. These helpers lack the <notextile>_tag</notextile> suffix, for example `text_field`, `text_area`.
+A particularly common task for a form is editing or creating a model object. While the `*_tag` helpers can certainly be used for this task they are somewhat verbose as for each tag you would have to ensure the correct parameter name is used and set the default value of the input appropriately. Rails provides helpers tailored to this task. These helpers lack the _tag suffix, for example `text_field`, `text_area`.
For these helpers the first argument is the name of an instance variable and the second is the name of a method (usually an attribute) to call on that object. Rails will set the value of the input control to the return value of that method for the object and set an appropriate input name. If your controller has defined `@person` and that person's name is Henry then a form containing:
diff --git a/guides/source/ruby_on_rails_guides_guidelines.md b/guides/source/ruby_on_rails_guides_guidelines.md
index 0b070bf500..e589a3d093 100644
--- a/guides/source/ruby_on_rails_guides_guidelines.md
+++ b/guides/source/ruby_on_rails_guides_guidelines.md
@@ -74,10 +74,10 @@ bundle exec rake guides:generate:html
(You may need to run `bundle install` first to install the required gems.)
-To process `my_guide.textile` and nothing else use the `ONLY` environment variable:
+To process `my_guide.md` and nothing else use the `ONLY` environment variable:
```
-touch my_guide.textile
+touch my_guide.md
bundle exec rake guides:generate ONLY=my_guide
```