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,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, "emphasis" do
|
|
28
|
+
include BlueCloth::TestConstants,
|
|
29
|
+
BlueCloth::Matchers
|
|
30
|
+
|
|
31
|
+
it "treats single asterisks as indicators of emphasis" do
|
|
32
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
33
|
+
Use *single splats* for emphasis.
|
|
34
|
+
---
|
|
35
|
+
<p>Use <em>single splats</em> for emphasis.</p>
|
|
36
|
+
---
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "treats single underscores as indicators of emphasis" do
|
|
40
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
41
|
+
Use *underscores* for emphasis.
|
|
42
|
+
---
|
|
43
|
+
<p>Use <em>underscores</em> for emphasis.</p>
|
|
44
|
+
---
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "treats double asterisks as strong emphasis" do
|
|
48
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
49
|
+
Use **double splats** for more emphasis.
|
|
50
|
+
---
|
|
51
|
+
<p>Use <strong>double splats</strong> for more emphasis.</p>
|
|
52
|
+
---
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "treats double underscores as strong emphasis" do
|
|
56
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
57
|
+
Use __doubled underscores__ for more emphasis.
|
|
58
|
+
---
|
|
59
|
+
<p>Use <strong>doubled underscores</strong> for more emphasis.</p>
|
|
60
|
+
---
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "allows you to use both kinds of emphasis in a single span" do
|
|
64
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
65
|
+
Use *single splats* or _single unders_ for normal emphasis.
|
|
66
|
+
---
|
|
67
|
+
<p>Use <em>single splats</em> or <em>single unders</em> for normal emphasis.</p>
|
|
68
|
+
---
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "allows you to use both kinds of strong emphasis in a single span" do
|
|
72
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
73
|
+
Use _single unders_ for normal emphasis
|
|
74
|
+
or __double them__ for strong emphasis.
|
|
75
|
+
---
|
|
76
|
+
<p>Use <em>single unders</em> for normal emphasis
|
|
77
|
+
or <strong>double them</strong> for strong emphasis.</p>
|
|
78
|
+
---
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "allows you to include literal asterisks by escaping them" do
|
|
82
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
83
|
+
You can include literal *\\*splats\\** by escaping them.
|
|
84
|
+
---
|
|
85
|
+
<p>You can include literal <em>*splats*</em> by escaping them.</p>
|
|
86
|
+
---
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it "allows two instances of asterisked emphasis on one line" do
|
|
90
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
91
|
+
If there's *two* splatted parts on a *single line* it should still work.
|
|
92
|
+
---
|
|
93
|
+
<p>If there's <em>two</em> splatted parts on a <em>single line</em> it should still work.</p>
|
|
94
|
+
---
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it "allows two instances of double-asterisked emphasis on one line" do
|
|
98
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
99
|
+
This **doubled** one should **work too**.
|
|
100
|
+
---
|
|
101
|
+
<p>This <strong>doubled</strong> one should <strong>work too</strong>.</p>
|
|
102
|
+
---
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it "allows two instances of underscored emphasis on one line" do
|
|
106
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
107
|
+
If there's _two_ underbarred parts on a _single line_ it should still work.
|
|
108
|
+
---
|
|
109
|
+
<p>If there's <em>two</em> underbarred parts on a <em>single line</em> it should still work.</p>
|
|
110
|
+
---
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it "allows two instances of double-underscored emphasis on one line" do
|
|
114
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
115
|
+
This __doubled__ one should __work too__.
|
|
116
|
+
---
|
|
117
|
+
<p>This <strong>doubled</strong> one should <strong>work too</strong>.</p>
|
|
118
|
+
---
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
it "correctly emphasizes the first span of the text if it's emphasized with asterisks" do
|
|
122
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
123
|
+
*Something* like this should be bold.
|
|
124
|
+
---
|
|
125
|
+
<p><em>Something</em> like this should be bold.</p>
|
|
126
|
+
---
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it "correctly emphasizes the first span of the text if it's emphasized with underscores" do
|
|
130
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
131
|
+
_Something_ like this should be bold.
|
|
132
|
+
---
|
|
133
|
+
<p><em>Something</em> like this should be bold.</p>
|
|
134
|
+
---
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
it "correctly emphasizes the first span of the text if it's emphasized with double asterisks" do
|
|
138
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
139
|
+
**Something** like this should be bold.
|
|
140
|
+
---
|
|
141
|
+
<p><strong>Something</strong> like this should be bold.</p>
|
|
142
|
+
---
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
it "correctly emphasizes the first span of the text if it's emphasized with double underscores" do
|
|
146
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
147
|
+
__Something__ like this should be bold.
|
|
148
|
+
---
|
|
149
|
+
<p><strong>Something</strong> like this should be bold.</p>
|
|
150
|
+
---
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Partial-word emphasis (Bug #568)
|
|
154
|
+
it "correctly emphasizes just a part of a word (bugfix for #568)" do
|
|
155
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
156
|
+
**E**xtended **TURN**
|
|
157
|
+
---
|
|
158
|
+
<p><strong>E</strong>xtended <strong>TURN</strong></p>
|
|
159
|
+
---
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
|
|
@@ -0,0 +1,65 @@
|
|
|
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, "document with entities" do
|
|
28
|
+
include BlueCloth::TestConstants,
|
|
29
|
+
BlueCloth::Matchers
|
|
30
|
+
|
|
31
|
+
it "escapes special characters" do
|
|
32
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
33
|
+
The left shift operator, which is written as <<, is often used & greatly admired.
|
|
34
|
+
---
|
|
35
|
+
<p>The left shift operator, which is written as <<, is often used & greatly admired.</p>
|
|
36
|
+
---
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "preserves named entities" do
|
|
40
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
41
|
+
The left shift operator, which is written as <<, is often used & greatly admired.
|
|
42
|
+
---
|
|
43
|
+
<p>The left shift operator, which is written as <<, is often used & greatly admired.</p>
|
|
44
|
+
---
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "preserves decimal-encoded entities" do
|
|
48
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
49
|
+
The left shift operator, which is written as <<, is often used & greatly admired.
|
|
50
|
+
---
|
|
51
|
+
<p>The left shift operator, which is written as <<, is often used & greatly admired.</p>
|
|
52
|
+
---
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "preserves hex-encoded entities" do
|
|
56
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
57
|
+
The left shift operator, which is written as <<, is often used & greatly admired.
|
|
58
|
+
---
|
|
59
|
+
<p>The left shift operator, which is written as <<, is often used & greatly admired.</p>
|
|
60
|
+
---
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
|
|
@@ -0,0 +1,90 @@
|
|
|
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, "horizontal rules" do
|
|
28
|
+
include BlueCloth::TestConstants,
|
|
29
|
+
BlueCloth::Matchers
|
|
30
|
+
|
|
31
|
+
# Hrule -- three asterisks
|
|
32
|
+
it "produces a horizontal rule tag from three asterisks on a line by themselves" do
|
|
33
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
34
|
+
***
|
|
35
|
+
---
|
|
36
|
+
<hr />
|
|
37
|
+
---
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Hrule -- three spaced-out asterisks
|
|
41
|
+
it "produces a horizontal rule tag from three asterisks with intervening spaces on a line " +
|
|
42
|
+
" by themselves" do
|
|
43
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
44
|
+
* * *
|
|
45
|
+
---
|
|
46
|
+
<hr />
|
|
47
|
+
---
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Indented Hrule -- three spaced-out asterisks
|
|
51
|
+
it "produces a horizontal rule tag from three asterisks with intervening spaces on a line " +
|
|
52
|
+
" by themselves, even if they're indented less than 4 spaces" do
|
|
53
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
54
|
+
* * *
|
|
55
|
+
---
|
|
56
|
+
<hr />
|
|
57
|
+
---
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Hrule -- more than three asterisks
|
|
61
|
+
it "produces a horizontal rule tag from more than three asterisks on a line by themselves" do
|
|
62
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
63
|
+
*****
|
|
64
|
+
---
|
|
65
|
+
<hr />
|
|
66
|
+
---
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Hrule -- a line of dashes
|
|
70
|
+
it "produces a horizontal rule tag from three dashes on a line by themselves" do
|
|
71
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
72
|
+
---------------------------------------
|
|
73
|
+
---
|
|
74
|
+
<hr />
|
|
75
|
+
---
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Hrule -- three spaced-out dashes
|
|
79
|
+
it "produces a horizontal rule tag from three dashes with intervening spaces on a line " +
|
|
80
|
+
" by themselves" do
|
|
81
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
82
|
+
- - -
|
|
83
|
+
---
|
|
84
|
+
<hr />
|
|
85
|
+
---
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
|
|
@@ -0,0 +1,92 @@
|
|
|
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, "images" do
|
|
28
|
+
include BlueCloth::TestConstants,
|
|
29
|
+
BlueCloth::Matchers
|
|
30
|
+
|
|
31
|
+
### [Images]
|
|
32
|
+
|
|
33
|
+
# Inline image with title
|
|
34
|
+
it "transforms inline images with a title in double quotes to an IMG tag" do
|
|
35
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
36
|
+

|
|
37
|
+
---
|
|
38
|
+
<p><img src="/path/img.jpg" title="Title" alt="alt text" /></p>
|
|
39
|
+
---
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Inline image with title (single-quotes)
|
|
43
|
+
it "transforms inline images with a title in single quotes to an IMG tag" do
|
|
44
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
45
|
+

|
|
46
|
+
---
|
|
47
|
+
<p><img src="/path/img.jpg" title="Title" alt="alt text" /></p>
|
|
48
|
+
---
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Inline image with title (with embedded quotes)
|
|
52
|
+
it "transforms inline images with a title that includes quotes to an IMG tag" do
|
|
53
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
54
|
+

|
|
55
|
+
---
|
|
56
|
+
<p><img src="/path/img.jpg" title="The "Title" Image" alt="alt text" /></p>
|
|
57
|
+
---
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Inline image without title
|
|
61
|
+
it "transforms inline images without a title to an IMG tag" do
|
|
62
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
63
|
+

|
|
64
|
+
---
|
|
65
|
+
<p><img src="/path/img.jpg" alt="alt text" /></p>
|
|
66
|
+
---
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Inline image with quoted alt text
|
|
70
|
+
it "transforms inline images with quoted alt text to an IMG tag" do
|
|
71
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
72
|
+

|
|
73
|
+
---
|
|
74
|
+
<p><img src="/path/img.jpg" alt="the "alt text"" /></p>
|
|
75
|
+
---
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
# Reference image
|
|
80
|
+
it "transforms image references with a title to an IMG tag" do
|
|
81
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
82
|
+
![alt text][id]
|
|
83
|
+
|
|
84
|
+
[id]: /url/to/img.jpg "Title"
|
|
85
|
+
---
|
|
86
|
+
<p><img src="/url/to/img.jpg" title="Title" alt="alt text" /></p>
|
|
87
|
+
---
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
|
|
@@ -0,0 +1,238 @@
|
|
|
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, "document with inline HTML" do
|
|
28
|
+
include BlueCloth::TestConstants,
|
|
29
|
+
BlueCloth::Matchers
|
|
30
|
+
|
|
31
|
+
it "preserves TABLE block" do
|
|
32
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
33
|
+
This is a regular paragraph.
|
|
34
|
+
|
|
35
|
+
<table>
|
|
36
|
+
<tr>
|
|
37
|
+
<td>Foo</td>
|
|
38
|
+
</tr>
|
|
39
|
+
</table>
|
|
40
|
+
|
|
41
|
+
This is another regular paragraph.
|
|
42
|
+
---
|
|
43
|
+
<p>This is a regular paragraph.</p>
|
|
44
|
+
|
|
45
|
+
<table>
|
|
46
|
+
<tr>
|
|
47
|
+
<td>Foo</td>
|
|
48
|
+
</tr>
|
|
49
|
+
</table>
|
|
50
|
+
|
|
51
|
+
<p>This is another regular paragraph.</p>
|
|
52
|
+
---
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "preserves DIV block" do
|
|
56
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
57
|
+
This is a regular paragraph.
|
|
58
|
+
|
|
59
|
+
<div>
|
|
60
|
+
Something
|
|
61
|
+
</div>
|
|
62
|
+
Something else.
|
|
63
|
+
---
|
|
64
|
+
<p>This is a regular paragraph.</p>
|
|
65
|
+
|
|
66
|
+
<div>
|
|
67
|
+
Something
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<p>Something else.</p>
|
|
71
|
+
---
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
it "preserves HRs" do
|
|
76
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
77
|
+
This is a regular paragraph.
|
|
78
|
+
|
|
79
|
+
<hr />
|
|
80
|
+
|
|
81
|
+
Something else.
|
|
82
|
+
---
|
|
83
|
+
<p>This is a regular paragraph.</p>
|
|
84
|
+
|
|
85
|
+
<hr />
|
|
86
|
+
|
|
87
|
+
<p>Something else.</p>
|
|
88
|
+
---
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
it "preserves fancy HRs" do
|
|
93
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
94
|
+
This is a regular paragraph.
|
|
95
|
+
|
|
96
|
+
<hr class="publishers-mark" id="first-hrule" />
|
|
97
|
+
|
|
98
|
+
Something else.
|
|
99
|
+
---
|
|
100
|
+
<p>This is a regular paragraph.</p>
|
|
101
|
+
|
|
102
|
+
<hr class="publishers-mark" id="first-hrule" />
|
|
103
|
+
|
|
104
|
+
<p>Something else.</p>
|
|
105
|
+
---
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
it "preserves IFRAMEs" do
|
|
110
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
111
|
+
This is a regular paragraph.
|
|
112
|
+
|
|
113
|
+
<iframe src="foo.html" id="foo-frame"></iframe>
|
|
114
|
+
|
|
115
|
+
Something else.
|
|
116
|
+
---
|
|
117
|
+
<p>This is a regular paragraph.</p>
|
|
118
|
+
|
|
119
|
+
<iframe src="foo.html" id="foo-frame"></iframe>
|
|
120
|
+
|
|
121
|
+
<p>Something else.</p>
|
|
122
|
+
---
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
it "preserves MathML block" do
|
|
127
|
+
pending "discount doesn't support this, it explicitly matches block-level HTML elements only"
|
|
128
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
129
|
+
Examples
|
|
130
|
+
--------
|
|
131
|
+
|
|
132
|
+
Now that we have met some of the key players, it is time to see what we can
|
|
133
|
+
do. Here are some examples and comments which illustrate the use of the basic
|
|
134
|
+
layout and token elements. Consider the expression x2 + 4x + 4 = 0. A basic
|
|
135
|
+
MathML presentation encoding for this would be:
|
|
136
|
+
|
|
137
|
+
<math>
|
|
138
|
+
<mrow>
|
|
139
|
+
<msup>
|
|
140
|
+
<mi>x</mi>
|
|
141
|
+
<mn>2</mn>
|
|
142
|
+
</msup>
|
|
143
|
+
<mo>+</mo>
|
|
144
|
+
<mn>4</mn>
|
|
145
|
+
<mi>x</mi>
|
|
146
|
+
<mo>+</mo>
|
|
147
|
+
<mn>4</mn>
|
|
148
|
+
<mo>=</mo>
|
|
149
|
+
<mn>0</mn>
|
|
150
|
+
</mrow>
|
|
151
|
+
</math>
|
|
152
|
+
|
|
153
|
+
This encoding will display as you would expect. However, if we were interested
|
|
154
|
+
in reusing this expression in unknown situations, we would likely want to spend
|
|
155
|
+
a little more effort analyzing and encoding the logical expression structure.
|
|
156
|
+
---
|
|
157
|
+
<h2>Examples</h2>
|
|
158
|
+
|
|
159
|
+
<p>Now that we have met some of the key players, it is time to see what we can
|
|
160
|
+
do. Here are some examples and comments which illustrate the use of the basic
|
|
161
|
+
layout and token elements. Consider the expression x2 + 4x + 4 = 0. A basic
|
|
162
|
+
MathML presentation encoding for this would be:</p>
|
|
163
|
+
|
|
164
|
+
<math>
|
|
165
|
+
<mrow>
|
|
166
|
+
<msup>
|
|
167
|
+
<mi>x</mi>
|
|
168
|
+
<mn>2</mn>
|
|
169
|
+
</msup>
|
|
170
|
+
<mo>+</mo>
|
|
171
|
+
<mn>4</mn>
|
|
172
|
+
<mi>x</mi>
|
|
173
|
+
<mo>+</mo>
|
|
174
|
+
<mn>4</mn>
|
|
175
|
+
<mo>=</mo>
|
|
176
|
+
<mn>0</mn>
|
|
177
|
+
</mrow>
|
|
178
|
+
</math>
|
|
179
|
+
|
|
180
|
+
<p>This encoding will display as you would expect. However, if we were interested
|
|
181
|
+
in reusing this expression in unknown situations, we would likely want to spend
|
|
182
|
+
a little more effort analyzing and encoding the logical expression structure.</p>
|
|
183
|
+
---
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
it "preserves span-level HTML" do
|
|
188
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
189
|
+
This is some stuff with a <span class="foo">spanned bit of text</span> in
|
|
190
|
+
it. And <del>this *should* be a bit of deleted text</del> which should be
|
|
191
|
+
preserved, and part of it emphasized.
|
|
192
|
+
---
|
|
193
|
+
<p>This is some stuff with a <span class="foo">spanned bit of text</span> in
|
|
194
|
+
it. And <del>this <em>should</em> be a bit of deleted text</del> which should be
|
|
195
|
+
preserved, and part of it emphasized.</p>
|
|
196
|
+
---
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
it "preserves block-level HTML case-insensitively" do
|
|
200
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
201
|
+
This is a regular paragraph.
|
|
202
|
+
|
|
203
|
+
<TABLE>
|
|
204
|
+
<TR>
|
|
205
|
+
<TD>Foo</TD>
|
|
206
|
+
</TR>
|
|
207
|
+
</TABLE>
|
|
208
|
+
|
|
209
|
+
This is another regular paragraph.
|
|
210
|
+
---
|
|
211
|
+
<p>This is a regular paragraph.</p>
|
|
212
|
+
|
|
213
|
+
<TABLE>
|
|
214
|
+
<TR>
|
|
215
|
+
<TD>Foo</TD>
|
|
216
|
+
</TR>
|
|
217
|
+
</TABLE>
|
|
218
|
+
|
|
219
|
+
<p>This is another regular paragraph.</p>
|
|
220
|
+
---
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
it "preserves span-level HTML case-insensitively" do
|
|
224
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
|
225
|
+
This is some stuff with a <SPAN CLASS="foo">spanned bit of text</SPAN> in
|
|
226
|
+
it. And <DEL>this *should* be a bit of deleted text</DEL> which should be
|
|
227
|
+
preserved, and part of it emphasized.
|
|
228
|
+
---
|
|
229
|
+
<p>This is some stuff with a <SPAN CLASS="foo">spanned bit of text</SPAN> in
|
|
230
|
+
it. And <DEL>this <em>should</em> be a bit of deleted text</DEL> which should be
|
|
231
|
+
preserved, and part of it emphasized.</p>
|
|
232
|
+
---
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
|