bluecloth 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +629 -0
- data/LICENSE +27 -0
- data/LICENSE.discount +47 -0
- data/README +71 -0
- data/Rakefile +319 -0
- data/Rakefile.local +63 -0
- data/bin/bluecloth +84 -0
- data/ext/VERSION +1 -0
- data/ext/amalloc.h +29 -0
- data/ext/bluecloth.c +373 -0
- data/ext/config.h +47 -0
- data/ext/cstring.h +73 -0
- data/ext/docheader.c +43 -0
- data/ext/extconf.rb +45 -0
- data/ext/generate.c +1387 -0
- data/ext/markdown.c +939 -0
- data/ext/markdown.h +135 -0
- data/ext/mkdio.c +241 -0
- data/ext/mkdio.h +66 -0
- data/ext/resource.c +169 -0
- data/ext/version.c +28 -0
- data/lib/bluecloth.rb +148 -0
- data/rake/191_compat.rb +26 -0
- data/rake/dependencies.rb +76 -0
- data/rake/helpers.rb +412 -0
- data/rake/manual.rb +782 -0
- data/rake/packaging.rb +116 -0
- data/rake/publishing.rb +321 -0
- data/rake/rdoc.rb +40 -0
- data/rake/style.rb +62 -0
- data/rake/svn.rb +639 -0
- data/rake/testing.rb +204 -0
- data/rake/verifytask.rb +64 -0
- data/rake/win32.rb +186 -0
- data/spec/bluecloth/101_changes_spec.rb +141 -0
- data/spec/bluecloth/autolinks_spec.rb +49 -0
- data/spec/bluecloth/blockquotes_spec.rb +143 -0
- data/spec/bluecloth/code_spans_spec.rb +164 -0
- data/spec/bluecloth/emphasis_spec.rb +164 -0
- data/spec/bluecloth/entities_spec.rb +65 -0
- data/spec/bluecloth/hrules_spec.rb +90 -0
- data/spec/bluecloth/images_spec.rb +92 -0
- data/spec/bluecloth/inline_html_spec.rb +238 -0
- data/spec/bluecloth/links_spec.rb +171 -0
- data/spec/bluecloth/lists_spec.rb +294 -0
- data/spec/bluecloth/paragraphs_spec.rb +75 -0
- data/spec/bluecloth/titles_spec.rb +305 -0
- data/spec/bluecloth_spec.rb +209 -0
- data/spec/bugfix_spec.rb +123 -0
- data/spec/contributions_spec.rb +85 -0
- data/spec/data/antsugar.txt +34 -0
- data/spec/data/markdowntest/Amps and angle encoding.html +17 -0
- data/spec/data/markdowntest/Amps and angle encoding.text +21 -0
- data/spec/data/markdowntest/Auto links.html +18 -0
- data/spec/data/markdowntest/Auto links.text +13 -0
- data/spec/data/markdowntest/Backslash escapes.html +118 -0
- data/spec/data/markdowntest/Backslash escapes.text +120 -0
- data/spec/data/markdowntest/Blockquotes with code blocks.html +15 -0
- data/spec/data/markdowntest/Blockquotes with code blocks.text +11 -0
- data/spec/data/markdowntest/Code Blocks.html +18 -0
- data/spec/data/markdowntest/Code Blocks.text +14 -0
- data/spec/data/markdowntest/Code Spans.html +5 -0
- data/spec/data/markdowntest/Code Spans.text +5 -0
- data/spec/data/markdowntest/Hard-wrapped paragraphs with list-like lines.html +8 -0
- data/spec/data/markdowntest/Hard-wrapped paragraphs with list-like lines.text +8 -0
- data/spec/data/markdowntest/Horizontal rules.html +71 -0
- data/spec/data/markdowntest/Horizontal rules.text +67 -0
- data/spec/data/markdowntest/Inline HTML (Advanced).html +15 -0
- data/spec/data/markdowntest/Inline HTML (Advanced).text +15 -0
- data/spec/data/markdowntest/Inline HTML (Simple).html +72 -0
- data/spec/data/markdowntest/Inline HTML (Simple).text +69 -0
- data/spec/data/markdowntest/Inline HTML comments.html +13 -0
- data/spec/data/markdowntest/Inline HTML comments.text +13 -0
- data/spec/data/markdowntest/Links, inline style.html +11 -0
- data/spec/data/markdowntest/Links, inline style.text +12 -0
- data/spec/data/markdowntest/Links, reference style.html +52 -0
- data/spec/data/markdowntest/Links, reference style.text +71 -0
- data/spec/data/markdowntest/Links, shortcut references.html +9 -0
- data/spec/data/markdowntest/Links, shortcut references.text +20 -0
- data/spec/data/markdowntest/Literal quotes in titles.html +3 -0
- data/spec/data/markdowntest/Literal quotes in titles.text +7 -0
- data/spec/data/markdowntest/Markdown Documentation - Basics.html +314 -0
- data/spec/data/markdowntest/Markdown Documentation - Basics.text +306 -0
- data/spec/data/markdowntest/Markdown Documentation - Syntax.html +942 -0
- data/spec/data/markdowntest/Markdown Documentation - Syntax.text +888 -0
- data/spec/data/markdowntest/Nested blockquotes.html +9 -0
- data/spec/data/markdowntest/Nested blockquotes.text +5 -0
- data/spec/data/markdowntest/Ordered and unordered lists.html +148 -0
- data/spec/data/markdowntest/Ordered and unordered lists.text +131 -0
- data/spec/data/markdowntest/Strong and em together.html +7 -0
- data/spec/data/markdowntest/Strong and em together.text +7 -0
- data/spec/data/markdowntest/Tabs.html +25 -0
- data/spec/data/markdowntest/Tabs.text +21 -0
- data/spec/data/markdowntest/Tidyness.html +8 -0
- data/spec/data/markdowntest/Tidyness.text +5 -0
- data/spec/data/ml-announce.txt +17 -0
- data/spec/data/re-overflow.txt +67 -0
- data/spec/data/re-overflow2.txt +281 -0
- data/spec/lib/constants.rb +5 -0
- data/spec/lib/helpers.rb +137 -0
- data/spec/lib/matchers.rb +235 -0
- data/spec/markdowntest_spec.rb +76 -0
- metadata +305 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
BEGIN {
|
|
5
|
+
require 'pathname'
|
|
6
|
+
basedir = Pathname.new( __FILE__ ).dirname.parent.parent
|
|
7
|
+
|
|
8
|
+
libdir = basedir + 'lib'
|
|
9
|
+
extdir = basedir + 'ext'
|
|
10
|
+
|
|
11
|
+
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
|
|
12
|
+
$LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
require 'spec'
|
|
16
|
+
require 'bluecloth'
|
|
17
|
+
|
|
18
|
+
require 'spec/lib/helpers'
|
|
19
|
+
require 'spec/lib/constants'
|
|
20
|
+
require 'spec/lib/matchers'
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
#####################################################################
|
|
24
|
+
### C O N T E X T S
|
|
25
|
+
#####################################################################
|
|
26
|
+
|
|
27
|
+
describe BlueCloth, "1.0.1 changes" do
|
|
28
|
+
include BlueCloth::TestConstants,
|
|
29
|
+
BlueCloth::Matchers
|
|
30
|
+
|
|
31
|
+
it "doesn't touch escapes in code blocks" do
|
|
32
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
33
|
+
Markdown allows you to use backslash escapes to generate literal
|
|
34
|
+
characters which would otherwise have special meaning in Markdown's
|
|
35
|
+
formatting syntax. For example, if you wanted to surround a word with
|
|
36
|
+
literal asterisks (instead of an HTML `<em>` tag), you can backslashes
|
|
37
|
+
before the asterisks, like this:
|
|
38
|
+
|
|
39
|
+
\\*literal asterisks\\*
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
<p>Markdown allows you to use backslash escapes to generate literal
|
|
43
|
+
characters which would otherwise have special meaning in Markdown's
|
|
44
|
+
formatting syntax. For example, if you wanted to surround a word with
|
|
45
|
+
literal asterisks (instead of an HTML <code><em></code> tag), you can backslashes
|
|
46
|
+
before the asterisks, like this:</p>
|
|
47
|
+
|
|
48
|
+
<pre><code>\\*literal asterisks\\*
|
|
49
|
+
</code></pre>
|
|
50
|
+
---
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "shouldn't touched escapes in code spans" do
|
|
54
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
55
|
+
You can escape the splat operator by backslashing it like this: `/foo\\*/`.
|
|
56
|
+
---
|
|
57
|
+
<p>You can escape the splat operator by backslashing it like this: <code>/foo\\*/</code>.</p>
|
|
58
|
+
---
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
it "converts reference-style links at or deeper than tab width to code blocks" do
|
|
63
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
64
|
+
An [example][ex] reference-style link.
|
|
65
|
+
|
|
66
|
+
[ex]: http://www.bluefi.com/
|
|
67
|
+
---
|
|
68
|
+
<p>An [example][ex] reference-style link.</p>
|
|
69
|
+
|
|
70
|
+
<pre><code>[ex]: http://www.bluefi.com/
|
|
71
|
+
</code></pre>
|
|
72
|
+
---
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it "fixes inline links using < and > URL delimiters, which weren't working" do
|
|
76
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
77
|
+
like [this](<http://example.com/>)
|
|
78
|
+
---
|
|
79
|
+
<p>like <a href="http://example.com/">this</a></p>
|
|
80
|
+
---
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it "keeps HTML comment blocks as-is" do
|
|
84
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
85
|
+
<!-- This is a comment -->
|
|
86
|
+
---
|
|
87
|
+
<!-- This is a comment -->
|
|
88
|
+
---
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it "doesn't auto-link inside code spans" do
|
|
92
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
93
|
+
like this: `<http://example.com/>`
|
|
94
|
+
---
|
|
95
|
+
<p>like this: <code><http://example.com/></code></p>
|
|
96
|
+
---
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
it "no longer creates a list when lines in the middle of hard-wrapped paragraphs look " +
|
|
101
|
+
"like the start of a list item" do
|
|
102
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
103
|
+
I recommend upgrading to version
|
|
104
|
+
8. Oops, now this line is treated
|
|
105
|
+
as a sub-list.
|
|
106
|
+
---
|
|
107
|
+
<p>I recommend upgrading to version
|
|
108
|
+
8. Oops, now this line is treated
|
|
109
|
+
as a sub-list.</p>
|
|
110
|
+
---
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
it "correctly marks up header + list + code" do
|
|
115
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
116
|
+
## This is a header.
|
|
117
|
+
|
|
118
|
+
1. This is the first list item.
|
|
119
|
+
2. This is the second list item.
|
|
120
|
+
|
|
121
|
+
Here's some example code:
|
|
122
|
+
|
|
123
|
+
return shell_exec("echo $input | $markdown_script");
|
|
124
|
+
---
|
|
125
|
+
<h2>This is a header.</h2>
|
|
126
|
+
|
|
127
|
+
<ol>
|
|
128
|
+
<li>This is the first list item.</li>
|
|
129
|
+
<li>This is the second list item.</li>
|
|
130
|
+
</ol>
|
|
131
|
+
|
|
132
|
+
<p>Here's some example code:</p>
|
|
133
|
+
|
|
134
|
+
<pre><code>return shell_exec("echo $input | $markdown_script");
|
|
135
|
+
</code></pre>
|
|
136
|
+
---
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
BEGIN {
|
|
5
|
+
require 'pathname'
|
|
6
|
+
basedir = Pathname.new( __FILE__ ).dirname.parent.parent
|
|
7
|
+
|
|
8
|
+
libdir = basedir + 'lib'
|
|
9
|
+
extdir = basedir + 'ext'
|
|
10
|
+
|
|
11
|
+
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
|
|
12
|
+
$LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
require 'spec'
|
|
16
|
+
require 'bluecloth'
|
|
17
|
+
|
|
18
|
+
require 'spec/lib/helpers'
|
|
19
|
+
require 'spec/lib/constants'
|
|
20
|
+
require 'spec/lib/matchers'
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
#####################################################################
|
|
24
|
+
### C O N T E X T S
|
|
25
|
+
#####################################################################
|
|
26
|
+
|
|
27
|
+
describe BlueCloth, "auto-links" do
|
|
28
|
+
include BlueCloth::TestConstants,
|
|
29
|
+
BlueCloth::Matchers
|
|
30
|
+
|
|
31
|
+
it "supports HTTP auto-links" do
|
|
32
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
33
|
+
This is a reference to <http://www.FaerieMUD.org/>. You should follow it.
|
|
34
|
+
---
|
|
35
|
+
<p>This is a reference to <a href="http://www.FaerieMUD.org/">http://www.FaerieMUD.org/</a>. You should follow it.</p>
|
|
36
|
+
---
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "supports FTP auto-link" do
|
|
40
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
41
|
+
Why not download your very own chandelier from <ftp://ftp.usuc.edu/pub/foof/mir/>?
|
|
42
|
+
---
|
|
43
|
+
<p>Why not download your very own chandelier from <a href="ftp://ftp.usuc.edu/pub/foof/mir/">ftp://ftp.usuc.edu/pub/foof/mir/</a>?</p>
|
|
44
|
+
---
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
BEGIN {
|
|
5
|
+
require 'pathname'
|
|
6
|
+
basedir = Pathname.new( __FILE__ ).dirname.parent.parent
|
|
7
|
+
|
|
8
|
+
libdir = basedir + 'lib'
|
|
9
|
+
extdir = basedir + 'ext'
|
|
10
|
+
|
|
11
|
+
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
|
|
12
|
+
$LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
require 'spec'
|
|
16
|
+
require 'bluecloth'
|
|
17
|
+
|
|
18
|
+
require 'spec/lib/helpers'
|
|
19
|
+
require 'spec/lib/constants'
|
|
20
|
+
require 'spec/lib/matchers'
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
#####################################################################
|
|
24
|
+
### C O N T E X T S
|
|
25
|
+
#####################################################################
|
|
26
|
+
|
|
27
|
+
describe BlueCloth, "blockquotes" do
|
|
28
|
+
include BlueCloth::TestConstants,
|
|
29
|
+
BlueCloth::Matchers
|
|
30
|
+
|
|
31
|
+
### [Blockquotes]
|
|
32
|
+
|
|
33
|
+
# Regular 1-level blockquotes
|
|
34
|
+
it "wraps sections with an angle-bracket left margin in a blockquote" do
|
|
35
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
36
|
+
> Email-style angle brackets
|
|
37
|
+
> are used for blockquotes.
|
|
38
|
+
---
|
|
39
|
+
<blockquote><p>Email-style angle brackets
|
|
40
|
+
are used for blockquotes.</p></blockquote>
|
|
41
|
+
---
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Nested blockquotes
|
|
45
|
+
it "supports nested blockquote sections" do
|
|
46
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
47
|
+
> Email-style angle brackets
|
|
48
|
+
> are used for blockquotes.
|
|
49
|
+
|
|
50
|
+
> > And, they can be nested.
|
|
51
|
+
---
|
|
52
|
+
<blockquote><p>Email-style angle brackets
|
|
53
|
+
are used for blockquotes.</p>
|
|
54
|
+
|
|
55
|
+
<blockquote><p>And, they can be nested.</p></blockquote></blockquote>
|
|
56
|
+
---
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Doubled blockquotes
|
|
60
|
+
it "supports nested blockquote sections even if there's only one multi-level section" do
|
|
61
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
62
|
+
> > And, they can be nested.
|
|
63
|
+
---
|
|
64
|
+
<blockquote><blockquote><p>And, they can be nested.</p></blockquote></blockquote>
|
|
65
|
+
---
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Lazy blockquotes
|
|
69
|
+
it "wraps sections preceded by an angle-bracket in a blockquote" do
|
|
70
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
71
|
+
> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
|
|
72
|
+
consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
|
|
73
|
+
Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
|
|
74
|
+
|
|
75
|
+
> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
|
|
76
|
+
id sem consectetuer libero luctus adipiscing.
|
|
77
|
+
---
|
|
78
|
+
<blockquote><p>This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
|
|
79
|
+
consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
|
|
80
|
+
Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.</p>
|
|
81
|
+
|
|
82
|
+
<p>Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
|
|
83
|
+
id sem consectetuer libero luctus adipiscing.</p></blockquote>
|
|
84
|
+
---
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
# Blockquotes containing other markdown elements
|
|
89
|
+
it "supports other Markdown elements in blockquote sections" do
|
|
90
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
91
|
+
> ## This is a header.
|
|
92
|
+
>
|
|
93
|
+
> 1. This is the first list item.
|
|
94
|
+
> 2. This is the second list item.
|
|
95
|
+
>
|
|
96
|
+
> Here's some example code:
|
|
97
|
+
>
|
|
98
|
+
> return shell_exec("echo $input | $markdown_script");
|
|
99
|
+
---
|
|
100
|
+
<blockquote><h2>This is a header.</h2>
|
|
101
|
+
|
|
102
|
+
<ol>
|
|
103
|
+
<li>This is the first list item.</li>
|
|
104
|
+
<li>This is the second list item.</li>
|
|
105
|
+
</ol>
|
|
106
|
+
|
|
107
|
+
<p>Here's some example code:</p>
|
|
108
|
+
|
|
109
|
+
<pre><code>return shell_exec("echo $input | $markdown_script");
|
|
110
|
+
</code></pre></blockquote>
|
|
111
|
+
---
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Blockquotes with a <pre> section
|
|
115
|
+
it "supports block-level HTML inside of blockquotes" do
|
|
116
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
117
|
+
> The best approximation of the problem is the following code:
|
|
118
|
+
>
|
|
119
|
+
> <pre>
|
|
120
|
+
> foo + bar; foo.factorize; foo.display
|
|
121
|
+
> </pre>
|
|
122
|
+
>
|
|
123
|
+
> This should result in an error on any little-endian platform.
|
|
124
|
+
>
|
|
125
|
+
> <div>- Garrick Mettronne</div>
|
|
126
|
+
---
|
|
127
|
+
<blockquote><p>The best approximation of the problem is the following code:</p>
|
|
128
|
+
|
|
129
|
+
<pre>
|
|
130
|
+
foo + bar; foo.factorize; foo.display
|
|
131
|
+
</pre>
|
|
132
|
+
|
|
133
|
+
<p>This should result in an error on any little-endian platform.</p>
|
|
134
|
+
|
|
135
|
+
<div>- Garrick Mettronne</div>
|
|
136
|
+
</blockquote>
|
|
137
|
+
---
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
BEGIN {
|
|
5
|
+
require 'pathname'
|
|
6
|
+
basedir = Pathname.new( __FILE__ ).dirname.parent.parent
|
|
7
|
+
|
|
8
|
+
libdir = basedir + 'lib'
|
|
9
|
+
extdir = basedir + 'ext'
|
|
10
|
+
|
|
11
|
+
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
|
|
12
|
+
$LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
require 'spec'
|
|
16
|
+
require 'bluecloth'
|
|
17
|
+
|
|
18
|
+
require 'spec/lib/helpers'
|
|
19
|
+
require 'spec/lib/constants'
|
|
20
|
+
require 'spec/lib/matchers'
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
#####################################################################
|
|
24
|
+
### C O N T E X T S
|
|
25
|
+
#####################################################################
|
|
26
|
+
|
|
27
|
+
describe BlueCloth, "that contains code blocks or spans" do
|
|
28
|
+
include BlueCloth::TestConstants,
|
|
29
|
+
BlueCloth::Matchers
|
|
30
|
+
|
|
31
|
+
it "wraps CODE tags around backticked spans" do
|
|
32
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
33
|
+
Making `code` work for you
|
|
34
|
+
---
|
|
35
|
+
<p>Making <code>code</code> work for you</p>
|
|
36
|
+
---
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "allows you to place literal backtick characters at the beginning or end of a code span " +
|
|
40
|
+
"by padding the inner string with spaces" do
|
|
41
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
42
|
+
Making `` `code` `` work for you
|
|
43
|
+
---
|
|
44
|
+
<p>Making <code>`code`</code> work for you</p>
|
|
45
|
+
---
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "wraps CODE tags around doubled backtick spans with a single literal backtick inside them" do
|
|
49
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
50
|
+
``There is a literal backtick (`) here.``
|
|
51
|
+
---
|
|
52
|
+
<p><code>There is a literal backtick (`) here.</code></p>
|
|
53
|
+
---
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "correctly transforms two literal spans in one line" do
|
|
57
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
58
|
+
This `thing` should be `two` spans.
|
|
59
|
+
---
|
|
60
|
+
<p>This <code>thing</code> should be <code>two</code> spans.</p>
|
|
61
|
+
---
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "correctly transforms literal spans at the beginning of a line" do
|
|
65
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
66
|
+
I should think that the
|
|
67
|
+
`tar` command would be universal.
|
|
68
|
+
---
|
|
69
|
+
<p>I should think that the
|
|
70
|
+
<code>tar</code> command would be universal.</p>
|
|
71
|
+
---
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it "encodes ampersands and angle brackets within code spans as HTML entities" do
|
|
75
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
76
|
+
The left angle-bracket (`<`) can also be written as a decimal-encoded
|
|
77
|
+
(`<`) or hex-encoded (`<`) entity. This
|
|
78
|
+
also works with `<div>` elements.
|
|
79
|
+
---
|
|
80
|
+
<p>The left angle-bracket (<code>&lt;</code>) can also be written as a decimal-encoded
|
|
81
|
+
(<code>&#060;</code>) or hex-encoded (<code>&#x3c;</code>) entity. This
|
|
82
|
+
also works with <code><div></code> elements.</p>
|
|
83
|
+
---
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# At the beginning of a document (Bug #525)
|
|
87
|
+
it "correctly transforms code spans at the beginning of paragraphs (bug #525)" do
|
|
88
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
89
|
+
`world` views
|
|
90
|
+
---
|
|
91
|
+
<p><code>world</code> views</p>
|
|
92
|
+
---
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
### [Code blocks]
|
|
99
|
+
|
|
100
|
+
# Para plus code block (literal tab, no colon)
|
|
101
|
+
it "wraps sections indented with a literal tab in a code block" do
|
|
102
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
103
|
+
This is a chunk of code
|
|
104
|
+
|
|
105
|
+
some.code > some.other_code
|
|
106
|
+
|
|
107
|
+
Some stuff.
|
|
108
|
+
---
|
|
109
|
+
<p>This is a chunk of code</p>
|
|
110
|
+
|
|
111
|
+
<pre><code>some.code > some.other_code
|
|
112
|
+
</code></pre>
|
|
113
|
+
|
|
114
|
+
<p>Some stuff.</p>
|
|
115
|
+
---
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Para plus code block (tab-width spaces)
|
|
119
|
+
it "wraps sections indented with at least 4 spaces in a code block" do
|
|
120
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
121
|
+
This is a chunk of code:
|
|
122
|
+
|
|
123
|
+
some.code > some.other_code
|
|
124
|
+
|
|
125
|
+
Some stuff.
|
|
126
|
+
---
|
|
127
|
+
<p>This is a chunk of code:</p>
|
|
128
|
+
|
|
129
|
+
<pre><code>some.code > some.other_code
|
|
130
|
+
</code></pre>
|
|
131
|
+
|
|
132
|
+
<p>Some stuff.</p>
|
|
133
|
+
---
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# Preserve leading whitespace (Bug #541)
|
|
137
|
+
it "removes one level of indentation (and no more) from code blocks" do
|
|
138
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
139
|
+
Examples:
|
|
140
|
+
|
|
141
|
+
# (Waste character because first line is flush left !!!)
|
|
142
|
+
# Example script1
|
|
143
|
+
x = 1
|
|
144
|
+
x += 1
|
|
145
|
+
puts x
|
|
146
|
+
|
|
147
|
+
Some stuff.
|
|
148
|
+
---
|
|
149
|
+
<p>Examples:</p>
|
|
150
|
+
|
|
151
|
+
<pre><code> # (Waste character because first line is flush left !!!)
|
|
152
|
+
# Example script1
|
|
153
|
+
x = 1
|
|
154
|
+
x += 1
|
|
155
|
+
puts x
|
|
156
|
+
</code></pre>
|
|
157
|
+
|
|
158
|
+
<p>Some stuff.</p>
|
|
159
|
+
---
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
|