From bb2d16c8a14ff1bac0fe3617e2bc66609ec49101 Mon Sep 17 00:00:00 2001
From: Alexey Verkhovsky A class SmartEngine end
would not mark up CodeBlocks
',
+ 'class SmartEngine end
would not mark up CodeBlocks
class SmartEngine end
would not mark up CodeBlocks') end @@ -168,7 +168,7 @@ class RevisionTest < Test::Unit::TestCase def test_double_replacing @revision.content = "VersionHistory\r\n\r\ncry VersionHistory" assert_equal '
Version History' + - "?
\n\n\tcry " + + "?
\n\n\n\tcry " + 'Version History?' + '
', @revision.display_content @@ -176,8 +176,8 @@ class RevisionTest < Test::Unit::TestCase @revision.clear_display_cache @revision.content = "f\r\nVersionHistory\r\n\r\ncry VersionHistory" - assert_equal "f
\nVersion History" +
- "?
cry " + + assert_equal "
f\nVersion History" + + "?
\n\n\n\tcry " + "Version History?" + "
", @revision.display_content diff --git a/vendor/RedCloth-3.0.3/RedCloth.gemspec b/vendor/RedCloth-3.0.3/RedCloth.gemspec new file mode 100644 index 00000000..ca64b780 --- /dev/null +++ b/vendor/RedCloth-3.0.3/RedCloth.gemspec @@ -0,0 +1,52 @@ +require 'rubygems' +spec = Gem::Specification.new do |s| + + ## Basic Information + + s.name = 'RedCloth' + s.version = "3.0.3" + s.platform = Gem::Platform::RUBY + s.summary = <<-TXT + RedCloth is a module for using Textile and Markdown in Ruby. Textile and Markdown are text formats. + A very simple text format. Another stab at making readable text that can be converted to HTML. + TXT + s.description = <<-TXT + No need to use verbose HTML to build your docs, your blogs, your pages. Textile gives you readable text while you're writing and beautiful text for your readers. And if you need to break out into HTML, Textile will allow you to do so. + + Textile also handles some subtleties of formatting which will enhance your document's readability: + + * Single- and double-quotes around words or phrases are converted to curly quotations, much easier on + the eye. "Observe!" + + * Double hyphens are replaced with an em-dash. Observe -- very nice! + + * Single hyphens are replaced with en-dashes. Observe - so cute! + + * Triplets of periods become an ellipsis. Observe... + + * The letter 'x' becomes a dimension sign when used alone. Observe: 2 x 2. + + * Conversion of ==(TM)== to (TM), ==(R)== to (R), ==(C)== to (C). + + For more on Textile's language, hop over to "A Textile Reference":http://hobix.com/textile/. For more + on Markdown, see "Daring Fireball's page":http://daringfireball.net/projects/markdown/. + TXT + + ## Include tests, libs, docs + + s.files = ['bin/**/*', 'tests/**/*', 'lib/**/*', 'docs/**/*', 'run-tests.rb'].collect do |dirglob| + Dir.glob(dirglob) + end.flatten.delete_if {|item| item.include?("CVS")} + + ## Load-time details + + s.require_path = 'lib' + s.autorequire = 'redcloth' + + ## Author and project details + + s.author = "Why the Lucky Stiff" + s.email = "why@ruby-lang.org" + s.rubyforge_project = "redcloth" + s.homepage = "http://www.whytheluckystiff.net/ruby/redcloth/" +end diff --git a/vendor/RedCloth-3.0.3/bin/redcloth b/vendor/RedCloth-3.0.3/bin/redcloth new file mode 100644 index 00000000..81abf7db --- /dev/null +++ b/vendor/RedCloth-3.0.3/bin/redcloth @@ -0,0 +1,3 @@ +#!/usr/local/bin/ruby18 +require 'redcloth' +puts RedCloth.new( ARGF.read ).to_html diff --git a/vendor/redcloth-2.0.11/doc/CHANGELOG b/vendor/RedCloth-3.0.3/doc/CHANGELOG old mode 100755 new mode 100644 similarity index 76% rename from vendor/redcloth-2.0.11/doc/CHANGELOG rename to vendor/RedCloth-3.0.3/doc/CHANGELOG index 6f2fa5bf..7b5f9cf3 --- a/vendor/redcloth-2.0.11/doc/CHANGELOG +++ b/vendor/RedCloth-3.0.3/doc/CHANGELOG @@ -1,4 +1,42 @@ --- %YAML:1.0 +- version: 3.0.3 + date: 2005-02-06 + changes: + - Stack overflow regexp on code inlines obliterated. + - Citations scaled back. + - Toggle span tags on CAPS with :no_span_tags accessor. + +- version: 3.0.2 + date: 2005-02-02 + changes: + - Stack overflow Regexps replaced. + - All code blocks protected from formatting. + - Hard breaks working. + - Filter HTML now uses detailed cleaner. + +- version: 3.0.1 + date: 2004-11-15 + changes: + - Using `float' rather than `text-align' to align image blocks. + - Shelving more HTML attributes to prevent them from clashing with Textile glyphs. + - Simplifying the block regexp. + +- version: 3.0 + date: 2004-10-26 + changes: + - Broke up the Textile engine into smaller parts, recoded central block parser. + - Added preliminary support for Markdown. + - Added support for custom Textile prefixes. + - RedCloth now generates XHTML fragments. + - Complete HTML documents should now work, RedCloth ignores complex HTML. + +- version: 2.0.12 + date: 2004-08-09 + changes: + - Escaping tighter fortags that share a single line. + - No more String#htmlesc!. Moved to RedCloth#htmlesc. + - Pruned out the code that was handling multibyte. + - version: 2.0.11 date: 2004-06-01 changes: diff --git a/vendor/redcloth-2.0.11/doc/COPYING b/vendor/RedCloth-3.0.3/doc/COPYING old mode 100755 new mode 100644 similarity index 100% rename from vendor/redcloth-2.0.11/doc/COPYING rename to vendor/RedCloth-3.0.3/doc/COPYING diff --git a/vendor/redcloth-2.0.11/doc/README b/vendor/RedCloth-3.0.3/doc/README old mode 100755 new mode 100644 similarity index 77% rename from vendor/redcloth-2.0.11/doc/README rename to vendor/RedCloth-3.0.3/doc/README index 7a5cb1f6..1ae4560c --- a/vendor/redcloth-2.0.11/doc/README +++ b/vendor/RedCloth-3.0.3/doc/README @@ -1,17 +1,19 @@ -p=. !redcloth-title.png! +p=. !redcloth3-title.png!-h4. Get RedCloth +h4. Get RedCloth 3 -p(example1). *Latest version:* "2.0.10":http://rubyforge.org/frs/download.php/670/redcloth-2.0.10.tar.gz +p(example1). *Stable version:* "2.0.11":http://rubyforge.org/frs/download.php/698/redcloth-2.0.11.tar.gz + +p(example1). *Unstable version:* "3.0.2":http://rubyforge.org/frs/download.php/2852/RedCloth-3.0.2.tar.gz Take a complete tour of Textile at "A Textile Reference":http://hobix.com/textile/. For fast syntax checking, try the "Quick Reference":http://hobix.com/textile/quick.html. -p(example1). Upgrade with RubyGems! Try: -@gem -Ri RedCloth@. +p(example1). Upgrade with "RubyGems":http://rubygems.rubyforge.org/! Try: +@gem install RedCloth@. See the "project page":http://rubyforge.org/projects/redcloth/ for bug reporting, old releases and CVS instructions. "Documentation":http://redcloth.rubyforge.org/rdoc/ is also hosted at RubyForge. @@ -38,10 +40,10 @@ Textile is a simple markup language. table{width:400px}. |_. textile|_. to|_. html| -| ==_a phrase_== |->|_a phrase_| -| ==*a phrase*== |->|*a phrase*| -| ==_*a phrase*_== |->|_*a phrase*_| -| =="Google":http://google.com== |->|"Google":http://google.com| +|_a phrase_ |->|_a phrase_| +|*a phrase* |->|*a phrase*| +|_*a phrase*_ |->|_*a phrase*_| +|"Google":http://google.com |->|"Google":http://google.com| No need to use verbose HTML to build your docs, your blogs, your pages. Textile gives you readable text while you're writing and beautiful text for your readers. And if you need to break out into HTML, Textile will allow you to do so. @@ -58,7 +60,7 @@ Textile also handles some subtleties of formatting which will enhance your docum * The letter 'x' becomes a dimension sign when used alone. Observe: 2 x 2. -* Conversion of ==(TM)== to (TM), ==(R)== to (R), ==(C)== to (C). +* Conversion of(TM) to (TM),(R) to (R),(C) to (C). For more on Textile's language, hop over to "A Textile Reference":http://hobix.com/textile/. @@ -86,10 +88,10 @@ h2. Installing RedCloth To install RedCloth via RubyGems:- gem -Ri RedCloth + gem install RedCloth-Or "download RedCloth":http://rubyforge.org/frs/download.php/670/redcloth-2.0.10.tar.gz and simply run the install.rb like so: +Or "download RedCloth":http://rubyforge.org/frs/download.php/2852/RedCloth-3.0.2.tar.gz and simply run the install.rb like so:ruby install.rb config diff --git a/vendor/redcloth-2.0.11/doc/REFERENCE b/vendor/RedCloth-3.0.3/doc/REFERENCE old mode 100755 new mode 100644 similarity index 100% rename from vendor/redcloth-2.0.11/doc/REFERENCE rename to vendor/RedCloth-3.0.3/doc/REFERENCE diff --git a/vendor/redcloth-2.0.11/doc/make.rb b/vendor/RedCloth-3.0.3/doc/make.rb old mode 100755 new mode 100644 similarity index 94% rename from vendor/redcloth-2.0.11/doc/make.rb rename to vendor/RedCloth-3.0.3/doc/make.rb index 746436ba..3789beaa --- a/vendor/redcloth-2.0.11/doc/make.rb +++ b/vendor/RedCloth-3.0.3/doc/make.rb @@ -1,6 +1,20 @@ +$:.unshift '../lib' require 'yaml' require 'redcloth' +class String + # + # Flexible HTML escaping + # + def htmlesc!( mode ) + gsub!( '&', '&' ) + gsub!( '"', '"' ) if mode != :NoQuotes + gsub!( "'", ''' ) if mode == :Quotes + gsub!('<', '<') + gsub!('>', '>') + end +end + def a_name( phrase ) phrase.downcase. gsub( /\W+/, '-' ) @@ -119,8 +133,8 @@ when 'QUICK-REFERENCE' sections.shift puts <<-HTML - + @@ -221,8 +235,8 @@ when 'REFERENCE' sections.shift puts <<-HTML - + diff --git a/vendor/redcloth-2.0.11/install.rb b/vendor/RedCloth-3.0.3/install.rb old mode 100755 new mode 100644 similarity index 100% rename from vendor/redcloth-2.0.11/install.rb rename to vendor/RedCloth-3.0.3/install.rb diff --git a/vendor/RedCloth-3.0.3/lib/redcloth.rb b/vendor/RedCloth-3.0.3/lib/redcloth.rb new file mode 100644 index 00000000..03df12b3 --- /dev/null +++ b/vendor/RedCloth-3.0.3/lib/redcloth.rb @@ -0,0 +1,1113 @@ +# vim:ts=4:sw=4: +# = RedCloth - Textile and Markdown Hybrid for Ruby +# +# Homepage:: http://whytheluckystiff.net/ruby/redcloth/ +# Author:: why the lucky stiff (http://whytheluckystiff.net/) +# Copyright:: (cc) 2004 why the lucky stiff (and his puppet organizations.) +# License:: BSD +# +# (see http://hobix.com/textile/ for a Textile Reference.) +# +# Based on (and also inspired by) both: +# +# PyTextile: http://diveintomark.org/projects/textile/textile.py.txt +# Textism for PHP: http://www.textism.com/tools/textile/ +# +# + +# = RedCloth +# +# RedCloth is a Ruby library for converting Textile and/or Markdown +# into HTML. You can use either format, intermingled or separately. +# You can also extend RedCloth to honor your own custom text stylings. +# +# RedCloth users are encouraged to use Textile if they are generating +# HTML and to use Markdown if others will be viewing the plain text. +# +# == What is Textile? +# +# Textile is a simple formatting style for text +# documents, loosely based on some HTML conventions. +# +# == Sample Textile Text +# +# h2. This is a title +# +# h3. This is a subhead +# +# This is a bit of paragraph. +# +# bq. This is a blockquote. +# +# = Writing Textile +# +# A Textile document consists of paragraphs. Paragraphs +# can be specially formatted by adding a small instruction +# to the beginning of the paragraph. +# +# h[n]. Header of size [n]. +# bq. Blockquote. +# # Numeric list. +# * Bulleted list. +# +# == Quick Phrase Modifiers +# +# Quick phrase modifiers are also included, to allow formatting +# of small portions of text within a paragraph. +# +# \_emphasis\_ +# \_\_italicized\_\_ +# \*strong\* +# \*\*bold\*\* +# ??citation?? +# -deleted text- +# +inserted text+ +# ^superscript^ +# ~subscript~ +# @code@ +# %(classname)span% +# +# ==notextile== (leave text alone) +# +# == Links +# +# To make a hypertext link, put the link text in "quotation +# marks" followed immediately by a colon and the URL of the link. +# +# Optional: text in (parentheses) following the link text, +# but before the closing quotation mark, will become a Title +# attribute for the link, visible as a tool tip when a cursor is above it. +# +# Example: +# +# "This is a link (This is a title) ":http://www.textism.com +# +# Will become: +# +# This is a link +# +# == Images +# +# To insert an image, put the URL for the image inside exclamation marks. +# +# Optional: text that immediately follows the URL in (parentheses) will +# be used as the Alt text for the image. Images on the web should always +# have descriptive Alt text for the benefit of readers using non-graphical +# browsers. +# +# Optional: place a colon followed by a URL immediately after the +# closing ! to make the image into a link. +# +# Example: +# +# !http://www.textism.com/common/textist.gif(Textist)! +# +# Will become: +# +#+# +# With a link: +# +# !/common/textist.gif(Textist)!:http://textism.com +# +# Will become: +# +#
+# +# == Defining Acronyms +# +# HTML allows authors to define acronyms via the tag. The definition appears as a +# tool tip when a cursor hovers over the acronym. A crucial aid to clear writing, +# this should be used at least once for each acronym in documents where they appear. +# +# To quickly define an acronym in Textile, place the full text in (parentheses) +# immediately following the acronym. +# +# Example: +# +# ACLU(American Civil Liberties Union) +# +# Will become: +# +# ACLU +# +# == Adding Tables +# +# In Textile, simple tables can be added by seperating each column by +# a pipe. +# +# |a|simple|table|row| +# |And|Another|table|row| +# +# Attributes are defined by style definitions in parentheses. +# +# table(border:1px solid black). +# (background:#ddd;color:red). |{}| | | | +# +# == Using RedCloth +# +# RedCloth is simply an extension of the String class, which can handle +# Textile formatting. Use it like a String and output HTML with its +# RedCloth#to_html method. +# +# doc = RedCloth.new " +# +# h2. Test document +# +# Just a simple test." +# +# puts doc.to_html +# +# By default, RedCloth uses both Textile and Markdown formatting, with +# Textile formatting taking precedence. If you want to turn off Markdown +# formatting, to boost speed and limit the processor: +# +# class RedCloth::Textile.new( str ) + +class RedCloth < String + + VERSION = '3.0.3' + DEFAULT_RULES = [:textile, :markdown] + + # + # Two accessor for setting security restrictions. + # + # This is a nice thing if you're using RedCloth for + # formatting in public places (e.g. Wikis) where you + # don't want users to abuse HTML for bad things. + # + # If +:filter_html+ is set, HTML which wasn't + # created by the Textile processor will be escaped. + # + # If +:filter_styles+ is set, it will also disable + # the style markup specifier. ('{color: red}') + # + attr_accessor :filter_html, :filter_styles + + # + # Accessor for toggling hard breaks. + # + # If +:hard_breaks+ is set, single newlines will + # be converted to HTML break tags. This is the + # default behavior for traditional RedCloth. + # + attr_accessor :hard_breaks + + # + # Accessor for toggling span caps. + # + # Textile places `span' tags around capitalized + # words by default, but this wreaks havoc on Wikis. + # If +:no_span_caps+ is set, this will be + # suppressed. + # + attr_accessor :no_span_caps + + # + # Establishes the markup predence. Available rules include: + # + # == Textile Rules + # + # The following textile rules can be set individually. Or add the complete + # set of rules with the single :textile rule, which supplies the rule set in + # the following precedence: + # + # refs_textile:: Textile references (i.e. [hobix]http://hobix.com/) + # block_textile_table:: Textile table block structures + # block_textile_lists:: Textile list structures + # block_textile_prefix:: Textile blocks with prefixes (i.e. bq., h2., etc.) + # inline_textile_image:: Textile inline images + # inline_textile_link:: Textile inline links + # inline_textile_span:: Textile inline spans + # inline_textile_glyphs:: Textile entities (such as em-dashes and smart quotes) + # + # == Markdown + # + # refs_markdown:: Markdown references (for example: [hobix]: http://hobix.com/) + # block_markdown_setext:: Markdown setext headers + # block_markdown_atx:: Markdown atx headers + # block_markdown_rule:: Markdown horizontal rules + # block_markdown_bq:: Markdown blockquotes + # block_markdown_lists:: Markdown lists + # inline_markdown_link:: Markdown links + attr_accessor :rules + + # Returns a new RedCloth object, based on _string_ and + # enforcing all the included _restrictions_. + # + # r = RedCloth.new( "h1. A bold man", [:filter_html] ) + # r.to_html + # #=>"
A <b>bold</b> man
" + # + def initialize( string, restrictions = [] ) + restrictions.each { |r| method( "#{ r }=" ).call( true ) } + super( string ) + end + + # + # Generates HTML from the Textile contents. + # + # r = RedCloth.new( "And then? She *fell*!" ) + # r.to_html( true ) + # #=>"And then? She fell!" + # + def to_html( *rules ) + rules = DEFAULT_RULES if rules.empty? + # make our working copy + text = self.dup + + @urlrefs = {} + @shelf = [] + textile_rules = [:refs_textile, :block_textile_table, :block_textile_lists, + :block_textile_prefix, :inline_textile_image, :inline_textile_link, + :inline_textile_code, :inline_textile_glyphs, :inline_textile_span] + markdown_rules = [:refs_markdown, :block_markdown_setext, :block_markdown_atx, :block_markdown_rule, + :block_markdown_bq, :block_markdown_lists, + :inline_markdown_reflink, :inline_markdown_link] + @rules = rules.collect do |rule| + case rule + when :markdown + markdown_rules + when :textile + textile_rules + else + rule + end + end.flatten + + # standard clean up + incoming_entities text + clean_white_space text + no_textile text + + # start processor + @pre_list = [] + rip_offtags text + hard_break text + refs text + blocks text + inline text + smooth_offtags text + + retrieve text + + text.gsub!( /<\/?notextile>/, '' ) + text.gsub!( /x%x%/, '&' ) + clean_html text if filter_html + text.strip! + text + + end + + ####### + private + ####### + # + # Mapping of 8-bit ASCII codes to HTML numerical entity equivalents. + # (from PyTextile) + # + TEXTILE_TAGS = + + [[128, 8364], [129, 0], [130, 8218], [131, 402], [132, 8222], [133, 8230], + [134, 8224], [135, 8225], [136, 710], [137, 8240], [138, 352], [139, 8249], + [140, 338], [141, 0], [142, 0], [143, 0], [144, 0], [145, 8216], [146, 8217], + [147, 8220], [148, 8221], [149, 8226], [150, 8211], [151, 8212], [152, 732], + [153, 8482], [154, 353], [155, 8250], [156, 339], [157, 0], [158, 0], [159, 376]]. + + collect! do |a, b| + [a.chr, ( b.zero? and "" or "{ b };" )] + end + + # + # Regular expressions to convert to HTML. + # + A_HLGN = /(?:(?:<>|<|>|\=|[()]+)+)/ + A_VLGN = /[\-^~]/ + C_CLAS = '(?:\([^)]+\))' + C_LNGE = '(?:\[[^\]]+\])' + C_STYL = '(?:\{[^}]+\})' + S_CSPN = '(?:\\\\\d+)' + S_RSPN = '(?:/\d+)' + A = "(?:#{A_HLGN}?#{A_VLGN}?|#{A_VLGN}?#{A_HLGN}?)" + S = "(?:#{S_CSPN}?#{S_RSPN}|#{S_RSPN}?#{S_CSPN}?)" + C = "(?:#{C_CLAS}?#{C_STYL}?#{C_LNGE}?|#{C_STYL}?#{C_LNGE}?#{C_CLAS}?|#{C_LNGE}?#{C_STYL}?#{C_CLAS}?)" + # PUNCT = Regexp::quote( '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~' ) + PUNCT = Regexp::quote( '!"#$%&\'*+,-./:;=?@\\^_`|~' ) + HYPERLINK = '(\S+?)([^\w\s/;=\?]*?)(?=\s|<|$)' + + # Text markup tags, don't conflict with block tags + SIMPLE_HTML_TAGS = [ + 'tt', 'b', 'i', 'big', 'small', 'em', 'strong', 'dfn', 'code', + 'samp', 'kbd', 'var', 'cite', 'abbr', 'acronym', 'a', 'img', 'br', + 'br', 'map', 'q', 'sub', 'sup', 'span', 'bdo' + ] + + # Elements to handle + GLYPHS = [ + # [ /([^\s\[{(>])?\'([dmst]\b|ll\b|ve\b|\s|:|$)/, '\1’\2' ], # single closing + [ /([^\s\[{(>])\'/, '\1’' ], # single closing + [ /\'(?=\s|s\b|[#{PUNCT}])/, '’' ], # single closing + [ /\'/, '‘' ], # single opening + # [ /([^\s\[{(])?"(\s|:|$)/, '\1”\2' ], # double closing + [ /([^\s\[{(>])"/, '\1”' ], # double closing + [ /"(?=\s|[#{PUNCT}])/, '”' ], # double closing + [ /"/, '“' ], # double opening + [ /\b( )?\.{3}/, '\1…' ], # ellipsis + [ /\b([A-Z][A-Z0-9]{2,})\b(?:[(]([^)]*)[)])/, '\1' ], # 3+ uppercase acronym + [ /(^|[^"][>\s])([A-Z][A-Z0-9 ]{2,})([^\2\3', :no_span_caps ], # 3+ uppercase caps + [ /(\.\s)?\s?--\s?/, '\1—' ], # em dash + [ /\s->\s/, ' → ' ], # right arrow + [ /\s-\s/, ' – ' ], # en dash + [ /(\d+) ?x ?(\d+)/, '\1×\2' ], # dimension sign + [ /\b ?[(\[]TM[\])]/i, '™' ], # trademark + [ /\b ?[(\[]R[\])]/i, '®' ], # registered + [ /\b ?[(\[]C[\])]/i, '©' ] # copyright + ] + + H_ALGN_VALS = { + '<' => 'left', + '=' => 'center', + '>' => 'right', + '<>' => 'justify' + } + + V_ALGN_VALS = { + '^' => 'top', + '-' => 'middle', + '~' => 'bottom' + } + + QTAGS = [ + ['**', 'b'], + ['*', 'strong'], + ['??', 'cite', :limit], + ['-', 'del', :limit], + ['__', 'i'], + ['_', 'em', :limit], + ['%', 'span', :limit], + ['+', 'ins', :limit], + ['^', 'sup'], + ['~', 'sub'] + ] + QTAGS.collect! do |rc, ht, rtype| + rcq = Regexp::quote rc + re = + case rtype + when :limit + /(\W) + (#{rcq}) + (#{C}) + (?::(\S+?))? + (.+?) + #{rcq} + (?=\W)/x + else + /(#{rcq}) + (#{C}) + (?::(\S+?))? + (.+?) + #{rcq}/xm + end + [rc, ht, re, rtype] + end + + # + # Flexible HTML escaping + # + def htmlesc( str, mode ) + str.gsub!( '&', '&' ) + str.gsub!( '"', '"' ) if mode != :NoQuotes + str.gsub!( "'", ''' ) if mode == :Quotes + str.gsub!( '<', '<') + str.gsub!( '>', '>') + end + + # Search and replace for Textile glyphs (quotes, dashes, other symbols) + def pgl( text ) + GLYPHS.each do |re, resub, tog| + next if tog and method( tog ).call + text.gsub! re, resub + end + end + + # Parses Textile attribute lists and builds an HTML attribute string + def pba( text_in, element = "" ) + + return '' unless text_in + + style = [] + text = text_in.dup + if element == 'td' + colspan = $1 if text =~ /\\(\d+)/ + rowspan = $1 if text =~ /\/(\d+)/ + style << "vertical-align:#{ v_align( $& ) };" if text =~ A_VLGN + end + + style << "#{ $1 };" if not filter_styles and + text.sub!( /\{([^}]*)\}/, '' ) + + lang = $1 if + text.sub!( /\[([^)]+?)\]/, '' ) + + cls = $1 if + text.sub!( /\(([^()]+?)\)/, '' ) + + style << "padding-left:#{ $1.length }em;" if + text.sub!( /([(]+)/, '' ) + + style << "padding-right:#{ $1.length }em;" if text.sub!( /([)]+)/, '' ) + + style << "text-align:#{ h_align( $& ) };" if text =~ A_HLGN + + cls, id = $1, $2 if cls =~ /^(.*?)#(.*)$/ + + atts = '' + atts << " style=\"#{ style.join }\"" unless style.empty? + atts << " class=\"#{ cls }\"" unless cls.to_s.empty? + atts << " lang=\"#{ lang }\"" if lang + atts << " id=\"#{ id }\"" if id + atts << " colspan=\"#{ colspan }\"" if colspan + atts << " rowspan=\"#{ rowspan }\"" if rowspan + + atts + end + + TABLE_RE = /^(?:table(_?#{S}#{A}#{C})\. ?\n)?^(#{A}#{C}\.? ?\|.*?\|)(\n\n|\Z)/m + + # Parses a Textile table block, building HTML from the result. + def block_textile_table( text ) + text.gsub!( TABLE_RE ) do |matches| + + tatts, fullrow = $~[1..2] + tatts = pba( tatts, 'table' ) + tatts = shelve( tatts ) if tatts + rows = [] + + fullrow. + split( /\|$/m ). + delete_if { |x| x.empty? }. + each do |row| + + ratts, row = pba( $1, 'tr' ), $2 if row =~ /^(#{A}#{C}\. )(.*)/m + + cells = [] + row.split( '|' ).each do |cell| + ctyp = 'd' + ctyp = 'h' if cell =~ /^_/ + + catts = '' + catts, cell = pba( $1, 'td' ), $2 if cell =~ /^(_?#{S}#{A}#{C}\. ?)(.*)/ + + unless cell.strip.empty? + catts = shelve( catts ) if catts + cells << "\t\t\t #{ cell } " + end + end + ratts = shelve( ratts ) if ratts + rows << "\t\t\n#{ cells.join( "\n" ) }\n\t\t " + end + "\t\n#{ rows.join( "\n" ) }\n\t
\n\n" + end + end + + LISTS_RE = /^([#*]+?#{C} .*?)$(?![^#*])/m + LISTS_CONTENT_RE = /^([#*]+)(#{A}#{C}) (.*)$/m + + # Parses Textile lists and generates HTML + def block_textile_lists( text ) + text.gsub!( LISTS_RE ) do |match| + lines = match.split( /\n/ ) + last_line = -1 + depth = [] + lines.each_with_index do |line, line_id| + if line =~ LISTS_CONTENT_RE + tl,atts,content = $~[1..3] + if depth.last + if depth.last.length > tl.length + (depth.length - 1).downto(0) do |i| + break if depth[i].length == tl.length + lines[line_id - 1] << "\n\t#{ lT( depth[i] ) }l>\n\t" + depth.pop + end + end + if depth.last.length == tl.length + lines[line_id - 1] << '' + end + end + unless depth.last == tl + depth << tl + atts = pba( atts ) + atts = shelve( atts ) if atts + lines[line_id] = "\t<#{ lT(tl) }l#{ atts }>\n\t#{ content }" + else + lines[line_id] = "\t\t #{ content }" + end + last_line = line_id + + else + last_line = line_id + end + if line_id - last_line > 1 or line_id == lines.length - 1 + depth.delete_if do |v| + lines[last_line] << " \n\t#{ lT( v ) }l>" + end + end + end + lines.join( "\n" ) + end + end + + CODE_RE = /(\W) + @ + (?:\|(\w+?)\|)? + (.+?) + @ + (?=\W)/x + + def inline_textile_code( text ) + text.gsub!( CODE_RE ) do |m| + before,lang,code,after = $~[1..4] + lang = " lang=\"#{ lang }\"" if lang + rip_offtags( "#{ before }#{ code }
#{ after }" ) + end + end + + def lT( text ) + text =~ /\#$/ ? 'o' : 'u' + end + + def hard_break( text ) + text.gsub!( /(.)\n(?! *[#*\s|]|$)/, "\\1
" ) if hard_breaks + end + + BLOCKS_GROUP_RE = /\n{2,}(?! )/m + + def blocks( text, deep_code = false ) + text.replace( text.split( BLOCKS_GROUP_RE ).collect do |blk| + plain = blk !~ /\A[#*> ]/ + + # skip blocks that are complex HTML + if blk =~ /^<\/?(\w+).*>/ and not SIMPLE_HTML_TAGS.include? $1 + blk + else + # search for indentation levels + blk.strip! + if blk.empty? + blk + else + code_blk = nil + blk.gsub!( /((?:\n(?:\n^ +[^\n]*)+)+)/m ) do |iblk| + flush_left iblk + blocks iblk, plain + iblk.gsub( /^(\S)/, "\t\\1" ) + if plain + code_blk = iblk; "" + else + iblk + end + end + + block_applied = 0 + @rules.each do |rule_name| + block_applied += 1 if ( rule_name.to_s.match /^block_/ and method( rule_name ).call( blk ) ) + end + if block_applied.zero? + if deep_code + blk = "\t" + else + blk = "\t#{ blk }
#{ blk }
" + end + end + # hard_break blk + blk + "\n#{ code_blk }" + end + end + + end.join( "\n\n" ) ) + end + + def textile_bq( tag, atts, cite, content ) + cite, cite_title = check_refs( cite ) + cite = " cite=\"#{ cite }\"" if cite + atts = shelve( atts ) if atts + "\t\n\t\t" + end + + def textile_p( tag, atts, cite, content ) + atts = shelve( atts ) if atts + "\t<#{ tag }#{ atts }>#{ content }#{ tag }>" + end + + alias textile_h1 textile_p + alias textile_h2 textile_p + alias textile_h3 textile_p + alias textile_h4 textile_p + alias textile_h5 textile_p + alias textile_h6 textile_p + + def textile_fn_( tag, num, atts, cite, content ) + atts << " id=\"fn#{ num }\"" + content = "#{ num } #{ content }" + atts = shelve( atts ) if atts + "\t#{ content }
\n\t#{ content }
" + end + + BLOCK_RE = /^(([a-z]+)(\d*))(#{A}#{C})\.(?::(\S+))? (.*)$/m + + def block_textile_prefix( text ) + if text =~ BLOCK_RE + tag,tagpre,num,atts,cite,content = $~[1..6] + atts = pba( atts ) + + # pass to prefix handler + if respond_to? "textile_#{ tag }", true + text.gsub!( $&, method( "textile_#{ tag }" ).call( tag, atts, cite, content ) ) + elsif respond_to? "textile_#{ tagpre }_", true + text.gsub!( $&, method( "textile_#{ tagpre }_" ).call( tagpre, num, atts, cite, content ) ) + end + end + end + + SETEXT_RE = /\A(.+?)\n([=-])[=-]* *$/m + def block_markdown_setext( text ) + if text =~ SETEXT_RE + tag = if $2 == "="; "h1"; else; "h2"; end + blk, cont = "<#{ tag }>#{ $1 }#{ tag }>", $' + blocks cont + text.replace( blk + cont ) + end + end + + ATX_RE = /\A(\#{1,6}) # $1 = string of #'s + [ ]* + (.+?) # $2 = Header text + [ ]* + \#* # optional closing #'s (not counted) + $/x + def block_markdown_atx( text ) + if text =~ ATX_RE + tag = "h#{ $1.length }" + blk, cont = "<#{ tag }>#{ $2 }#{ tag }>\n\n", $' + blocks cont + text.replace( blk + cont ) + end + end + + MARKDOWN_BQ_RE = /\A(^ *> ?.+$(.+\n)*\n*)+/m + + def block_markdown_bq( text ) + text.gsub!( MARKDOWN_BQ_RE ) do |blk| + blk.gsub!( /^ *> ?/, '' ) + flush_left blk + blocks blk + blk.gsub!( /^(\S)/, "\t\\1" ) + "\n#{ blk }\n\n\n" + end + end + + MARKDOWN_RULE_RE = /^#{ + ['*', '-', '_'].collect { |ch| '( ?' + Regexp::quote( ch ) + ' ?){3,}' }.join( '|' ) + }$/ + + def block_markdown_rule( text ) + text.gsub!( MARKDOWN_RULE_RE ) do |blk| + "
" + end + end + + # XXX TODO XXX + def block_markdown_lists( text ) + end + + def inline_markdown_link( text ) + end + + def inline_textile_span( text ) + QTAGS.each do |qtag_rc, ht, qtag_re, rtype| + text.gsub!( qtag_re ) do |m| + + case rtype + when :limit + sta,qtag,atts,cite,content = $~[1..5] + else + qtag,atts,cite,content = $~[1..4] + sta = '' + end + atts = pba( atts ) + atts << " cite=\"#{ cite }\"" if cite + atts = shelve( atts ) if atts + + "#{ sta }<#{ ht }#{ atts }>#{ content }#{ ht }>" + + end + end + end + + LINK_RE = / + ([\s\[{(]|[#{PUNCT}])? # $pre + " # start + (#{C}) # $atts + ([^"]+?) # $text + \s? + (?:\(([^)]+?)\)(?="))? # $title + ": + (\S+?) # $url + (\/)? # $slash + ([^\w\/;]*?) # $post + (?=<|\s|$) + /x + + def inline_textile_link( text ) + text.gsub!( LINK_RE ) do |m| + pre,atts,text,title,url,slash,post = $~[1..7] + + url, url_title = check_refs( url ) + title ||= url_title + + atts = pba( atts ) + atts = " href=\"#{ url }#{ slash }\"#{ atts }" + atts << " title=\"#{ title }\"" if title + atts = shelve( atts ) if atts + + "#{ pre }#{ text }#{ post }" + end + end + + MARKDOWN_REFLINK_RE = / + \[([^\[\]]+)\] # $text + [ ]? # opt. space + (?:\n[ ]*)? # one optional newline followed by spaces + \[(.*?)\] # $id + /x + + def inline_markdown_reflink( text ) + text.gsub!( MARKDOWN_REFLINK_RE ) do |m| + text, id = $~[1..2] + + if id.empty? + url, title = check_refs( text ) + else + url, title = check_refs( id ) + end + + atts = " href=\"#{ url }\"" + atts << " title=\"#{ title }\"" if title + atts = shelve( atts ) + + "#{ text }" + end + end + + MARKDOWN_LINK_RE = / + \[([^\[\]]+)\] # $text + \( # open paren + [ \t]* # opt space + (.+?)>? # $href + [ \t]* # opt space + (?: # whole title + (['"]) # $quote + (.*?) # $title + \3 # matching quote + )? # title is optional + \) + /x + + def inline_markdown_link( text ) + text.gsub!( MARKDOWN_LINK_RE ) do |m| + text, url, quote, title = $~[1..4] + + atts = " href=\"#{ url }\"" + atts << " title=\"#{ title }\"" if title + atts = shelve( atts ) + + "#{ text }" + end + end + + TEXTILE_REFS_RE = /(^ *)\[([^\n]+?)\](#{HYPERLINK})(?=\s|$)/ + MARKDOWN_REFS_RE = /(^ *)\[([^\n]+?)\]:\s+(#{HYPERLINK})>?(?:\s+"((?:[^"]|\\")+)")?(?=\s|$)/m + + def refs( text ) + @rules.each do |rule_name| + method( rule_name ).call( text ) if rule_name.to_s.match /^refs_/ + end + end + + def refs_textile( text ) + text.gsub!( TEXTILE_REFS_RE ) do |m| + flag, url = $~[2..3] + @urlrefs[flag.downcase] = [url, nil] + nil + end + end + + def refs_markdown( text ) + text.gsub!( MARKDOWN_REFS_RE ) do |m| + flag, url = $~[2..3] + title = $~[6] + @urlrefs[flag.downcase] = [url, title] + nil + end + end + + def check_refs( text ) + ret = @urlrefs[text.downcase] if text + ret || [text, nil] + end + + IMAGE_RE = / + (|.|^) # start of line? + \! # opening + (\<|\=|\>)? # optional alignment atts + (#{C}) # optional style,class atts + (?:\. )? # optional dot-space + ([^\s(!]+?) # presume this is the src + \s? # optional space + (?:\(((?:[^\(\)]|\([^\)]+\))+?)\))? # optional title + \! # closing + (?::#{ HYPERLINK })? # optional href + /x + + def inline_textile_image( text ) + text.gsub!( IMAGE_RE ) do |m| + stln,algn,atts,url,title,href,href_a1,href_a2 = $~[1..8] + atts = pba( atts ) + atts = " src=\"#{ url }\"#{ atts }" + atts << " title=\"#{ title }\"" if title + atts << " alt=\"#{ title }\"" + # size = @getimagesize($url); + # if($size) $atts.= " $size[3]"; + + href, alt_title = check_refs( href ) if href + url, url_title = check_refs( url ) + + out = '' + out << "" if href + out << "
" + out << "#{ href_a1 }#{ href_a2 }" if href + + if algn + algn = h_align( algn ) + if stln == "
" + out = "
#{ out }" + else + out = "#{ stln }
#{ out }" + end + else + out = stln + out + end + + out + end + end + + def shelve( val ) + @shelf << val + " <#{ @shelf.length }>" + end + + def retrieve( text ) + @shelf.each_with_index do |r, i| + text.gsub!( " <#{ i + 1 }>", r ) + end + end + + def incoming_entities( text ) + ## turn any incoming ampersands into a dummy character for now. + ## This uses a negative lookahead for alphanumerics followed by a semicolon, + ## implying an incoming html entity, to be skipped + + text.gsub!( /&(?![#a-z0-9]+;)/i, "x%x%" ) + end + + def no_textile( text ) + text.gsub!( /(^|\s)==([^=]+.*?)==(\s|$)?/, + '\1\2 \3' ) + text.gsub!( /^ *==([^=]+.*?)==/m, + '\1\2 \3' ) + end + + def clean_white_space( text ) + # normalize line breaks + text.gsub!( /\r\n/, "\n" ) + text.gsub!( /\r/, "\n" ) + text.gsub!( /\t/, ' ' ) + text.gsub!( /^ +$/, '' ) + text.gsub!( /\n{3,}/, "\n\n" ) + text.gsub!( /"$/, "\" " ) + + # if entire document is indented, flush + # to the left side + flush_left text + end + + def flush_left( text ) + indt = 0 + if text =~ /^ / + while text !~ /^ {#{indt}}\S/ + indt += 1 + end unless text.empty? + if indt.nonzero? + text.gsub!( /^ {#{indt}}/, '' ) + end + end + end + + def footnote_ref( text ) + text.gsub!( /\b\[([0-9]+?)\](\s)?/, + '\1\2' ) + end + + OFFTAGS = /(code|pre|kbd|notextile)/ + OFFTAG_MATCH = /(?:(<\/#{ OFFTAGS }>)|(<#{ OFFTAGS }[^>]*>))(.*?)(?=<\/?#{ OFFTAGS }|\Z)/mi + OFFTAG_OPEN = /<#{ OFFTAGS }/ + OFFTAG_CLOSE = /<\/?#{ OFFTAGS }/ + HASTAG_MATCH = /(<\/?\w[^\n]*?>)/m + ALLTAG_MATCH = /(<\/?\w[^\n]*?>)|.*?(?=<\/?\w[^\n]*?>|$)/m + + def inline_textile_glyphs( text, level = 0 ) + if text !~ HASTAG_MATCH + pgl text + footnote_ref text + else + codepre = 0 + text.gsub!( ALLTAG_MATCH ) do |line| + ## matches are off if we're between,
etc. + if $1 + if line =~ OFFTAG_OPEN + codepre += 1 + elsif line =~ OFFTAG_CLOSE + codepre -= 1 + codepre = 0 if codepre < 0 + end + elsif codepre.zero? + inline_textile_glyphs( line, level + 1 ) + else + htmlesc( line, :NoQuotes ) + end + ## p [level, codepre, orig_line, line] + + line + end + end + end + + def rip_offtags( text ) + if text =~ /<.*>/ + ## strip and encodecontent + codepre, used_offtags = 0, {} + text.gsub!( OFFTAG_MATCH ) do |line| + if $3 + offtag, aftertag = $4, $5 + codepre += 1 + used_offtags[offtag] = true + if codepre - used_offtags.length > 0 + htmlesc( line, :NoQuotes ) unless used_offtags['notextile'] + @pre_list.last << line + line = "" + else + htmlesc( aftertag, :NoQuotes ) if aftertag and not used_offtags['notextile'] + line = "" + @pre_list << "#{ $3 }#{ aftertag }" + end + elsif $1 and codepre > 0 + if codepre - used_offtags.length > 0 + htmlesc( line, :NoQuotes ) unless used_offtags['notextile'] + @pre_list.last << line + line = "" + end + codepre -= 1 unless codepre.zero? + used_offtags = {} if codepre.zero? + end + line + end + end + text + end + + def smooth_offtags( text ) + unless @pre_list.empty? + ## replace content + text.gsub!( // ) { @pre_list[$1.to_i] } + end + end + + def inline( text ) + @rules.each do |rule_name| + method( rule_name ).call( text ) if rule_name.to_s.match /^inline_/ + end + end + + def h_align( text ) + H_ALGN_VALS[text] + end + + def v_align( text ) + V_ALGN_VALS[text] + end + + def textile_popup_help( name, windowW, windowH ) + ' ' + name + '
' + end + + # HTML cleansing stuff + BASIC_TAGS = { + 'a' => ['href', 'title'], + 'img' => ['src', 'alt', 'title'], + 'br' => [], + 'i' => nil, + 'u' => nil, + 'b' => nil, + 'pre' => nil, + 'kbd' => nil, + 'code' => ['lang'], + 'cite' => nil, + 'strong' => nil, + 'em' => nil, + 'ins' => nil, + 'sup' => nil, + 'sub' => nil, + 'del' => nil, + 'table' => nil, + 'tr' => nil, + 'td' => ['colspan', 'rowspan'], + 'th' => nil, + 'ol' => nil, + 'ul' => nil, + 'li' => nil, + 'p' => nil, + 'h1' => nil, + 'h2' => nil, + 'h3' => nil, + 'h4' => nil, + 'h5' => nil, + 'h6' => nil, + 'blockquote' => ['cite'] + } + + def clean_html( text, tags = BASIC_TAGS ) + text.gsub!( /]*)>/ ) do + raw = $~ + tag = raw[2].downcase + if tags.has_key? tag + pcs = [tag] + tags[tag].each do |prop| + ['"', "'", ''].each do |q| + q2 = ( q != '' ? q : '\s' ) + if raw[3] =~ /#{prop}\s*=\s*#{q}([^#{q2}]+)#{q}/i + attrv = $1 + next if prop == 'src' and attrv !~ /^http/ + pcs << "#{prop}=\"#{$1.gsub('"', '\\"')}\"" + break + end + end + end if tags[tag] + "<#{raw[1]}#{pcs.join " "}>" + else + " " + end + end + end +end + diff --git a/vendor/redcloth-2.0.11/run-tests.rb b/vendor/RedCloth-3.0.3/run-tests.rb old mode 100755 new mode 100644 similarity index 55% rename from vendor/redcloth-2.0.11/run-tests.rb rename to vendor/RedCloth-3.0.3/run-tests.rb index d5bb83ae..65b5c969 --- a/vendor/redcloth-2.0.11/run-tests.rb +++ b/vendor/RedCloth-3.0.3/run-tests.rb @@ -1,12 +1,20 @@ #!/usr/bin/env ruby -require 'redcloth' +require 'lib/redcloth' require 'yaml' Dir["tests/*.yml"].each do |testfile| YAML::load_documents( File.open( testfile ) ) do |doc| if doc['in'] and doc['out'] - html = RedCloth.new( doc['in'] ).to_html + red = RedCloth.new( doc['in'] ) + html = if testfile =~ /markdown/ + red.to_html( :markdown ) + else + red.to_html + end puts "---" + + html.gsub!( /\n+/, "\n" ) + doc['out'].gsub!( /\n+/, "\n" ) if html == doc['out'] puts "success: true" else diff --git a/vendor/redcloth-2.0.11/tests/code.yml b/vendor/RedCloth-3.0.3/tests/code.yml old mode 100755 new mode 100644 similarity index 58% rename from vendor/redcloth-2.0.11/tests/code.yml rename to vendor/RedCloth-3.0.3/tests/code.yml index 4fd84053..bc7bd2cc --- a/vendor/redcloth-2.0.11/tests/code.yml +++ b/vendor/RedCloth-3.0.3/tests/code.yml @@ -24,6 +24,7 @@ in: |- out: |-Testing nested pre tags…
++ + + If @plastic_cup@ contains either @nil@ or @false@, you won't see anything print + to the screen. They're not on the @if@ guest list. So @if@ isn't going to run + any of the code it's protecting. + + + But @nil@ and @false@ need not walk away in shame. They may be of questionable + character, but @unless@ runs a smaller establishment that caters to the bedraggled. + The @unless@ keyword has a policy of only allowing those with a negative charge in. + Who are: @nil@ and @false@. + + +Good code here. @@ -64,3 +65,41 @@ out: '
this test is strong
' --- in:__inline__out:__inline__+--- +in: |- + * @foo@ + * @bar@ + * and @x@ is also. +out: "\n\t
" +--- +in: |- +- \n\t\t
foo
- \n\t\t
bar
- and
\n\tx
is also.+ +out: |- + <hello>+<hello>+--- +in: | + Test of Markdown-style indented code. + + a = [1, 2, 3] + a.each do |x| + puts "test number", x, + "and more!" + end + + Paragraph 2. + + Paragraph 3. +out: |- +Test of Markdown-style indented code.
+ ++ +a = [1, 2, 3] + a.each do |x| + puts "test number", x, + "and more!" + end
Paragraph 2.
+ +Paragraph 3.
diff --git a/vendor/redcloth-2.0.11/tests/images.yml b/vendor/RedCloth-3.0.3/tests/images.yml old mode 100755 new mode 100644 similarity index 73% rename from vendor/redcloth-2.0.11/tests/images.yml rename to vendor/RedCloth-3.0.3/tests/images.yml index 01f38f45..d097e0fb --- a/vendor/redcloth-2.0.11/tests/images.yml +++ b/vendor/RedCloth-3.0.3/tests/images.yml @@ -27,145 +27,145 @@ in: This is not an image!!! out:This is not an image!!!
--- in: This is an !http://example.com/i/image.jpg!:#1 -out: +out: --- in: This is an !http://example.com/i/image.jpg!:#a -out: +out: --- in: This is an !http://example.com/i/image.jpg!:#a1 -out: +out: --- in: This is an !http://example.com/i/image.jpg!:#a10 -out: +out: --- in: This is an !http://example.com/i/image.jpg!:index.html -out: +out: --- in: This is an !http://example.com/i/image.jpg!:index.html#1 -out: +out: --- in: This is an !http://example.com/i/image.jpg!:index.html#a1 -out: +out: --- in: This is an !http://example.com/i/image.jpg!:index.html#a10 -out: +out: --- in: This is an !http://example.com/i/image.jpg!:index.html?foo=bar -out: +out: --- in: This is an !http://example.com/i/image.jpg!:index.html?foo=bar#1 -out: +out: --- in: This is an !http://example.com/i/image.jpg!:index.html?foo=bar#a -out: +out: --- in: This is an !http://example.com/i/image.jpg!:index.html?foo=bar#a1 -out: +out: --- in: This is an !http://example.com/i/image.jpg!:index.html?foo=bar#a10 -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/ -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/#1 -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/#a -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/#a1 -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/#a10 -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html#1 -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html#a -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html#a1 -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html#a10 -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar#1 -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar#a -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar#a1 -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar#a10 -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#1 -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#a -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#a1 -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#a10 -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b. -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#1. -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#a. -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#a1. -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#a10. -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b, but this is not. -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#1, but this is not. -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#a, but this is not. -out: +out: --- in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#a1, but this is not. -out: +out: --- in: (This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#a10) This is not. -out: +out: --- in: (This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b) This is not. -out: +out: --- in: (This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#1) This is not. -out: +out: --- in: (This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#a) This is not. -out: +out: --- in: (This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#a1) This is not. -out: +out: --- in: (This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#a10) This is not. -out: +out: diff --git a/vendor/redcloth-2.0.11/tests/instiki.yml b/vendor/RedCloth-3.0.3/tests/instiki.yml old mode 100755 new mode 100644 similarity index 96% rename from vendor/redcloth-2.0.11/tests/instiki.yml rename to vendor/RedCloth-3.0.3/tests/instiki.yml index eaf22424..89b8ec6b --- a/vendor/redcloth-2.0.11/tests/instiki.yml +++ b/vendor/RedCloth-3.0.3/tests/instiki.yml @@ -18,17 +18,19 @@ out: 'nested span because of Version History +
-
diff --git a/vendor/redcloth-2.0.11/tests/links.yml b/vendor/RedCloth-3.0.3/tests/links.yml old mode 100755 new mode 100644 similarity index 90% rename from vendor/redcloth-2.0.11/tests/links.yml rename to vendor/RedCloth-3.0.3/tests/links.yml index eeb28ae8..16b63331 --- a/vendor/redcloth-2.0.11/tests/links.yml +++ b/vendor/RedCloth-3.0.3/tests/links.yml @@ -150,3 +150,6 @@ out:- Version
+- Version 0.0 – Early version using MD5 hashes.
-- Version
+- Version 0.1 – First cut of new system. Much cleaner.
- Version 0.2 – Fixed problem with “authors” page and some tests.
Go to \n\t
rubylang \n\t" +--- +in: 'The ION coding style document found at "IONCodingStyleGuide.doc":http://perforce:8081/@md=d&cd=//&c=82E@//depot/systest/system/main/pub/doc/IONCodingStyleGuide.doc?ac=22 codifies a couple of rules to ensure reasonably consistent code and documentation of libraries in ION. Test text' +out:The ION coding style document found at IONCodingStyleGuide.doc codifies a couple of rules to ensure reasonably consistent code and documentation of libraries in ION. Test text
diff --git a/vendor/redcloth-2.0.11/tests/lists.yml b/vendor/RedCloth-3.0.3/tests/lists.yml old mode 100755 new mode 100644 similarity index 93% rename from vendor/redcloth-2.0.11/tests/lists.yml rename to vendor/RedCloth-3.0.3/tests/lists.yml index d075ce5b..cf8938f0 --- a/vendor/redcloth-2.0.11/tests/lists.yml +++ b/vendor/RedCloth-3.0.3/tests/lists.yml @@ -24,11 +24,10 @@ in: |- p. end out: |-start
--
@@ -46,13 +45,11 @@ in: |- yeah number #* bullet *** okay - ****# what out: |-- one
+- one and one
-- two
+- two and two
- three
Funky:
-
- Testing
@@ -62,13 +59,12 @@ out: |-
number -number
+number yeah number
- bullet
diff --git a/vendor/RedCloth-3.0.3/tests/markdown.yml b/vendor/RedCloth-3.0.3/tests/markdown.yml new file mode 100644 index 00000000..a053ea39 --- /dev/null +++ b/vendor/RedCloth-3.0.3/tests/markdown.yml @@ -0,0 +1,218 @@ +in: | + This is a regular paragraph. + +
- okay -
- what
+
+ + This is another regular paragraph. +out: |- ++ +Foo +This is a regular paragraph.
+ + ++
++ +Foo +This is another regular paragraph.
+--- +in: '"Larry Bird":http://images.google.com/images?num=30&q=larry+bird' +out: '"Larry Bird":http://images.google.com/images?num=30&q=larry+bird
' +--- +in: '©' +out:©
+--- +in: AT&T +out:AT&T
+ +# We don't do this. +# --- +# in: 4 < 5 +# out: 4 < 5 +--- +in: | + This is an H1 + ============= + + This is an H2 + ------------- +out: |- +This is an H1
+ +This is an H2
+--- +in: | + # This is an H1 + + ## This is an H2 + + ###### This is an H6 +out: |- +This is an H1
+ +This is an H2
+ +This is an H6
+--- +in: | + > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, + > consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. + > Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. + > + > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse + > id sem consectetuer libero luctus adipiscing. +out: |- +++--- +in: | + > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, + consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. + Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. + > + > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse + id sem consectetuer libero luctus adipiscing. +out: |- +This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, + consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. + Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
+ +Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse + id sem consectetuer libero luctus adipiscing.
+ +++--- +in: | + > This is the first level of quoting. + > + > > This is nested blockquote. + > + > Back to the first level. +out: |- +This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, + consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. + Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
+ +Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse + id sem consectetuer libero luctus adipiscing.
+ +++--- +in: | + > ## This is a header. + > + > 1. This is the first list item. + > 2. This is the second list item. + > + > Here's some example code: + > + > return shell_exec("echo $input | $markdown_script"); +out: |- +This is the first level of quoting.
+++ + + +This is nested blockquote.
+ +Back to the first level.
+ +++--- +in: | + * * * + + *** + + ***** + + - - - + + --------------------------------------- + + _ _ _ +out: |- +This is a header.
+ + + +1. This is the first list item. + 2. This is the second list item.
+ +Here's some example code:
++ +return shell_exec("echo $input | $markdown_script");
+ +
+ +
+ +
+ +
+ +
+--- +in: | + This is [an example](http://example.com/ "Title") inline link. + + [This link](http://example.net/) has no title attribute. +out: |- +This is an example inline link.
+ +This link has no title attribute.
+--- +in: See my [About](/about/) page for details. +out:See my About page for details.
+--- +in: | + This is [an example][id] reference-style link. + + This is [an example] [id] reference-style link. + + [id]: http://example.com/ "Optional Title Here" +out: |- +This is an example reference-style link.
+ +This is an example reference-style link.
+--- +in: | + [Google][] + [Google]: http://google.com/ +out: +--- +in: | + Visit [Daring Fireball][] for more information. + [Daring Fireball]: http://daringfireball.net/ +out:Visit Daring Fireball for more information.
+--- +in: | + I get 10 times more traffic from [Google] [1] than from + [Yahoo] [2] or [MSN] [3]. + + [1]: http://google.com/ "Google" + [2]: http://search.yahoo.com/ "Yahoo Search" + [3]: http://search.msn.com/ "MSN Search" + +out: |- +I get 10 times more traffic from Google than from + Yahoo or MSN.
+--- +in: | + I get 10 times more traffic from [Google][] than from + [Yahoo][] or [MSN][]. + + [google]: http://google.com/ "Google" + [yahoo]: http://search.yahoo.com/ "Yahoo Search" + [msn]: http://search.msn.com/ "MSN Search" +out: |- +I get 10 times more traffic from Google than from + Yahoo or MSN.
diff --git a/vendor/RedCloth-3.0.3/tests/poignant.yml b/vendor/RedCloth-3.0.3/tests/poignant.yml new file mode 100644 index 00000000..1a0f6942 --- /dev/null +++ b/vendor/RedCloth-3.0.3/tests/poignant.yml @@ -0,0 +1,64 @@ +--- # Tests from the (Poignant Guide) +in: > + h3. False + + + ! + if plastic_cup + print "Plastic cup is on the up 'n' up!" + end ++ unless plastic_cup + print "Plastic cup is on the down low." + end ++ + + You can also use @if@ and @unless@ at the end of a single line of code, if that's + all that is being protected. + + ++ print "Yeah, plastic cup is up again!" if plastic_cup + print "Hardly. It's down." unless plastic_cup ++ + + Now that you've met @false@, I'm sure you can see what's on next. + +out: "False
\n\n\t\n\n\t
The cat Trady Blix. Frozen in emptiness. Immaculate whiskers rigid. Placid eyes of lake. Tail of warm icicle. Sponsored by a Very Powerful Pause Button.
\n\n\tThe darkness surrounding Blix can be called negative space. Hang on to that phrase. Let it suggest that the emptiness has a negative connotation. In a similar way,
\n\n\tnil
has a slightly sour note that it whistles.Generally speaking, everything in Ruby has a positive charge to it. This spark flows through strings, numbers, regexps, all of it. Only two keywords wear a shady cloak:
\n\n\tnil
andfalse
draggin us down.You can test that charge with an
\n\n\nif
keyword. It looks very much like thedo
blocks we saw in the last chapter, in that both end with anend
.\n if plastic_cup\n print \"Plastic cup is on the up 'n' up!\" \n end\n\n\tIf
\n\n\tplastic_cup
contains eithernil
orfalse
, you won’t see anything print to the screen. They’re not on theif
guest list. Soif
isn’t going to run any of the code it’s protecting.But
\n\n\nnil
andfalse
need not walk away in shame. They may be of questionable character, butunless
runs a smaller establishment that caters to the bedraggled. Theunless
keyword has a policy of only allowing those with a negative charge in. Who are:nil
andfalse
.\n unless plastic_cup\n print \"Plastic cup is on the down low.\" \n end\n\n\tYou can also use
\n\n\nif
andunless
at the end of a single line of code, if that’s all that is being protected.\n print \"Yeah, plastic cup is up again!\" if plastic_cup\n print \"Hardly. It's down.\" unless plastic_cup\n\n\tNow that you’ve met
" diff --git a/vendor/RedCloth-3.0.3/tests/table.yml b/vendor/RedCloth-3.0.3/tests/table.yml new file mode 100644 index 00000000..bf5059e1 --- /dev/null +++ b/vendor/RedCloth-3.0.3/tests/table.yml @@ -0,0 +1,198 @@ +in: | + {background:#ddd}. |S|Target|Complete|App|Milestone| + |!/i/g.gif!|11/18/04|11/18/04|070|XML spec complete| + |!/i/g.gif!|11/29/04|11/29/04|011|XML spec complete (KH is on schedule)| + |!/i/g.gif!|11/29/04|11/29/04|051|XML spec complete (KH is on schedule)| + |!/i/g.gif!|11/29/04|11/29/04|081|XML spec complete (KH is on schedule)| + |!/i/g.gif!|11/19/04|11/22/04|070|Preprocessor complete| + |!/i/g.gif!|11/22/04|11/22/04|070|Dialog pass 1 builds an index file| + |!/i/g.gif!|11/24/04|11/24/04|070|Dialog pass 2 98% complete| + |!/i/g.gif!|11/30/04|11/30/04|070|Feature complete. Passes end-to-end smoke test.| + |!/i/g.gif!|11/30/04|11/30/04|011|Preprocessor updates complete| + |!/i/g.gif!|11/30/04|11/30/04|051|Preprocessor updates complete| + |!/i/g.gif!|11/30/04|11/29/04|081|Preprocessor updates complete| + |!/i/w.gif!|12/02/04|.|011|Dialog pass 1 and 2 complete (98+%)| + |!/i/w.gif!|12/02/04|.|051|Dialog pass 1 and 2 complete (98+%)| + |!/i/w.gif!|12/02/04|.|081|Dialog pass 1 and 2 complete (98+%)| + |!/i/w.gif!|12/03/04|.|011|Feature complete| + |!/i/w.gif!|12/03/04|.|051|Feature complete| + |!/i/w.gif!|12/03/04|.|081|Feature complete| + |!/i/w.gif!|12/10/04|.|011|Deployed to Napa test workstation. Passes smoke test.| + |!/i/w.gif!|12/10/04|.|051|Deployed to Napa test workstation. Passes smoke test.| + |!/i/w.gif!|12/10/04|.|081|Deployed to Napa test workstation. Passes smoke test.| + |!/i/w.gif!|12/10/04|.|070|Deployed to Napa test workstation. Passes smoke test.| + |!/i/w.gif!|12/17/04|.|011|System testing complete. Begin testing with live customer data.| + |!/i/w.gif!|12/17/04|.|051|System testing complete. Begin testing with live customer data.| + |!/i/w.gif!|12/17/04|.|081|System testing complete. Begin testing with live customer data.| + |!/i/w.gif!|12/17/04|.|070|System testing complete. Begin testing with live customer data.| +out: |- +false
, I’m sure you can see what’s on next.+
diff --git a/vendor/redcloth-2.0.11/tests/textism.yml b/vendor/RedCloth-3.0.3/tests/textism.yml old mode 100755 new mode 100644 similarity index 97% rename from vendor/redcloth-2.0.11/tests/textism.yml rename to vendor/RedCloth-3.0.3/tests/textism.yml index cdb0c625..5489c04d --- a/vendor/redcloth-2.0.11/tests/textism.yml +++ b/vendor/RedCloth-3.0.3/tests/textism.yml @@ -114,7 +114,7 @@ in: h3=. centered header out:+ +S +Target +Complete +App +Milestone ++ ++ 11/18/04 +11/18/04 +070 +XML spec complete ++ ++ 11/29/04 +11/29/04 +011 +XML spec complete (KH is on schedule) ++ ++ 11/29/04 +11/29/04 +051 +XML spec complete (KH is on schedule) ++ ++ 11/29/04 +11/29/04 +081 +XML spec complete (KH is on schedule) ++ ++ 11/19/04 +11/22/04 +070 +Preprocessor complete ++ ++ 11/22/04 +11/22/04 +070 +Dialog pass 1 builds an index file ++ ++ 11/24/04 +11/24/04 +070 +Dialog pass 2 98% complete ++ ++ 11/30/04 +11/30/04 +070 +Feature complete. Passes end-to-end smoke test. ++ ++ 11/30/04 +11/30/04 +011 +Preprocessor updates complete ++ ++ 11/30/04 +11/30/04 +051 +Preprocessor updates complete ++ ++ 11/30/04 +11/29/04 +081 +Preprocessor updates complete ++ ++ 12/02/04 +011 +Dialog pass 1 and 2 complete (98+%) ++ ++ 12/02/04 +051 +Dialog pass 1 and 2 complete (98+%) ++ ++ 12/02/04 +081 +Dialog pass 1 and 2 complete (98+%) ++ ++ 12/03/04 +011 +Feature complete ++ ++ 12/03/04 +051 +Feature complete ++ ++ 12/03/04 +081 +Feature complete ++ ++ 12/10/04 +011 +Deployed to Napa test workstation. Passes smoke test. ++ ++ 12/10/04 +051 +Deployed to Napa test workstation. Passes smoke test. ++ ++ 12/10/04 +081 +Deployed to Napa test workstation. Passes smoke test. ++ ++ 12/10/04 +070 +Deployed to Napa test workstation. Passes smoke test. ++ ++ 12/17/04 +011 +System testing complete. Begin testing with live customer data. ++ ++ 12/17/04 +051 +System testing complete. Begin testing with live customer data. ++ ++ 12/17/04 +081 +System testing complete. Begin testing with live customer data. ++ ++ 12/17/04 +070 +System testing complete. Begin testing with live customer data. +centered header
--- in: '!>/image.gif! right-aligned image' -out:+out:
right-aligned image
--- in: p[no]{color:red}. A Norse of a different colour. out:
right-aligned image
A Norse of a different colour.
@@ -255,7 +255,7 @@ in: |- # Yes they do # But you knew that - Some more text of dubious character. Here is a noisome string of CAPITAL letters. Here is something we want to _emphasize_. + Some more text of dubious character. Here is a noisome string of CAPITAL letters. Here is something we want to _emphasize_. That was a linebreak. And something to indicate *strength*. Of course I could use my own HTML tags if I felt like it. h3. Coding @@ -287,13 +287,12 @@ out: |-This is a subhead
This is some text of dubious character. Isn’t the use of “quotes” just lazy writing—and theft of ‘intellectual property’ besides? I think the time has come to see a block quote.
- +This is a block quote. I’ll admit it’s not the most exciting block quote ever devised.
Simple list:
-
- one
- two
@@ -301,7 +300,6 @@ out: |-Multi-level list:
-
- one
' - end - end - unless depth.last == tl - depth << tl - atts = pba( atts ) - lines[line_id] = "\t<#{ lT(tl) }l#{ atts }>\n\t@@ -320,7 +318,6 @@ out: |-
Mixed list:
-
- Point one
- Point two @@ -340,7 +337,7 @@ out: |-
\n\t#{ lT( depth[i] ) }l>\n\t" - depth.pop - end - end - if depth.last.length == tl.length - lines[line_id - 1] << 'Well, that went well. How about we insert an old-fashioned hypertext link? Will the quote marks in the tags get messed up? No!
- ++ +
this @@ -361,23 +358,25 @@ out: |-An image:
-
-
- Librarians rule
- Yes they do
- But you knew that
Some more text of dubious character. Here is a noisome string of CAPITAL letters. Here is something we want to emphasize.
+Some more text of dubious character. Here is a noisome string of CAPITAL letters. Here is something we want to emphasize. That was a linebreak. And something to indicate strength. Of course I could use my own HTML tags if I felt like it.
- +Coding
This
+is some code, "isn't it"
. Watch those quote marks! Now for some preformatted text:-$text = str_replace("<p>%::%</p>","",$text); @@ -386,11 +385,9 @@ out: |-
This isn’t code.
So you see, my friends:
-- - - - diff --git a/vendor/redcloth-2.0.11/RedCloth.gemspec b/vendor/redcloth-2.0.11/RedCloth.gemspec deleted file mode 100755 index 2ff4ab35..00000000 --- a/vendor/redcloth-2.0.11/RedCloth.gemspec +++ /dev/null @@ -1,34 +0,0 @@ -require 'rubygems' -spec = Gem::Specification.new do |s| - - ## Basic Information - - s.name = 'RedCloth' - s.version = "2.0.11" - s.platform = Gem::Platform::RUBY - s.summary = <<-TXT - RedCloth is a module for using Textile in Ruby. Textile is a text format. - A very simple text format. Another stab at making readable text that can be converted to HTML. - TXT - - ## Include tests, libs, docs - - s.files = ['tests/**/*', 'lib/**/*', 'docs/**/*', 'run-tests.rb'].collect do |dirglob| - Dir.glob(dirglob) - end.flatten.delete_if {|item| item.include?("CVS")} - - ## Load-time details - - s.require_path = 'lib' - s.autorequire = 'redcloth' - - ## Author and project details - - s.author = "Why the Lucky Stiff" - s.email = "why@ruby-lang.org" - s.rubyforge_project = "redcloth" - s.homepage = "http://www.whytheluckystiff.net/ruby/redcloth/" -end -if $0==__FILE__ - Gem::Builder.new(spec).build -end diff --git a/vendor/redcloth-2.0.11/lib/redcloth.rb b/vendor/redcloth-2.0.11/lib/redcloth.rb deleted file mode 100755 index 61b2577e..00000000 --- a/vendor/redcloth-2.0.11/lib/redcloth.rb +++ /dev/null @@ -1,894 +0,0 @@ -# vim:ts=4:sw=4: -# = RedCloth - Textile for Ruby -# -# Homepage:: http://whytheluckystiff.net/ruby/redcloth/ -# Author:: why the lucky stiff (http://whytheluckystiff.net/) -# Copyright:: (c) 2004 why the lucky stiff (and his puppet organizations.) -# License:: BSD -# -# (see http://hobix.com/textile/ for a Textile Reference.) -# -# Based on (and also inspired by) both: -# -# PyTextile: http://diveintomark.org/projects/textile/textile.py.txt -# Textism for PHP: http://www.textism.com/tools/textile/ -# -# - -class String - # - # Flexible HTML escaping - # - def htmlesc!( mode ) - gsub!( '&', '&' ) - gsub!( '"', '"' ) if mode != :NoQuotes - gsub!( "'", ''' ) if mode == :Quotes - gsub!('<', '<') - gsub!('>', '>') - end -end - -# = RedCloth -# -# RedCloth is a Ruby library for converting Textile -# into HTML. -# -# == What is Textile? -# -# Textile is a simple formatting style for text -# documents, loosely based on some HTML conventions. -# -# == Sample Textile Text -# -# h2. This is a title -# -# h3. This is a subhead -# -# This is a bit of paragraph. -# -# bq. This is a blockquote. -# -# = Writing Textile -# -# A Textile document consists of paragraphs. Paragraphs -# can be specially formatted by adding a small instruction -# to the beginning of the paragraph. -# -# h[n]. Header of size [n]. -# bq. Blockquote. -# # Numeric list. -# * Bulleted list. -# -# == Quick Phrase Modifiers -# -# Quick phrase modifiers are also included, to allow formatting -# of small portions of text within a paragraph. -# -# \_emphasis\_ -# \_\_italicized\_\_ -# \*strong\* -# \*\*bold\*\* -# ??citation?? -# -deleted text- -# +inserted text+ -# ^superscript^ -# ~subscript~ -# @code@ -# %(classname)span% -# -# ==notextile== (leave text alone) -# -# == Links -# -# To make a hypertext link, put the link text in "quotation -# marks" followed immediately by a colon and the URL of the link. -# -# Optional: text in (parentheses) following the link text, -# but before the closing quotation mark, will become a Title -# attribute for the link, visible as a tool tip when a cursor is above it. -# -# Example: -# -# "This is a link (This is a title) ":http://www.textism.com -# -# Will become: -# -# This is a link -# -# == Images -# -# To insert an image, put the URL for the image inside exclamation marks. -# -# Optional: text that immediately follows the URL in (parentheses) will -# be used as the Alt text for the image. Images on the web should always -# have descriptive Alt text for the benefit of readers using non-graphical -# browsers. -# -# Optional: place a colon followed by a URL immediately after the -# closing ! to make the image into a link. -# -# Example: -# -# !http://www.textism.com/common/textist.gif(Textist)! -# -# Will become: -# -#
- The time is now
- The time is not later
@@ -398,7 +395,3 @@ out: |-- We must act
-# -# With a link: -# -# !/common/textist.gif(Textist)!:http://textism.com -# -# Will become: -# -#
-# -# == Defining Acronyms -# -# HTML allows authors to define acronyms via the tag. The definition appears as a -# tool tip when a cursor hovers over the acronym. A crucial aid to clear writing, -# this should be used at least once for each acronym in documents where they appear. -# -# To quickly define an acronym in Textile, place the full text in (parentheses) -# immediately following the acronym. -# -# Example: -# -# ACLU(American Civil Liberties Union) -# -# Will become: -# -# ACLU -# -# == Adding Tables -# -# In Textile, simple tables can be added by seperating each column by -# a pipe. -# -# |a|simple|table|row| -# |And|Another|table|row| -# -# Attributes are defined by style definitions in parentheses. -# -# table(border:1px solid black). -# (background:#ddd;color:red). |{}| | | | -# -# == Using RedCloth -# -# RedCloth is simply an extension of the String class, which can handle -# Textile formatting. Use it like a String and output HTML with its -# RedCloth#to_html method. -# -# doc = RedCloth.new " -# -# h2. Test document -# -# Just a simple test." -# -# puts doc.to_html - -class RedCloth < String - - VERSION = '2.0.11' - - # - # Two accessor for setting security restrictions. - # - # This is a nice thing if you're using RedCloth for - # formatting in public places (e.g. Wikis) where you - # don't want users to abuse HTML for bad things. - # - # If +:filter_html+ is set, HTML which wasn't - # created by the Textile processor will be escaped. - # - # If +:filter_styles+ is set, it will also disable - # the style markup specifier. ('{color: red}') - # - attr_accessor :filter_html, :filter_styles - - # - # Accessor for toggling line folding. - # - # If +:fold_lines+ is set, single newlines will - # not be converted to break tags. - # - attr_accessor :fold_lines - - # - # Returns a new RedCloth object, based on _string_ and - # enforcing all the included _restrictions_. - # - # r = RedCloth.new( "h1. A bold man", [:filter_html] ) - # r.to_html - # #=>"
A <b>bold</b> man
" - # - def initialize( string, restrictions = [] ) - @lite = false - restrictions.each { |r| method( "#{ r }=" ).call( true ) } - super( string ) - end - - # - # Generates HTML from the Textile contents. The _lite_ flag - # may be used to honor only inline markup, ignoring lists, tables, - # and block formatting. - # - # r = RedCloth.new( "And then? She *fell*!" ) - # r.to_html( true ) - # #=>"And then? She fell!" - # - def to_html( lite = nil ) - - @lite = lite unless lite.nil? - - # make our working copy - text = self.dup - - @urlrefs = {} - @shelf = [] - - incoming_entities text - ## encode_entities text - ## fix_entities text - clean_white_space text - - get_refs text - - no_textile text - - inline text - - unless @lite - fold text - block text - end - - retrieve text - - text.gsub!( /<\/?notextile>/, '' ) - text.gsub!( /x%x%/, '&' ) - text.gsub!( /
/, "
\n" ) - text.strip! - text - - end - - ####### - private - ####### - # - # Mapping of 8-bit ASCII codes to HTML numerical entity equivalents. - # (from PyTextile) - # - TEXTILE_TAGS = - - [[128, 8364], [129, 0], [130, 8218], [131, 402], [132, 8222], [133, 8230], - [134, 8224], [135, 8225], [136, 710], [137, 8240], [138, 352], [139, 8249], - [140, 338], [141, 0], [142, 0], [143, 0], [144, 0], [145, 8216], [146, 8217], - [147, 8220], [148, 8221], [149, 8226], [150, 8211], [151, 8212], [152, 732], - [153, 8482], [154, 353], [155, 8250], [156, 339], [157, 0], [158, 0], [159, 376]]. - - collect! do |a, b| - [a.chr, ( b.zero? and "" or "{ b };" )] - end - - # - # Regular expressions to convert to HTML. - # - A_HLGN = /(?:(?:<>|<|>|\=|[()]+)+)/ - A_VLGN = /[\-^~]/ - C_CLAS = '(?:\([^)]+\))' - C_LNGE = '(?:\[[^\]]+\])' - C_STYL = '(?:\{[^}]+\})' - S_CSPN = '(?:\\\\\d+)' - S_RSPN = '(?:/\d+)' - A = "(?:#{A_HLGN}?#{A_VLGN}?|#{A_VLGN}?#{A_HLGN}?)" - S = "(?:#{S_CSPN}?#{S_RSPN}|#{S_RSPN}?#{S_CSPN}?)" - C = "(?:#{C_CLAS}?#{C_STYL}?#{C_LNGE}?|#{C_STYL}?#{C_LNGE}?#{C_CLAS}?|#{C_LNGE}?#{C_STYL}?#{C_CLAS}?)" - # PUNCT = Regexp::quote( '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~' ) - PUNCT = Regexp::quote( '!"#$%&\'*+,-./:;=?@\\^_`|~' ) - HYPERLINK = '(\S+?)([^\w\s/;=\?]*?)(\s|$)' - - GLYPHS = [ - # [ /([^\s\[{(>])?\'([dmst]\b|ll\b|ve\b|\s|:|$)/, '\1’\2' ], # single closing - [ /([^\s\[{(>])\'/, '\1’' ], # single closing - [ /\'(?=\s|s\b|[#{PUNCT}])/, '’' ], # single closing - [ /\'/, '‘' ], # single opening - # [ /([^\s\[{(])?"(\s|:|$)/, '\1”\2' ], # double closing - [ /([^\s\[{(>])"/, '\1”' ], # double closing - [ /"(?=\s|[#{PUNCT}])/, '”' ], # double closing - [ /"/, '“' ], # double opening - [ /\b( )?\.{3}/, '\1…' ], # ellipsis - [ /\b([A-Z][A-Z0-9]{2,})\b(?:[(]([^)]*)[)])/, '\1' ], # 3+ uppercase acronym - [ /(^|[^"][>\s])([A-Z][A-Z0-9 ]{2,})([^\2\3' ], # 3+ uppercase caps - [ /(\.\s)?\s?--\s?/, '\1—' ], # em dash - [ /\s->\s/, ' → ' ], # en dash - [ /\s-\s/, ' – ' ], # en dash - [ /(\d+) ?x ?(\d+)/, '\1×\2' ], # dimension sign - [ /\b ?[(\[]TM[\])]/i, '™' ], # trademark - [ /\b ?[(\[]R[\])]/i, '®' ], # registered - [ /\b ?[(\[]C[\])]/i, '©' ] # copyright - ] - - I_ALGN_VALS = { - '<' => 'left', - '=' => 'center', - '>' => 'right' - } - - H_ALGN_VALS = { - '<' => 'left', - '=' => 'center', - '>' => 'right', - '<>' => 'justify' - } - - V_ALGN_VALS = { - '^' => 'top', - '-' => 'middle', - '~' => 'bottom' - } - - QTAGS = [ - ['**', 'b'], - ['*', 'strong'], - ['??', 'cite'], - ['-', 'del'], - ['__', 'i'], - ['_', 'em'], - ['%', 'span'], - ['+', 'ins'], - ['^', 'sup'], - ['~', 'sub'] - ].collect do |rc, ht| - ttr = Regexp.quote(rc) - punct = PUNCT.sub( Regexp::quote(rc), '' ) - re = /(^|[\s\>#{punct}{(\[]) - #{ttr} - (#{C}) - (?::(\S+?))? - ([^\s#{ttr}]+?(?:[^\n]|\n(?!\n))*?) - ([#{punct}]*?) - #{ttr} - (?=[\s\])}<#{punct}]|$)/xm - [re, ht] - end - - def pgl( text ) - GLYPHS.each do |re, resub| - text.gsub! re, resub - end - end - - def pba( text_in, element = "" ) - - return '' unless text_in - - style = [] - text = text_in.dup - if element == 'td' - colspan = $1 if text =~ /\\(\d+)/ - rowspan = $1 if text =~ /\/(\d+)/ - style << "vertical-align:#{ v_align( $& ) };" if text =~ A_VLGN - end - - style << "#{ $1 };" if not @filter_styles and - text.sub!( /\{([^}]*)\}/, '' ) - - lang = $1 if - text.sub!( /\[([^)]+?)\]/, '' ) - - cls = $1 if - text.sub!( /\(([^()]+?)\)/, '' ) - - style << "padding-left:#{ $1.length }em;" if - text.sub!( /([(]+)/, '' ) - - style << "padding-right:#{ $1.length }em;" if text.sub!( /([)]+)/, '' ) - - style << "text-align:#{ h_align( $& ) };" if text =~ A_HLGN - - cls, id = $1, $2 if cls =~ /^(.*?)#(.*)$/ - - atts = '' - atts << " style=\"#{ style.join }\"" unless style.empty? - atts << " class=\"#{ cls }\"" unless cls.to_s.empty? - atts << " lang=\"#{ lang }\"" if lang - atts << " id=\"#{ id }\"" if id - atts << " colspan=\"#{ colspan }\"" if colspan - atts << " rowspan=\"#{ rowspan }\"" if rowspan - - atts - end - - TABLE_RE = /^(?:table(_?#{S}#{A}#{C})\. ?\n)?^(#{A}#{C}\.? ?\|.*?\|)(\n\n|\Z)/m - - def table( text ) - text.gsub!( TABLE_RE ) do |matches| - - tatts, fullrow = $~[1..2] - tatts = pba( tatts, 'table' ) - rows = [] - - fullrow. - split( /\|$/m ). - delete_if { |x| x.empty? }. - each do |row| - - ratts, row = pba( $1, 'tr' ), $2 if row =~ /^(#{A}#{C}\. )(.*)/m - - cells = [] - row.split( '|' ).each do |cell| - ctyp = 'd' - ctyp = 'h' if cell =~ /^_/ - - catts = '' - catts, cell = pba( $1, 'td' ), $2 if cell =~ /^(_?#{S}#{A}#{C}\. )(.*)/ - - unless cell.strip.empty? - cells << "\t\t\t #{ cell } " - end - end - rows << "\t\t\n#{ cells.join( "\n" ) }\n\t\t " - end - "\t\n#{ rows.join( "\n" ) }\n\t
\n\n" - end - end - - LISTS_RE = /^([#*]+?#{C} .*?)$(?![^#*])/m - LISTS_CONTENT_RE = /^([#*]+)(#{A}#{C}) (.*)$/m - - def lists( text ) - text.gsub!( LISTS_RE ) do |match| - lines = match.split( /\n/ ) - last_line = -1 - depth = [] - lines.each_with_index do |line, line_id| - if line =~ LISTS_CONTENT_RE - tl,atts,content = $~[1..3] - if depth.last - if depth.last.length > tl.length - (depth.length - 1).downto(0) do |i| - break if depth[i].length == tl.length - lines[line_id - 1] << "- #{ content }" - else - lines[line_id] = "\t\t
- #{ content }" - end - last_line = line_id - - elsif line =~ /^\s+\S/ - last_line = line_id - elsif line_id - last_line < 2 and line =~ /^\S/ - last_line = line_id - end - if line_id - last_line > 1 or line_id == lines.length - 1 - depth.delete_if do |v| - lines[last_line] << "
\n\t#{ lT( v ) }l>" - end - end - end - lines.join( "\n" ) - end - end - - def lT( text ) - text =~ /\#$/ ? 'o' : 'u' - end - - def fold( text ) - text.gsub!( /(.+)\n(?![#*\s|])/, "\\1#{ @fold_lines ? ' ' : '
' }" ) - end - - BLOCK_RE = ['bq','h[1-6]','fn\d+','p'].collect!{|stag| - [stag, - /^(#{ stag })(#{A}#{C})\.(?::(\S+))? (.*)$/] - } - - def block( text ) - pre = false - find = ['bq','h[1-6]','fn\d+','p'] - - lines = text.split( /\n/ ) + [' '] - new_text = - lines.collect do |line| - pre = true if line =~ /<(pre|notextile)[^>]*>/i - BLOCK_RE.each do |stag, ctag| - line.gsub!( ctag ) do |m| - tag,atts,cite,content = $~[1..4] - - atts = pba( atts ) - - if tag =~ /fn(\d+)/ - tag = 'p'; - atts << " id=\"fn#{ $1 }\"" - content = "#{ $1 } #{ content }" - end - - start = "\t<#{ tag }" - tend = "#{ tag }>" - - if tag == "bq" - cite = check_refs( cite ) - cite = " cite=\"#{ cite }\"" if cite - start = "\t\n\t\t#{ content }#{ tend }" - end unless pre - end - - line.gsub!( /^(?!\t|<\/?div|<\/?pre|<\/?notextile|<\/?code|$| )(.*)/, "\t
\\1
" ) unless pre - - line.gsub!( "
", "\n" ) if pre - pre = false if line =~ /<\/(pre|notextile)>/i - - line - end.join( "\n" ) - text.replace( new_text ) - end - - def span( text ) - QTAGS.each do |ttr, ht| - text.gsub!(ttr) do |m| - - start,atts,cite,content,tend = $~[1..5] - atts = pba( atts ) - atts << " cite=\"#{ cite }\"" if cite - - "#{ start }<#{ ht }#{ atts }>#{ content }#{ tend }#{ ht }>" - - end - end - end - - LINK_RE = / - ([\s\[{(]|[#{PUNCT}])? # $pre - " # start - (#{C}) # $atts - ([^"]+?) # $text - \s? - (?:\(([^)]+?)\)(?="))? # $title - ": - (\S+?) # $url - (\/)? # $slash - ([^\w\/;]*?) # $post - (?=<|\s|$) - /x - - def links( text ) - text.gsub!( LINK_RE ) do |m| - pre,atts,text,title,url,slash,post = $~[1..7] - - url = check_refs( url ) - - atts = pba( atts ) - atts << " title=\"#{ title }\"" if title - atts = shelve( atts ) if atts - - "#{ pre }#{ text }#{ post }" - end - end - - REFS_RE = /(^|\s)\[(.+?)\]((?:http:\/\/|javascript:|ftp:\/\/|\/)\S+?)(?=\s|$)/ - - def get_refs( text ) - text.gsub!( REFS_RE ) do |m| - flag, url = $~[2..3] - @urlrefs[flag] = url - nil - end - end - - def check_refs( text ) - @urlrefs[text] || text - end - - IMAGE_RE = / - \! # opening - (\<|\=|\>)? # optional alignment atts - (#{C}) # optional style,class atts - (?:\. )? # optional dot-space - ([^\s(!]+?) # presume this is the src - \s? # optional space - (?:\(((?:[^\(\)]|\([^\)]+\))+?)\))? # optional title - \! # closing - (?::#{ HYPERLINK })? # optional href - /x - - def image( text ) - text.gsub!( IMAGE_RE ) do |m| - algn,atts,url,title,href,href_a1,href_a2 = $~[1..7] - atts = pba( atts ) - atts << " align=\"#{ i_align( algn ) }\"" if algn - atts << " title=\"#{ title }\"" if title - atts << " alt=\"#{ title }\"" - # size = @getimagesize($url); - # if($size) $atts.= " $size[3]"; - - href = check_refs( href ) if href - url = check_refs( url ) - atts << " border=\"0\"" if href - - out = '' - out << "" if href - out << "" - out << "#{ href_a1 }#{ href_a2 }" if href - - out - end - end - - CODE_RE = / - (^|[\s>#{PUNCT}{(\[]) # 1 open bracket? - @ # opening - (?:\|(\w+?)\|)? # 2 language - (\S(?:[^\n]|\n(?!\n))*?) # 3 code - @ # closing - (?=[\s\]}\)<#{PUNCT}]|$) # 4 closing bracket? - /x - - def code( text ) - text.gsub!( CODE_RE ) do |m| - before,lang,code,after = $~[1..4] - lang = " language=\"#{ lang }\"" if lang - "#{ before }
#{ code }
#{ after }" - end - end - - def shelve( val ) - @shelf << val - " <#{ @shelf.length }>" - end - - def retrieve( text ) - @shelf.each_with_index do |r, i| - text.gsub!( " <#{ i + 1 }>", r ) - end - end - - def incoming_entities( text ) - ## turn any incoming ampersands into a dummy character for now. - ## This uses a negative lookahead for alphanumerics followed by a semicolon, - ## implying an incoming html entity, to be skipped - - text.gsub!( /&(?![#a-z0-9]+;)/i, "x%x%" ) - end - - def encode_entities( text ) - ## Convert high and low ascii to entities. - # if $-K == "UTF-8" - # encode_high( text ) - # else - text.htmlesc!( :NoQuotes ) - # end - end - - def fix_entities( text ) - ## de-entify any remaining angle brackets or ampersands - text.gsub!( ">", ">" ) - text.gsub!( "<", "<" ) - text.gsub!( "&", "&" ) - end - - def clean_white_space( text ) - text.gsub!( /\r\n/, "\n" ) - text.gsub!( /\t/, '' ) - text.gsub!( /\n{3,}/, "\n\n" ) - text.gsub!( /\n *\n/, "\n\n" ) - text.gsub!( /"$/, "\" " ) - end - - def no_textile( text ) - text.gsub!( /(^|\s)==(.*?)==(\s|$)?/, - '\1\2 \3' ) - end - - def footnote_ref( text ) - text.gsub!( /\b\[([0-9]+?)\](\s)?/, - '\1\2' ) - end - - OFFTAGS = /(code|pre|kbd|notextile)/ - OFFTAG_MATCH = /(?:(<\/#{ OFFTAGS }>)|(<#{ OFFTAGS }[^>]*>))(.*?)(?=<\/?#{ OFFTAGS }>|\Z)/mi - OFFTAG_OPEN = /<#{ OFFTAGS }/ - OFFTAG_CLOSE = /<\/?#{ OFFTAGS }/ - HASTAG_MATCH = /(<\/?\w[^\n]*?>)/m - ALLTAG_MATCH = /(<\/?\w[^\n]*?>)|.*?(?=<\/?\w[^\n]*?>|$)/m - - def glyphs( text, level = 0 ) - if text !~ HASTAG_MATCH - pgl text - footnote_ref text - else - codepre = 0 - text.gsub!( ALLTAG_MATCH ) do |line| - ## matches are off if we're between,
etc. - if $1 - if @filter_html - line.htmlesc!( :NoQuotes ) - elsif line =~ OFFTAG_OPEN - codepre += 1 - elsif line =~ OFFTAG_CLOSE - codepre -= 1 - codepre = 0 if codepre < 0 - end - ## do htmlspecial if between- elsif codepre.zero? - glyphs( line, level + 1 ) - else - line.htmlesc!( :NoQuotes ) - end - ## p [level, codepre, orig_line, line] - - line - end - end - end - - def rip_offtags( text ) - pre_list = [] - if text =~ /<.*>/ - ## strip and encode
content - codepre, used_offtags = 0, {} - text.gsub!( OFFTAG_MATCH ) do |line| - if $3 - offtag, aftertag = $4, $5 - codepre += 1 - used_offtags[offtag] = true - if codepre - used_offtags.length > 0 - line.htmlesc!( :NoQuotes ) - pre_list.last << line - line = "" - else - aftertag.htmlesc!( :NoQuotes ) if aftertag - line = "" - pre_list << "#{ $3 }#{ aftertag }" - end - elsif $1 and codepre > 0 - if codepre - used_offtags.length > 0 - line.htmlesc!( :NoQuotes ) - pre_list.last << line - line = "" - end - codepre -= 1 unless codepre.zero? - used_offtags = {} if codepre.zero? - end - line - end - end - pre_list - end - - def smooth_offtags( text, pre_list ) - unless pre_list.empty? - ## replace content - text.gsub!( /- - - If @plastic_cup@ contains either @nil@ or @false@, you won't see anything print - to the screen. They're not on the @if@ guest list. So @if@ isn't going to run - any of the code it's protecting. - - - But @nil@ and @false@ need not walk away in shame. They may be of questionable - character, but @unless@ runs a smaller establishment that caters to the bedraggled. - The @unless@ keyword has a policy of only allowing those with a negative charge in. - Who are: @nil@ and @false@. - - -/ ) { pre_list[$1.to_i] } - end - end - - def inline( text ) - text.gsub!( /"\z/, "\" " ) - pre_list = rip_offtags text - - ## apply inline markup - unless @lite - lists text - table text - end - - image text - links text - code text - span text - - ## replace entities - glyphs text - smooth_offtags text, pre_list - end - - def i_align( text ) - I_ALGN_VALS[text] - end - - def h_align( text ) - H_ALGN_VALS[text] - end - - def v_align( text ) - V_ALGN_VALS[text] - end - - def encode_high( text ) - ## mb_encode_numericentity($text, $cmap, $charset); - end - - def decode_high( text ) - ## mb_decode_numericentity($text, $cmap, $charset); - end - - def textile_popup_help( name, helpvar, windowW, windowH ) - ' ' + name + '
' - end - - CMAP = [ - 160, 255, 0, 0xffff, - 402, 402, 0, 0xffff, - 913, 929, 0, 0xffff, - 931, 937, 0, 0xffff, - 945, 969, 0, 0xffff, - 977, 978, 0, 0xffff, - 982, 982, 0, 0xffff, - 8226, 8226, 0, 0xffff, - 8230, 8230, 0, 0xffff, - 8242, 8243, 0, 0xffff, - 8254, 8254, 0, 0xffff, - 8260, 8260, 0, 0xffff, - 8465, 8465, 0, 0xffff, - 8472, 8472, 0, 0xffff, - 8476, 8476, 0, 0xffff, - 8482, 8482, 0, 0xffff, - 8501, 8501, 0, 0xffff, - 8592, 8596, 0, 0xffff, - 8629, 8629, 0, 0xffff, - 8656, 8660, 0, 0xffff, - 8704, 8704, 0, 0xffff, - 8706, 8707, 0, 0xffff, - 8709, 8709, 0, 0xffff, - 8711, 8713, 0, 0xffff, - 8715, 8715, 0, 0xffff, - 8719, 8719, 0, 0xffff, - 8721, 8722, 0, 0xffff, - 8727, 8727, 0, 0xffff, - 8730, 8730, 0, 0xffff, - 8733, 8734, 0, 0xffff, - 8736, 8736, 0, 0xffff, - 8743, 8747, 0, 0xffff, - 8756, 8756, 0, 0xffff, - 8764, 8764, 0, 0xffff, - 8773, 8773, 0, 0xffff, - 8776, 8776, 0, 0xffff, - 8800, 8801, 0, 0xffff, - 8804, 8805, 0, 0xffff, - 8834, 8836, 0, 0xffff, - 8838, 8839, 0, 0xffff, - 8853, 8853, 0, 0xffff, - 8855, 8855, 0, 0xffff, - 8869, 8869, 0, 0xffff, - 8901, 8901, 0, 0xffff, - 8968, 8971, 0, 0xffff, - 9001, 9002, 0, 0xffff, - 9674, 9674, 0, 0xffff, - 9824, 9824, 0, 0xffff, - 9827, 9827, 0, 0xffff, - 9829, 9830, 0, 0xffff, - 338, 339, 0, 0xffff, - 352, 353, 0, 0xffff, - 376, 376, 0, 0xffff, - 710, 710, 0, 0xffff, - 732, 732, 0, 0xffff, - 8194, 8195, 0, 0xffff, - 8201, 8201, 0, 0xffff, - 8204, 8207, 0, 0xffff, - 8211, 8212, 0, 0xffff, - 8216, 8218, 0, 0xffff, - 8218, 8218, 0, 0xffff, - 8220, 8222, 0, 0xffff, - 8224, 8225, 0, 0xffff, - 8240, 8240, 0, 0xffff, - 8249, 8250, 0, 0xffff, - 8364, 8364, 0, 0xffff - ] -end - diff --git a/vendor/redcloth-2.0.11/tests/poignant.yml b/vendor/redcloth-2.0.11/tests/poignant.yml deleted file mode 100755 index 5e773373..00000000 --- a/vendor/redcloth-2.0.11/tests/poignant.yml +++ /dev/null @@ -1,64 +0,0 @@ ---- # Tests from the (Poignant Guide) -in: > - h3. False - - - ! - if plastic_cup - print "Plastic cup is on the up 'n' up!" - end -- unless plastic_cup - print "Plastic cup is on the down low." - end -- - - You can also use @if@ and @unless@ at the end of a single line of code, if that's - all that is being protected. - - -- print "Yeah, plastic cup is up again!" if plastic_cup - print "Hardly. It's down." unless plastic_cup -- - - Now that you've met @false@, I'm sure you can see what's on next. - -out: "False
\n\n\t\n\n\t
The cat Trady Blix. Frozen in emptiness. Immaculate whiskers rigid. Placid eyes of lake. Tail of warm icicle. Sponsored by a Very Powerful Pause Button.
\n\n\tThe darkness surrounding Blix can be called negative space. Hang on to that phrase. Let it suggest that the emptiness has a negative connotation. In a similar way,
\n\n\tnil
has a slightly sour note that it whistles.Generally speaking, everything in Ruby has a positive charge to it. This spark flows through strings, numbers, regexps, all of it. Only two keywords wear a shady cloak:
\n\n\tnil
andfalse
draggin us down.You can test that charge with an
\n\nif
keyword. It looks very much like thedo
blocks we saw in the last chapter, in that both end with anend
.\n if plastic_cup\n print \"Plastic cup is on the up 'n' up!\" \n end\n\n\n\tIf
\n\n\tplastic_cup
contains eithernil
orfalse
, you won’t see anything print to the screen. They’re not on theif
guest list. Soif
isn’t going to run any of the code it’s protecting.But
\n\nnil
andfalse
need not walk away in shame. They may be of questionable character, butunless
runs a smaller establishment that caters to the bedraggled. Theunless
keyword has a policy of only allowing those with a negative charge in. Who are:nil
andfalse
.\n unless plastic_cup\n print \"Plastic cup is on the down low.\" \n end\n\n\n\tYou can also use
\n\nif
andunless
at the end of a single line of code, if that’s all that is being protected.\n print \"Yeah, plastic cup is up again!\" if plastic_cup\n print \"Hardly. It's down.\" unless plastic_cup\n\n\n\tNow that you’ve met
"false
, I’m sure you can see what’s on next.
\n