From 2382acb9f10bec86c227fbd576a682d593053802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Sat, 26 Apr 2008 17:25:48 +0200 Subject: [PATCH] split groups of test samples into several files --- spec/markdown_spec.rb | 8 +- spec/sample_loader.rb | 123 +++--- spec/samples/all | 902 ------------------------------------------ spec/samples/code | 177 +++++++++ spec/samples/emphasis | 152 +++++++ spec/samples/links | 153 +++++++ spec/samples/lists | 248 ++++++++++++ spec/samples/titles | 240 +++++++++++ 8 files changed, 1036 insertions(+), 967 deletions(-) create mode 100644 spec/samples/code create mode 100644 spec/samples/emphasis create mode 100644 spec/samples/links create mode 100644 spec/samples/lists create mode 100644 spec/samples/titles diff --git a/spec/markdown_spec.rb b/spec/markdown_spec.rb index 42a3085..6610f3e 100644 --- a/spec/markdown_spec.rb +++ b/spec/markdown_spec.rb @@ -6,16 +6,16 @@ extend SampleLoader it "should render HTML without trailing newline" do - BlueCloth.new('Foo').to_html.should == '

Foo

' + markdown('Foo').should == '

Foo

' end it "should not swallow trailing newline" do pending - BlueCloth.new("Foo\n").to_html.should == "

Foo

\n" + markdown("Foo\n").should == "

Foo

\n" end describe 'sample:' do - load_samples('all') do |sample| + load_samples('all', 'code', 'titles', 'emphasis', 'links', 'lists') do |sample| it(sample.comment) { sample.should render } end @@ -90,7 +90,7 @@ def matches?(sample) end def failure_message - "%s (line %d):\n<<<\n%s\n---\n%s\n>>>\n%s\n===" % [ + "%s (line %d):\n<<< input:\n%s\n--- expected:\n%s\n>>> actual:\n%s\n===" % [ @sample.comment, @sample.line, @sample.input, @sample.output, diff --git a/spec/sample_loader.rb b/spec/sample_loader.rb index e8756e5..b893c13 100644 --- a/spec/sample_loader.rb +++ b/spec/sample_loader.rb @@ -1,77 +1,78 @@ module SampleLoader protected - def load_samples(name, &block) - samples_file = File.dirname(__FILE__) + '/samples/' + name - raise ArgumentError, %[no samples file for "#{name}"] unless File.exists? samples_file + def load_samples(*names, &block) + @sections ||= Hash.new { |h, k| h[k] = [] } + loaded_samples = [] - meta_space = true - section = section_name = sample = nil - linenum = 0 - - @sections = Hash.new { |h, k| h[k] = [] } + for name in names + samples_file = File.dirname(__FILE__) + '/samples/' + name + unless File.exists? samples_file + $stderr.puts %[WARNING: no samples file for "#{name}"] + next + end + + meta_space = true + section = section_name = sample = nil + linenum = 0 - begin - File.foreach(samples_file) do |line| - linenum += 1 + begin + File.foreach(samples_file) do |line| + linenum += 1 - # Start off in the meta section, which has sections and - # descriptions. - if meta_space - case line - # Left angles switch into data section for the current section - # and description. - when /^<<>>/ + section = @sections['[no name]'] unless section + section << sample + loaded_samples << sample + sample = nil + meta_space = true + # 3-Dashed divider with text divides input from output + when /^--- (.+)/ + sample.end_input + # Anything else adds to either input or output else - sample.comment << $1.chomp + sample << line end end - # Data section has input and expected output parts - else - case line - # Right angles terminate a data section, at which point we - # should have enough data to add a test. - when /^>>>/ - unless section - section = @sections['[no name]'] - end - section << sample - sample = nil - meta_space = true - # 3-Dashed divider with text divides input from output - when /^--- (.+)/ - sample.end_input - # Anything else adds to either input or output - else - sample << line - end end + rescue + $stderr.puts "error while processing line #{linenum}" + raise $! end - rescue - $stderr.puts "error while processing line #{linenum}" - raise $! end - if block_given? - @sections.values.each do |samples| - samples.each &block - end - end + loaded_samples.each &block if block_given? end class Sample diff --git a/spec/samples/all b/spec/samples/all index 9b56c37..5400a9b 100644 --- a/spec/samples/all +++ b/spec/samples/all @@ -265,187 +265,6 @@ preserved, and part of it emphasized.

-### [Code spans] - -# Single backtick -<<< -Making `code` work for you ---- Should become: -

Making code work for you

->>> - -# Literal backtick with doubling -<<< -Making `` `code` `` work for you ---- Should become: -

Making `code` work for you

->>> - -# Many repetitions -<<< -Making `````code````` work for you ---- Should become: -

Making code work for you

->>> - -# Two in a row -<<< -This `thing` should be `two` spans. ---- Should become: -

This thing should be two spans.

->>> - -# At the beginning of a newline -<<< -I should think that the -`tar` command would be universal. ---- Should become: -

I should think that the -tar command would be universal.

->>> - -# Entity escaping -<<< -The left angle-bracket (`<`) can also be written as a decimal-encoded -(`<`) or hex-encoded (`<`) entity. ---- Should become: -

The left angle-bracket (&lt;) can also be written as a decimal-encoded -(&#060;) or hex-encoded (&#x3c;) entity.

->>> - -# At the beginning of a document (Bug #525) -<<< -`world` views ---- Should become: -

world views

->>> - - - - -### [Code blocks] - -# Para plus code block (literal tab) -<<< -This is a chunk of code: - - some.code > some.other_code - -Some stuff. ---- Should become: -

This is a chunk of code:

- -
some.code > some.other_code
-
- -

Some stuff.

->>> - -# Para plus code block (literal tab, no colon) -<<< -This is a chunk of code - - some.code > some.other_code - -Some stuff. ---- Should become: -

This is a chunk of code

- -
some.code > some.other_code
-
- -

Some stuff.

->>> - -# Para plus code block (tab-width spaces) -<<< -This is a chunk of code: - - some.code > some.other_code - -Some stuff. ---- Should become: -

This is a chunk of code:

- -
some.code > some.other_code
-
- -

Some stuff.

->>> - -# Para plus code block (tab-width spaces, no colon) -<<< -This is a chunk of code - - some.code > some.other_code - -Some stuff. ---- Should become: -

This is a chunk of code

- -
some.code > some.other_code
-
- -

Some stuff.

->>> - -# Colon with preceeding space -<<< -A regular paragraph, without a colon. : - - This is a code block. - -Some stuff. ---- Should become: -

A regular paragraph, without a colon. :

- -
This is a code block.
-
- -

Some stuff.

->>> - -# Single colon -<<< -: - - some.code > some.other_code - -Some stuff. ---- Should become: -

:

- -
some.code > some.other_code
-
- -

Some stuff.

->>> - -# Preserve leading whitespace (Bug #541) -<<< -Examples: - - # (Waste character because first line is flush left !!!) - # Example script1 - x = 1 - x += 1 - puts x - -Some stuff. ---- Should become: -

Examples:

- -
      # (Waste character because first line is flush left !!!)
-      # Example script1
-      x = 1
-      x += 1
-      puts x
-
- -

Some stuff.

->>> - - ### [Horizontal Rules] # Hrule 1 @@ -484,203 +303,6 @@ Some stuff. >>> -### [Titles] - -# setext-style h1 -<<< -Title Text -= ---- Should become: -

Title Text

->>> - -<<< -Title Text -=== ---- Should become: -

Title Text

->>> - -<<< -Title Text -========== ---- Should become: -

Title Text

->>> - -# setext-style h2 -<<< -Title Text -- ---- Should become: -

Title Text

->>> - -<<< -Title Text ---- ---- Should become: -

Title Text

->>> - -<<< -Title Text ----------- ---- Should become: -

Title Text

->>> - -# ATX-style h1 -<<< -# Title Text ---- Should become: -

Title Text

->>> - -<<< -# Title Text # ---- Should become: -

Title Text

->>> - -<<< -# Title Text ### ---- Should become: -

Title Text

->>> - -<<< -# Title Text ##### ---- Should become: -

Title Text

->>> - -# ATX-style h2 -<<< -## Title Text ---- Should become: -

Title Text

->>> - -<<< -## Title Text # ---- Should become: -

Title Text

->>> - -<<< -## Title Text ### ---- Should become: -

Title Text

->>> - -<<< -## Title Text ##### ---- Should become: -

Title Text

->>> - -# ATX-style h3 -<<< -### Title Text ---- Should become: -

Title Text

->>> - -<<< -### Title Text # ---- Should become: -

Title Text

->>> - -<<< -### Title Text ### ---- Should become: -

Title Text

->>> - -<<< -### Title Text ##### ---- Should become: -

Title Text

->>> - -# ATX-style h4 -<<< -#### Title Text ---- Should become: -

Title Text

->>> - -<<< -#### Title Text # ---- Should become: -

Title Text

->>> - -<<< -#### Title Text ### ---- Should become: -

Title Text

->>> - -<<< -#### Title Text ##### ---- Should become: -

Title Text

->>> - -# ATX-style h5 -<<< -##### Title Text ---- Should become: -
Title Text
->>> - -<<< -##### Title Text # ---- Should become: -
Title Text
->>> - -<<< -##### Title Text ### ---- Should become: -
Title Text
->>> - -<<< -##### Title Text ##### ---- Should become: -
Title Text
->>> - -# ATX-style h6 -<<< -###### Title Text ---- Should become: -
Title Text
->>> - -<<< -###### Title Text # ---- Should become: -
Title Text
->>> - -<<< -###### Title Text ### ---- Should become: -
Title Text
->>> - -<<< -###### Title Text ##### ---- Should become: -
Title Text
->>> - - ### [Blockquotes] # Regular 1-level blockquotes @@ -839,530 +461,6 @@ foo + bar; foo.factorize; foo.display >>> - -### [Emphasis] - -# Emphasis () with asterisks -<<< -Use *single splats* for emphasis. ---- Should become: -

Use single splats for emphasis.

->>> - -# Emphasis () with underscores -<<< -Use *underscores* for emphasis. ---- Should become: -

Use underscores for emphasis.

->>> - -# Strong emphasis () with asterisks -<<< -Use **double splats** for more emphasis. ---- Should become: -

Use double splats for more emphasis.

->>> - -# Strong emphasis () with underscores -<<< -Use __doubled underscores__ for more emphasis. ---- Should become: -

Use doubled underscores for more emphasis.

->>> - -# Combined emphasis types 1 -<<< -Use *single splats* or _single unders_ for normal emphasis. ---- Should become: -

Use single splats or single unders for normal emphasis.

->>> - -# Combined emphasis types 2 -<<< -Use _single unders_ for normal emphasis -or __double them__ for strong emphasis. ---- Should become: -

Use single unders for normal emphasis -or double them for strong emphasis.

->>> - -# Emphasis containing escaped metachars -<<< -You can include literal *\*splats\** by escaping them. ---- Should become: -

You can include literal *splats* by escaping them.

->>> - -# Two instances of asterisked emphasis on one line -<<< -If there's *two* splatted parts on a *single line* it should still work. ---- Should become: -

If there's two splatted parts on a single line it should still work.

->>> - -# Two instances of double asterisked emphasis on one line -<<< -This **doubled** one should **work too**. ---- Should become: -

This doubled one should work too.

->>> - -# Two instances of underscore emphasis on one line -<<< -If there's _two_ underbarred parts on a _single line_ it should still work. ---- Should become: -

If there's two underbarred parts on a single line it should still work.

->>> - -# Two instances of doubled underscore emphasis on one line -<<< -This __doubled__ one should __work too__. ---- Should become: -

This doubled one should work too.

->>> - -# Initial emphasis (asterisk) -<<< -*Something* like this should be bold. ---- Should become: -

Something like this should be bold.

->>> - -# Initial emphasis (underscore) -<<< -_Something_ like this should be bold. ---- Should become: -

Something like this should be bold.

->>> - -# Initial strong emphasis (asterisk) -<<< -**Something** like this should be bold. ---- Should become: -

Something like this should be bold.

->>> - -# Initial strong emphasis (underscore) -<<< -__Something__ like this should be bold. ---- Should become: -

Something like this should be bold.

->>> - -# Partial-word emphasis (Bug #568) -<<< -**E**xtended **TURN** ---- Should become: -

Extended TURN

->>> - - - -### [Links] - -# Inline link, no title -<<< -An [example](http://url.com/). ---- Should become: -

An example.

->>> - -# Inline link with title -<<< -An [example](http://url.com/ "Check out url.com!"). ---- Should become: -

An example.

->>> - -# Reference-style link, no title -<<< -An [example][ex] reference-style link. - -[ex]: http://www.bluefi.com/ ---- Should become: -

An example reference-style link.

->>> - -# Indented (less than tabwidth) reference-style link -<<< -An [example][ex] reference-style link. - - [ex]: http://www.bluefi.com/ ---- Should become: -

An example reference-style link.

->>> - -# Reference-style link with quoted title -<<< -An [example][ex] reference-style link. - -[ex]: http://www.bluefi.com/ "Check out our air." ---- Should become: -

An example reference-style link.

->>> - -# Reference-style link with paren title -<<< -An [example][ex] reference-style link. - -[ex]: http://www.bluefi.com/ (Check out our air.) ---- Should become: -

An example reference-style link.

->>> - -# Reference-style link with one of each (hehe) -<<< -An [example][ex] reference-style link. - -[ex]: http://www.bluefi.com/ "Check out our air.) ---- Should become: -

An example reference-style link.

->>> - -" <- For syntax highlighting - -# Reference-style link with intervening space -<<< -You can split the [linked part] [ex] from -the reference part with a single space. - -[ex]: http://www.treefrog.com/ "for some reason" ---- Should become: -

You can split the linked part from -the reference part with a single space.

->>> - -# Reference-style link with intervening space -<<< -You can split the [linked part] - [ex] from the reference part -with a newline in case your editor wraps it there, I guess. - -[ex]: http://www.treefrog.com/ ---- Should become: -

You can split the linked part from the reference part -with a newline in case your editor wraps it there, I guess.

->>> - -# Reference-style anchors -<<< -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" ---- Should become: -

I get 10 times more traffic from Google than from -Yahoo or MSN.

->>> - -# Implicit name-link shortcut anchors -<<< -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" ---- Should become: -

I get 10 times more traffic from Google than from -Yahoo or MSN.

->>> - -# Inline anchors -<<< -I get 10 times more traffic from [Google](http://google.com/ "Google") -than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or -[MSN](http://search.msn.com/ "MSN Search"). ---- Should become: -

I get 10 times more traffic from Google -than from Yahoo or -MSN.

->>> - -# Graceful fail for unclosed brackets (and bug #524) -<<< -This is just a [bracket opener; it should fail gracefully. ---- Should become: -

This is just a [bracket opener; it should fail gracefully.

->>> - -# Unresolved reference-style links (Bug #620) -<<< -This is an unresolved [url][1]. ---- Should become: -

This is an unresolved [url][1].

->>> - - -### [Auto-links] - -# Plain HTTP link -<<< -This is a reference to . You should follow it. ---- Should become: -

This is a reference to http://www.FaerieMUD.org/. You should follow it.

->>> - -# FTP link -<<< -Why not download your very own chandelier from ? ---- Should become: -

Why not download your very own chandelier from ftp://ftp.usuc.edu/pub/foof/mir/?

->>> - - -### [Lists] - -# Unordered list -<<< -* Red -* Green -* Blue ---- Should become: -
    -
  • Red
  • -
  • Green
  • -
  • Blue
  • -
->>> - -# Unordered list w/alt bullets -<<< -- Red -- Green -- Blue ---- Should become: -
    -
  • Red
  • -
  • Green
  • -
  • Blue
  • -
->>> - -# Unordered list w/alt bullets 2 -<<< -+ Red -+ Green -+ Blue ---- Should become: -
    -
  • Red
  • -
  • Green
  • -
  • Blue
  • -
->>> - -# Unordered list w/mixed bullets -<<< -+ Red -- Green -* Blue ---- Should become: -
    -
  • Red
  • -
  • Green
  • -
  • Blue
  • -
->>> - -# Ordered list -<<< -1. Bird -2. McHale -3. Parish ---- Should become: -
    -
  1. Bird
  2. -
  3. McHale
  4. -
  5. Parish
  6. -
->>> - -# Ordered list, any numbers -<<< -1. Bird -1. McHale -1. Parish ---- Should become: -
    -
  1. Bird
  2. -
  3. McHale
  4. -
  5. Parish
  6. -
->>> - -# Ordered list, any numbers 2 -<<< -3. Bird -1. McHale -8. Parish ---- Should become: -
    -
  1. Bird
  2. -
  3. McHale
  4. -
  5. Parish
  6. -
->>> - -# Hanging indents -<<< -* 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. ---- Should become: -
    -
  • 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.
  • -
->>> - -# Lazy indents -<<< -* 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. ---- Should become: -
    -
  • 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.
  • -
->>> - -# Paragraph wrapped list items -<<< -* Bird - -* Magic ---- Should become: -
    -
  • Bird

  • -
  • Magic

  • -
->>> - -# Multi-paragraph list items -<<< -1. This is a list item 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. - -2. Suspendisse id sem consectetuer libero luctus adipiscing. ---- Should become: -
    -
  1. This is a list item 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.

  2. -
  3. Suspendisse id sem consectetuer libero luctus adipiscing.

  4. -
->>> - -# Multi-paragraph list items followed by paragraph -<<< -1. This is a list item 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. - -2. Suspendisse id sem consectetuer libero luctus adipiscing. - -This is a following paragraph which shouldn't be part of the list. ---- Should become: -
    -
  1. This is a list item 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.

  2. -
  3. Suspendisse id sem consectetuer libero luctus adipiscing.

  4. -
- -

This is a following paragraph which shouldn't be part of the list.

->>> - -# Lazy multi-paragraphs -<<< -* This is a list item with two paragraphs. - - This is the second paragraph in the list item. You're -only required to indent the first line. Lorem ipsum dolor -sit amet, consectetuer adipiscing elit. - -* Another item in the same list. ---- Should become: -
    -
  • This is a list item with two paragraphs.

    - -

    This is the second paragraph in the list item. You're -only required to indent the first line. Lorem ipsum dolor -sit amet, consectetuer adipiscing elit.

  • -
  • Another item in the same list.

  • -
->>> - -# Blockquote in list item -<<< -* A list item with a blockquote: - - > This is a blockquote - > inside a list item. ---- Should become: -
    -
  • A list item with a blockquote:

    - -
    -

    This is a blockquote - inside a list item.

    -
  • -
->>> - -# Code block in list item -<<< -* A list item with a code block: - - ---- Should become: -
    -
  • A list item with a code block:

    - -
    <code goes here>
    -
  • -
->>> - -# Backslash-escaped number-period-space -<<< -1986\. What a great season. ---- Should become: -

1986. What a great season.

->>> - - ### [1.0.1 changes] # Header + list + code diff --git a/spec/samples/code b/spec/samples/code new file mode 100644 index 0000000..812c010 --- /dev/null +++ b/spec/samples/code @@ -0,0 +1,177 @@ +### [Code spans] + +# Single backtick +<<< +Making `code` work for you +--- Should become: +

Making code work for you

+>>> + +# Literal backtick with doubling +<<< +Making `` `code` `` work for you +--- Should become: +

Making `code` work for you

+>>> + +# Many repetitions +<<< +Making `````code````` work for you +--- Should become: +

Making code work for you

+>>> + +# Two in a row +<<< +This `thing` should be `two` spans. +--- Should become: +

This thing should be two spans.

+>>> + +# At the beginning of a newline +<<< +I should think that the +`tar` command would be universal. +--- Should become: +

I should think that the +tar command would be universal.

+>>> + +# Entity escaping +<<< +The left angle-bracket (`<`) can also be written as a decimal-encoded +(`<`) or hex-encoded (`<`) entity. +--- Should become: +

The left angle-bracket (&lt;) can also be written as a decimal-encoded +(&#060;) or hex-encoded (&#x3c;) entity.

+>>> + +# At the beginning of a document (Bug #525) +<<< +`world` views +--- Should become: +

world views

+>>> + + +### [Code blocks] + +# Para plus code block (literal tab) +<<< +This is a chunk of code: + + some.code > some.other_code + +Some stuff. +--- Should become: +

This is a chunk of code:

+ +
some.code > some.other_code
+
+ +

Some stuff.

+>>> + +# Para plus code block (literal tab, no colon) +<<< +This is a chunk of code + + some.code > some.other_code + +Some stuff. +--- Should become: +

This is a chunk of code

+ +
some.code > some.other_code
+
+ +

Some stuff.

+>>> + +# Para plus code block (tab-width spaces) +<<< +This is a chunk of code: + + some.code > some.other_code + +Some stuff. +--- Should become: +

This is a chunk of code:

+ +
some.code > some.other_code
+
+ +

Some stuff.

+>>> + +# Para plus code block (tab-width spaces, no colon) +<<< +This is a chunk of code + + some.code > some.other_code + +Some stuff. +--- Should become: +

This is a chunk of code

+ +
some.code > some.other_code
+
+ +

Some stuff.

+>>> + +# Colon with preceeding space +<<< +A regular paragraph, without a colon. : + + This is a code block. + +Some stuff. +--- Should become: +

A regular paragraph, without a colon. :

+ +
This is a code block.
+
+ +

Some stuff.

+>>> + +# Single colon +<<< +: + + some.code > some.other_code + +Some stuff. +--- Should become: +

:

+ +
some.code > some.other_code
+
+ +

Some stuff.

+>>> + +# Preserve leading whitespace (Bug #541) +<<< +Examples: + + # (Waste character because first line is flush left !!!) + # Example script1 + x = 1 + x += 1 + puts x + +Some stuff. +--- Should become: +

Examples:

+ +
      # (Waste character because first line is flush left !!!)
+      # Example script1
+      x = 1
+      x += 1
+      puts x
+
+ +

Some stuff.

+>>> diff --git a/spec/samples/emphasis b/spec/samples/emphasis new file mode 100644 index 0000000..f9bc32d --- /dev/null +++ b/spec/samples/emphasis @@ -0,0 +1,152 @@ +### [Emphasis] + +# Emphasis () with asterisks +<<< +Use *single splats* for emphasis. +--- Should become: +

Use single splats for emphasis.

+>>> + +# Emphasis () with underscores +<<< +Use *underscores* for emphasis. +--- Should become: +

Use underscores for emphasis.

+>>> + +# Strong emphasis () with asterisks +<<< +Use **double splats** for more emphasis. +--- Should become: +

Use double splats for more emphasis.

+>>> + +# Strong emphasis () with underscores +<<< +Use __doubled underscores__ for more emphasis. +--- Should become: +

Use doubled underscores for more emphasis.

+>>> + +# Combined emphasis types 1 +<<< +Use *single splats* or _single unders_ for normal emphasis. +--- Should become: +

Use single splats or single unders for normal emphasis.

+>>> + +# Combined emphasis types 2 +<<< +Use _single unders_ for normal emphasis +or __double them__ for strong emphasis. +--- Should become: +

Use single unders for normal emphasis +or double them for strong emphasis.

+>>> + +# Emphasis containing escaped metachars +<<< +You can include literal *\*splats\** by escaping them. +--- Should become: +

You can include literal *splats* by escaping them.

+>>> + +# Two instances of asterisked emphasis on one line +<<< +If there's *two* splatted parts on a *single line* it should still work. +--- Should become: +

If there's two splatted parts on a single line it should still work.

+>>> + +# Two instances of double asterisked emphasis on one line +<<< +This **doubled** one should **work too**. +--- Should become: +

This doubled one should work too.

+>>> + +# Two instances of underscore emphasis on one line +<<< +If there's _two_ underbarred parts on a _single line_ it should still work. +--- Should become: +

If there's two underbarred parts on a single line it should still work.

+>>> + +# Two instances of doubled underscore emphasis on one line +<<< +This __doubled__ one should __work too__. +--- Should become: +

This doubled one should work too.

+>>> + +# Initial emphasis (asterisk) +<<< +*Something* like this should be bold. +--- Should become: +

Something like this should be bold.

+>>> + +# Initial emphasis (underscore) +<<< +_Something_ like this should be bold. +--- Should become: +

Something like this should be bold.

+>>> + +# Initial strong emphasis (asterisk) +<<< +**Something** like this should be bold. +--- Should become: +

Something like this should be bold.

+>>> + +# Initial strong emphasis (underscore) +<<< +__Something__ like this should be bold. +--- Should become: +

Something like this should be bold.

+>>> + +# Partial-word emphasis (Bug #568) +<<< +**E**xtended **TURN** +--- Should become: +

Extended TURN

+>>> + +# Double underscores in words shouldn't create emphasis +<<< +assert__no__emphasis +--- Should become: +

assert__no__emphasis

+>>> + +# Asterisks in words should create emphasis +<<< +we**have**emphasis and we*like*it +--- Should become: +

wehaveemphasis and welikeit

+>>> + +# Ruby methods don't create emphasis +<<< +Here I am mentioning will_paginate and paginated_each methods. +People seem to like acts_as_ferret for indexing. +--- Should become: +

Here I am mentioning will_paginate and paginated_each methods. +People seem to like acts_as_ferret for indexing.

+>>> + +# Ruby methods in CODE spans don't create emphasis +<<< +Here I am mentioning `will_paginate` and `paginated_each` methods. +--- Should become: +

Here I am mentioning will_paginate and paginated_each methods.

+>>> + +# should be able to emphasise a Ruby method with underscores +<<< +_acts_as_ferret_ +--- Should become: +

acts_as_ferret

+>>> diff --git a/spec/samples/links b/spec/samples/links new file mode 100644 index 0000000..a54c4a1 --- /dev/null +++ b/spec/samples/links @@ -0,0 +1,153 @@ +### [Links] + +# Inline link, no title +<<< +An [example](http://url.com/). +--- Should become: +

An example.

+>>> + +# Inline link with title +<<< +An [example](http://url.com/ "Check out url.com!"). +--- Should become: +

An example.

+>>> + +# Reference-style link, no title +<<< +An [example][ex] reference-style link. + +[ex]: http://www.bluefi.com/ +--- Should become: +

An example reference-style link.

+>>> + +# Indented (less than tabwidth) reference-style link +<<< +An [example][ex] reference-style link. + + [ex]: http://www.bluefi.com/ +--- Should become: +

An example reference-style link.

+>>> + +# Reference-style link with quoted title +<<< +An [example][ex] reference-style link. + +[ex]: http://www.bluefi.com/ "Check out our air." +--- Should become: +

An example reference-style link.

+>>> + +# Reference-style link with paren title +<<< +An [example][ex] reference-style link. + +[ex]: http://www.bluefi.com/ (Check out our air.) +--- Should become: +

An example reference-style link.

+>>> + +# Reference-style link with one of each (hehe) +<<< +An [example][ex] reference-style link. + +[ex]: http://www.bluefi.com/ "Check out our air.) +--- Should become: +

An example reference-style link.

+>>> + +" <- For syntax highlighting + +# Reference-style link with intervening space +<<< +You can split the [linked part] [ex] from +the reference part with a single space. + +[ex]: http://www.treefrog.com/ "for some reason" +--- Should become: +

You can split the linked part from +the reference part with a single space.

+>>> + +# Reference-style link with intervening space +<<< +You can split the [linked part] + [ex] from the reference part +with a newline in case your editor wraps it there, I guess. + +[ex]: http://www.treefrog.com/ +--- Should become: +

You can split the linked part from the reference part +with a newline in case your editor wraps it there, I guess.

+>>> + +# Reference-style anchors +<<< +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" +--- Should become: +

I get 10 times more traffic from Google than from +Yahoo or MSN.

+>>> + +# Implicit name-link shortcut anchors +<<< +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" +--- Should become: +

I get 10 times more traffic from Google than from +Yahoo or MSN.

+>>> + +# Inline anchors +<<< +I get 10 times more traffic from [Google](http://google.com/ "Google") +than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or +[MSN](http://search.msn.com/ "MSN Search"). +--- Should become: +

I get 10 times more traffic from Google +than from Yahoo or +MSN.

+>>> + +# Graceful fail for unclosed brackets (and bug #524) +<<< +This is just a [bracket opener; it should fail gracefully. +--- Should become: +

This is just a [bracket opener; it should fail gracefully.

+>>> + +# Unresolved reference-style links (Bug #620) +<<< +This is an unresolved [url][1]. +--- Should become: +

This is an unresolved [url][1].

+>>> + + +### [Auto-links] + +# Plain HTTP link +<<< +This is a reference to . You should follow it. +--- Should become: +

This is a reference to http://www.FaerieMUD.org/. You should follow it.

+>>> + +# FTP link +<<< +Why not download your very own chandelier from ? +--- Should become: +

Why not download your very own chandelier from ftp://ftp.usuc.edu/pub/foof/mir/?

+>>> diff --git a/spec/samples/lists b/spec/samples/lists new file mode 100644 index 0000000..af59986 --- /dev/null +++ b/spec/samples/lists @@ -0,0 +1,248 @@ +### [Lists] + +# Unordered list +<<< +* Red +* Green +* Blue +--- Should become: +
    +
  • Red
  • +
  • Green
  • +
  • Blue
  • +
+>>> + +# Unordered list w/alt bullets +<<< +- Red +- Green +- Blue +--- Should become: +
    +
  • Red
  • +
  • Green
  • +
  • Blue
  • +
+>>> + +# Unordered list w/alt bullets 2 +<<< ++ Red ++ Green ++ Blue +--- Should become: +
    +
  • Red
  • +
  • Green
  • +
  • Blue
  • +
+>>> + +# Unordered list w/mixed bullets +<<< ++ Red +- Green +* Blue +--- Should become: +
    +
  • Red
  • +
  • Green
  • +
  • Blue
  • +
+>>> + +# Ordered list +<<< +1. Bird +2. McHale +3. Parish +--- Should become: +
    +
  1. Bird
  2. +
  3. McHale
  4. +
  5. Parish
  6. +
+>>> + +# Ordered list, any numbers +<<< +1. Bird +1. McHale +1. Parish +--- Should become: +
    +
  1. Bird
  2. +
  3. McHale
  4. +
  5. Parish
  6. +
+>>> + +# Ordered list, any numbers 2 +<<< +3. Bird +1. McHale +8. Parish +--- Should become: +
    +
  1. Bird
  2. +
  3. McHale
  4. +
  5. Parish
  6. +
+>>> + +# Hanging indents +<<< +* 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. +--- Should become: +
    +
  • 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.
  • +
+>>> + +# Lazy indents +<<< +* 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. +--- Should become: +
    +
  • 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.
  • +
+>>> + +# Paragraph wrapped list items +<<< +* Bird + +* Magic +--- Should become: +
    +
  • Bird

  • +
  • Magic

  • +
+>>> + +# Multi-paragraph list items +<<< +1. This is a list item 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. + +2. Suspendisse id sem consectetuer libero luctus adipiscing. +--- Should become: +
    +
  1. This is a list item 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.

  2. +
  3. Suspendisse id sem consectetuer libero luctus adipiscing.

  4. +
+>>> + +# Multi-paragraph list items followed by paragraph +<<< +1. This is a list item 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. + +2. Suspendisse id sem consectetuer libero luctus adipiscing. + +This is a following paragraph which shouldn't be part of the list. +--- Should become: +
    +
  1. This is a list item 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.

  2. +
  3. Suspendisse id sem consectetuer libero luctus adipiscing.

  4. +
+ +

This is a following paragraph which shouldn't be part of the list.

+>>> + +# Lazy multi-paragraphs +<<< +* This is a list item with two paragraphs. + + This is the second paragraph in the list item. You're +only required to indent the first line. Lorem ipsum dolor +sit amet, consectetuer adipiscing elit. + +* Another item in the same list. +--- Should become: +
    +
  • This is a list item with two paragraphs.

    + +

    This is the second paragraph in the list item. You're +only required to indent the first line. Lorem ipsum dolor +sit amet, consectetuer adipiscing elit.

  • +
  • Another item in the same list.

  • +
+>>> + +# Blockquote in list item +<<< +* A list item with a blockquote: + + > This is a blockquote + > inside a list item. +--- Should become: +
    +
  • A list item with a blockquote:

    + +
    +

    This is a blockquote + inside a list item.

    +
  • +
+>>> + +# Code block in list item +<<< +* A list item with a code block: + + +--- Should become: +
    +
  • A list item with a code block:

    + +
    <code goes here>
    +
  • +
+>>> + +# Backslash-escaped number-period-space +<<< +1986\. What a great season. +--- Should become: +

1986. What a great season.

+>>> diff --git a/spec/samples/titles b/spec/samples/titles new file mode 100644 index 0000000..544eef9 --- /dev/null +++ b/spec/samples/titles @@ -0,0 +1,240 @@ +### [Titles] + +# setext-style h1 +<<< +Title Text += +--- Should become: +

Title Text

+>>> + +<<< +Title Text +=== +--- Should become: +

Title Text

+>>> + +<<< +Title Text +========== +--- Should become: +

Title Text

+>>> + +# setext-style h2 +<<< +Title Text +- +--- Should become: +

Title Text

+>>> + +<<< +Title Text +--- +--- Should become: +

Title Text

+>>> + +<<< +Title Text +---------- +--- Should become: +

Title Text

+>>> + +# ATX-style h1 +<<< +# Title Text +--- Should become: +

Title Text

+>>> + +<<< +# Title Text # +--- Should become: +

Title Text

+>>> + +<<< +# Title Text ### +--- Should become: +

Title Text

+>>> + +<<< +# Title Text ##### +--- Should become: +

Title Text

+>>> + +# ATX-style h2 +<<< +## Title Text +--- Should become: +

Title Text

+>>> + +<<< +## Title Text # +--- Should become: +

Title Text

+>>> + +<<< +## Title Text ### +--- Should become: +

Title Text

+>>> + +<<< +## Title Text ##### +--- Should become: +

Title Text

+>>> + +# ATX-style h3 +<<< +### Title Text +--- Should become: +

Title Text

+>>> + +<<< +### Title Text # +--- Should become: +

Title Text

+>>> + +<<< +### Title Text ### +--- Should become: +

Title Text

+>>> + +<<< +### Title Text ##### +--- Should become: +

Title Text

+>>> + +# ATX-style h4 +<<< +#### Title Text +--- Should become: +

Title Text

+>>> + +<<< +#### Title Text # +--- Should become: +

Title Text

+>>> + +<<< +#### Title Text ### +--- Should become: +

Title Text

+>>> + +<<< +#### Title Text ##### +--- Should become: +

Title Text

+>>> + +# ATX-style h5 +<<< +##### Title Text +--- Should become: +
Title Text
+>>> + +<<< +##### Title Text # +--- Should become: +
Title Text
+>>> + +<<< +##### Title Text ### +--- Should become: +
Title Text
+>>> + +<<< +##### Title Text ##### +--- Should become: +
Title Text
+>>> + +# ATX-style h6 +<<< +###### Title Text +--- Should become: +
Title Text
+>>> + +<<< +###### Title Text # +--- Should become: +
Title Text
+>>> + +<<< +###### Title Text ### +--- Should become: +
Title Text
+>>> + +<<< +###### Title Text ##### +--- Should become: +
Title Text
+>>> + +# mixed-style headings +<<< +A First Level Header +==================== + +A Second Level Header +--------------------- + +Now is the time for all good men to come to +the aid of their country. This is just a +regular paragraph. + +The quick brown fox jumped over the lazy +dog's back. + +### Header 3 + +> This is a blockquote. +> +> This is the second paragraph in the blockquote. +> +> ## This is an H2 in a blockquote +--- becomes: +

A First Level Header

+ +

A Second Level Header

+ +

Now is the time for all good men to come to +the aid of their country. This is just a +regular paragraph.

+ +

The quick brown fox jumped over the lazy +dog's back.

+ +

Header 3

+ +
+

This is a blockquote.

+ +

This is the second paragraph in the blockquote.

+ +

This is an H2 in a blockquote

+
+>>>