BlueCloth 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +506 -0
- data/LICENSE +340 -0
- data/README +99 -0
- data/bin/bluecloth +83 -0
- data/install.rb +185 -0
- data/lib/bluecloth.rb +1144 -0
- data/test.rb +117 -0
- data/tests/00_Class.tests.rb +71 -0
- data/tests/05_Markdown.tests.rb +1541 -0
- data/tests/10_Bug.tests.rb +67 -0
- data/tests/15_Contrib.tests.rb +132 -0
- data/tests/bctestcase.rb +283 -0
- data/tests/data/antsugar.txt +34 -0
- data/tests/data/hr-dos.txt +4 -0
- data/tests/data/ml-announce.txt +17 -0
- data/tests/data/re-overflow.txt +67 -0
- data/tests/data/re-overflow2.txt +281 -0
- data/utils.rb +739 -0
- metadata +74 -0
data/test.rb
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
#
|
3
|
+
# Test suite for BlueCloth classes
|
4
|
+
# $Id$
|
5
|
+
#
|
6
|
+
|
7
|
+
BEGIN {
|
8
|
+
$basedir = File::dirname( __FILE__ )
|
9
|
+
["lib", "tests", "redist"].each do |subdir|
|
10
|
+
$LOAD_PATH.unshift File::join( $basedir, subdir )
|
11
|
+
end
|
12
|
+
|
13
|
+
require "#{$basedir}/utils"
|
14
|
+
include UtilityFunctions
|
15
|
+
}
|
16
|
+
|
17
|
+
verboseOff {
|
18
|
+
require 'bctestcase'
|
19
|
+
require 'find'
|
20
|
+
require 'test/unit'
|
21
|
+
require 'test/unit/testsuite'
|
22
|
+
require 'test/unit/ui/console/testrunner'
|
23
|
+
require 'optparse'
|
24
|
+
}
|
25
|
+
|
26
|
+
# Turn off output buffering
|
27
|
+
$stderr.sync = $stdout.sync = true
|
28
|
+
$DebugPattern = nil
|
29
|
+
|
30
|
+
# Initialize variables
|
31
|
+
safelevel = 0
|
32
|
+
patterns = []
|
33
|
+
requires = []
|
34
|
+
|
35
|
+
# Parse command-line switches
|
36
|
+
ARGV.options {|oparser|
|
37
|
+
oparser.banner = "Usage: #$0 [options] [TARGETS]\n"
|
38
|
+
|
39
|
+
oparser.on( "--debug[=PATTERN]", "-d[=PATTERN]", String,
|
40
|
+
"Turn debugging on (for tests which match PATTERN)" ) {|arg|
|
41
|
+
if arg
|
42
|
+
$DebugPattern = Regexp::new( arg )
|
43
|
+
puts "Turned debugging on for %p." % $DebugPattern
|
44
|
+
else
|
45
|
+
$DEBUG = true
|
46
|
+
debugMsg "Turned debugging on globally."
|
47
|
+
end
|
48
|
+
}
|
49
|
+
|
50
|
+
oparser.on( "--verbose", "-v", TrueClass, "Make progress verbose" ) {
|
51
|
+
$VERBOSE = true
|
52
|
+
debugMsg "Turned verbose on."
|
53
|
+
}
|
54
|
+
|
55
|
+
# Handle the 'help' option
|
56
|
+
oparser.on( "--help", "-h", "Display this text." ) {
|
57
|
+
$stderr.puts oparser
|
58
|
+
exit!(0)
|
59
|
+
}
|
60
|
+
|
61
|
+
oparser.parse!
|
62
|
+
}
|
63
|
+
|
64
|
+
# Parse test patterns
|
65
|
+
ARGV.each {|pat| patterns << Regexp::new( pat, Regexp::IGNORECASE )}
|
66
|
+
$stderr.puts "#{patterns.length} patterns given on the command line"
|
67
|
+
|
68
|
+
### Load all the tests from the tests dir
|
69
|
+
Find.find("#{$basedir}/tests") {|file|
|
70
|
+
Find.prune if /\/\./ =~ file or /~$/ =~ file
|
71
|
+
Find.prune if /TEMPLATE/ =~ file
|
72
|
+
next if File.stat( file ).directory?
|
73
|
+
|
74
|
+
unless patterns.empty?
|
75
|
+
Find.prune unless patterns.find {|pat| pat =~ file}
|
76
|
+
end
|
77
|
+
|
78
|
+
debugMsg "Considering '%s': " % file
|
79
|
+
next unless file =~ /\.tests.rb$/
|
80
|
+
debugMsg "Requiring '%s'..." % file
|
81
|
+
require "#{file}"
|
82
|
+
requires << file
|
83
|
+
}
|
84
|
+
|
85
|
+
$stderr.puts "Required #{requires.length} files."
|
86
|
+
unless patterns.empty?
|
87
|
+
$stderr.puts "[" + requires.sort.join( ", " ) + "]"
|
88
|
+
end
|
89
|
+
|
90
|
+
# Build the test suite
|
91
|
+
class BlueClothTests
|
92
|
+
class << self
|
93
|
+
def suite
|
94
|
+
suite = Test::Unit::TestSuite.new( "BlueCloth" )
|
95
|
+
|
96
|
+
if suite.respond_to?( :add )
|
97
|
+
ObjectSpace.each_object( Class ) {|klass|
|
98
|
+
suite.add( klass.suite ) if klass < BlueCloth::TestCase
|
99
|
+
}
|
100
|
+
else
|
101
|
+
ObjectSpace.each_object( Class ) {|klass|
|
102
|
+
suite << klass.suite if klass < BlueCloth::TestCase
|
103
|
+
}
|
104
|
+
end
|
105
|
+
|
106
|
+
return suite
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# Run tests
|
112
|
+
$SAFE = safelevel
|
113
|
+
Test::Unit::UI::Console::TestRunner.new( BlueClothTests ).start
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
@@ -0,0 +1,71 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
#
|
3
|
+
# Unit test for the BlueCloth class object
|
4
|
+
# $Id: TEMPLATE.rb.tpl,v 1.2 2003/09/11 04:59:51 deveiant Exp $
|
5
|
+
#
|
6
|
+
# Copyright (c) 2004 The FaerieMUD Consortium.
|
7
|
+
#
|
8
|
+
|
9
|
+
if !defined?( BlueCloth ) || !defined?( BlueCloth::TestCase )
|
10
|
+
basedir = File::dirname( __FILE__ )
|
11
|
+
require File::join( basedir, 'bctestcase' )
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
### This test case tests ...
|
16
|
+
class BlueClothClassTestCase < BlueCloth::TestCase
|
17
|
+
|
18
|
+
TestString = "foo"
|
19
|
+
|
20
|
+
def test_00_class_constant
|
21
|
+
printTestHeader "BlueCloth: Class Constant"
|
22
|
+
|
23
|
+
assert Object::constants.include?( "BlueCloth" ),
|
24
|
+
"No BlueCloth constant in Object"
|
25
|
+
assert_instance_of Class, BlueCloth
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_01_instantiation
|
29
|
+
printTestHeader "BlueCloth: Instantiation"
|
30
|
+
rval = nil
|
31
|
+
|
32
|
+
# With no argument... ("")
|
33
|
+
assert_nothing_raised {
|
34
|
+
rval = BlueCloth::new
|
35
|
+
}
|
36
|
+
assert_instance_of BlueCloth, rval
|
37
|
+
assert_kind_of String, rval
|
38
|
+
assert_equal "", rval
|
39
|
+
|
40
|
+
# String argument
|
41
|
+
assert_nothing_raised {
|
42
|
+
rval = BlueCloth::new TestString
|
43
|
+
}
|
44
|
+
assert_instance_of BlueCloth, rval
|
45
|
+
assert_kind_of String, rval
|
46
|
+
assert_equal TestString, rval
|
47
|
+
|
48
|
+
addSetupBlock {
|
49
|
+
debugMsg "Creating a new BlueCloth"
|
50
|
+
@obj = BlueCloth::new( TestString )
|
51
|
+
}
|
52
|
+
addTeardownBlock {
|
53
|
+
@obj = nil
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_02_duplication
|
58
|
+
printTestHeader "BlueCloth: Duplication"
|
59
|
+
rval = nil
|
60
|
+
|
61
|
+
assert_nothing_raised {
|
62
|
+
rval = @obj.dup
|
63
|
+
}
|
64
|
+
assert_instance_of BlueCloth, rval
|
65
|
+
assert_kind_of String, rval
|
66
|
+
assert_equal TestString, rval
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
end
|
71
|
+
|
@@ -0,0 +1,1541 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
#
|
3
|
+
# Test case for BlueCloth Markdown transforms.
|
4
|
+
# $Id: TEMPLATE.rb.tpl,v 1.2 2003/09/11 04:59:51 deveiant Exp $
|
5
|
+
#
|
6
|
+
# Copyright (c) 2004 The FaerieMUD Consortium.
|
7
|
+
#
|
8
|
+
|
9
|
+
if !defined?( BlueCloth ) || !defined?( BlueCloth::TestCase )
|
10
|
+
basedir = File::dirname( __FILE__ )
|
11
|
+
require File::join( basedir, 'bctestcase' )
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
### This test case tests ...
|
16
|
+
class SubfunctionsTestCase < BlueCloth::TestCase
|
17
|
+
|
18
|
+
### Test email address output
|
19
|
+
Emails = %w[
|
20
|
+
address@example.com
|
21
|
+
foo-list-admin@bar.com
|
22
|
+
fu@bar.COM
|
23
|
+
baz@ruby-lang.org
|
24
|
+
foo-tim-bazzle@bar-hop.co.uk
|
25
|
+
littlestar@twinkle.twinkle.band.CO.ZA
|
26
|
+
ll@lll.lllll.ll
|
27
|
+
Ull@Ulll.Ulllll.ll
|
28
|
+
UUUU1@UU1.UU1UUU.UU
|
29
|
+
l@ll.ll
|
30
|
+
Ull.Ullll@llll.ll
|
31
|
+
Ulll-Ull.Ulllll@ll.ll
|
32
|
+
1@111.ll
|
33
|
+
]
|
34
|
+
# I can't see a way to handle IDNs clearly yet, so these will have to wait.
|
35
|
+
# info@�ko.de
|
36
|
+
# jemand@b�ro.de
|
37
|
+
# irgendwo-interre�ant@d�gta.se
|
38
|
+
#]
|
39
|
+
|
40
|
+
def test_10_email_address
|
41
|
+
printTestHeader "BlueCloth: Inline email address"
|
42
|
+
rval = match = nil
|
43
|
+
|
44
|
+
Emails.each {|addr|
|
45
|
+
assert_nothing_raised {
|
46
|
+
rval = BlueCloth::new( "<#{addr}>" ).to_html
|
47
|
+
}
|
48
|
+
|
49
|
+
match = %r{<p><a href="([^\"]+)">[^<]+</a></p>}.match( rval )
|
50
|
+
assert_not_nil match, "Match against output #{rval}"
|
51
|
+
assert_equal "mailto:#{addr}", decode( match[1] )
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def decode( str )
|
57
|
+
str.gsub( /&#(x[a-f0-9]+|\d{3});/i ) {|match|
|
58
|
+
code = $1
|
59
|
+
debugMsg "Decoding %p" % code
|
60
|
+
|
61
|
+
case code
|
62
|
+
when /^x([a-f0-9]+)/i
|
63
|
+
debugMsg " (hex) = %p" % $1.to_i(16).chr
|
64
|
+
$1.to_i(16).chr
|
65
|
+
when /\d{3}/
|
66
|
+
debugMsg " (oct) = %p" % code.to_i.chr
|
67
|
+
code.to_i.chr
|
68
|
+
else
|
69
|
+
raise "Hmmm... malformed entity %p" % code
|
70
|
+
end
|
71
|
+
}
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
#################################################################
|
77
|
+
### A U T O - G E N E R A T E D T E S T S
|
78
|
+
#################################################################
|
79
|
+
|
80
|
+
# Parse the data section into a hash of test specifications
|
81
|
+
TestSets = {}
|
82
|
+
begin
|
83
|
+
seenEnd = false
|
84
|
+
inMetaSection = true
|
85
|
+
inInputSection = true
|
86
|
+
section, description, input, output = '', '', '', ''
|
87
|
+
linenum = 0
|
88
|
+
|
89
|
+
# Read this file, skipping lines until the __END__ token. Then start
|
90
|
+
# reading the tests.
|
91
|
+
File::foreach( __FILE__ ) {|line|
|
92
|
+
linenum += 1
|
93
|
+
if /^__END__/ =~ line then seenEnd = true; next end
|
94
|
+
debugMsg "#{linenum}: #{line.chomp}"
|
95
|
+
next unless seenEnd
|
96
|
+
|
97
|
+
# Start off in the meta section, which has sections and
|
98
|
+
# descriptions.
|
99
|
+
if inMetaSection
|
100
|
+
|
101
|
+
case line
|
102
|
+
|
103
|
+
# Left angles switch into data section for the current section
|
104
|
+
# and description.
|
105
|
+
when /^<<</
|
106
|
+
inMetaSection = false
|
107
|
+
next
|
108
|
+
|
109
|
+
# Section headings look like:
|
110
|
+
# ### [Code blocks]
|
111
|
+
when /^### \[([^\]]+)\]/
|
112
|
+
section = $1.chomp
|
113
|
+
TestSets[ section ] ||= {}
|
114
|
+
|
115
|
+
# Descriptions look like:
|
116
|
+
# # Para plus code block
|
117
|
+
when /^# (.*)/
|
118
|
+
description = $1.chomp
|
119
|
+
TestSets[ section ][ description ] ||= {
|
120
|
+
:line => linenum,
|
121
|
+
:sets => [],
|
122
|
+
}
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
# Data section has input and expected output parts
|
127
|
+
else
|
128
|
+
|
129
|
+
case line
|
130
|
+
|
131
|
+
# Right angles terminate a data section, at which point we
|
132
|
+
# should have enough data to add a test.
|
133
|
+
when /^>>>/
|
134
|
+
TestSets[ section ][ description ][:sets] << [ input.chomp, output.chomp ]
|
135
|
+
|
136
|
+
inMetaSection = true
|
137
|
+
inInputSection = true
|
138
|
+
input = ''; output = ''
|
139
|
+
|
140
|
+
# 3-Dashed divider with text divides input from output
|
141
|
+
when /^--- (.+)/
|
142
|
+
inInputSection = false
|
143
|
+
|
144
|
+
# Anything else adds to either input or output
|
145
|
+
else
|
146
|
+
if inInputSection
|
147
|
+
input += line
|
148
|
+
else
|
149
|
+
output += line
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
}
|
154
|
+
end
|
155
|
+
|
156
|
+
debugMsg "Test sets: %p" % TestSets
|
157
|
+
|
158
|
+
# Auto-generate tests out of the test specifications
|
159
|
+
TestSets.each {|sname, section|
|
160
|
+
|
161
|
+
# Generate a test method for each section
|
162
|
+
section.each do |desc, test|
|
163
|
+
methname = "test_%03d_%s" %
|
164
|
+
[ test[:line], desc.gsub(/\W+/, '_').downcase ]
|
165
|
+
|
166
|
+
# Header
|
167
|
+
code = %{
|
168
|
+
def #{methname}
|
169
|
+
printTestHeader "BlueCloth: #{desc}"
|
170
|
+
rval = nil
|
171
|
+
}
|
172
|
+
|
173
|
+
# An assertion for each input/output pair
|
174
|
+
test[:sets].each {|input, output|
|
175
|
+
code << %{
|
176
|
+
assert_nothing_raised {
|
177
|
+
obj = BlueCloth::new(%p)
|
178
|
+
rval = obj.to_html
|
179
|
+
}
|
180
|
+
assert_equal %p, rval
|
181
|
+
|
182
|
+
} % [ input, output ]
|
183
|
+
}
|
184
|
+
|
185
|
+
code << %{
|
186
|
+
end
|
187
|
+
}
|
188
|
+
|
189
|
+
|
190
|
+
debugMsg "--- %s [%s]:\n%s\n---\n" % [sname, desc, code]
|
191
|
+
eval code
|
192
|
+
end
|
193
|
+
|
194
|
+
}
|
195
|
+
|
196
|
+
end
|
197
|
+
|
198
|
+
|
199
|
+
__END__
|
200
|
+
|
201
|
+
### [Paragraphs and Line Breaks]
|
202
|
+
|
203
|
+
# Paragraphs
|
204
|
+
<<<
|
205
|
+
This is some stuff that should all be
|
206
|
+
put in one paragraph
|
207
|
+
even though
|
208
|
+
it occurs over several lines.
|
209
|
+
|
210
|
+
And this is a another
|
211
|
+
one.
|
212
|
+
--- Should become:
|
213
|
+
<p>This is some stuff that should all be
|
214
|
+
put in one paragraph
|
215
|
+
even though
|
216
|
+
it occurs over several lines.</p>
|
217
|
+
|
218
|
+
<p>And this is a another
|
219
|
+
one.</p>
|
220
|
+
>>>
|
221
|
+
|
222
|
+
# Line breaks
|
223
|
+
<<<
|
224
|
+
Mostly the same kind of thing
|
225
|
+
with two spaces at the end
|
226
|
+
of each line
|
227
|
+
should result in
|
228
|
+
line breaks, though.
|
229
|
+
|
230
|
+
And this is a another
|
231
|
+
one.
|
232
|
+
--- Should become:
|
233
|
+
<p>Mostly the same kind of thing<br/>
|
234
|
+
with two spaces at the end<br/>
|
235
|
+
of each line<br/>
|
236
|
+
should result in<br/>
|
237
|
+
line breaks, though.</p>
|
238
|
+
|
239
|
+
<p>And this is a another<br/>
|
240
|
+
one.</p>
|
241
|
+
>>>
|
242
|
+
|
243
|
+
# Escaping special characters
|
244
|
+
<<<
|
245
|
+
The left shift operator, which is written as <<, is often used & greatly admired.
|
246
|
+
--- Should become:
|
247
|
+
<p>The left shift operator, which is written as <<, is often used & greatly admired.</p>
|
248
|
+
>>>
|
249
|
+
|
250
|
+
# Preservation of named entities
|
251
|
+
<<<
|
252
|
+
The left shift operator, which is written as <<, is often used & greatly admired.
|
253
|
+
--- Should become:
|
254
|
+
<p>The left shift operator, which is written as <<, is often used & greatly admired.</p>
|
255
|
+
>>>
|
256
|
+
|
257
|
+
# Preservation of decimal-encoded entities
|
258
|
+
<<<
|
259
|
+
The left shift operator, which is written as <<, is often used & greatly admired.
|
260
|
+
--- Should become:
|
261
|
+
<p>The left shift operator, which is written as <<, is often used & greatly admired.</p>
|
262
|
+
>>>
|
263
|
+
|
264
|
+
# Preservation of hex-encoded entities
|
265
|
+
<<<
|
266
|
+
The left shift operator, which is written as <<, is often used & greatly admired.
|
267
|
+
--- Should become:
|
268
|
+
<p>The left shift operator, which is written as <<, is often used & greatly admired.</p>
|
269
|
+
>>>
|
270
|
+
|
271
|
+
# Inline HTML - table tags
|
272
|
+
<<<
|
273
|
+
This is a regular paragraph.
|
274
|
+
|
275
|
+
<table>
|
276
|
+
<tr>
|
277
|
+
<td>Foo</td>
|
278
|
+
</tr>
|
279
|
+
</table>
|
280
|
+
|
281
|
+
This is another regular paragraph.
|
282
|
+
--- Should become:
|
283
|
+
<p>This is a regular paragraph.</p>
|
284
|
+
|
285
|
+
<table>
|
286
|
+
<tr>
|
287
|
+
<td>Foo</td>
|
288
|
+
</tr>
|
289
|
+
</table>
|
290
|
+
|
291
|
+
<p>This is another regular paragraph.</p>
|
292
|
+
>>>
|
293
|
+
|
294
|
+
# Inline HTML - div tags
|
295
|
+
<<<
|
296
|
+
This is a regular paragraph.
|
297
|
+
|
298
|
+
<div>
|
299
|
+
Something
|
300
|
+
</div>
|
301
|
+
Something else.
|
302
|
+
--- Should become:
|
303
|
+
<p>This is a regular paragraph.</p>
|
304
|
+
|
305
|
+
<div>
|
306
|
+
Something
|
307
|
+
</div>
|
308
|
+
|
309
|
+
<p>Something else.</p>
|
310
|
+
>>>
|
311
|
+
|
312
|
+
|
313
|
+
# Inline HTML - Plain HR
|
314
|
+
<<<
|
315
|
+
This is a regular paragraph.
|
316
|
+
|
317
|
+
<hr />
|
318
|
+
|
319
|
+
Something else.
|
320
|
+
--- Should become:
|
321
|
+
<p>This is a regular paragraph.</p>
|
322
|
+
|
323
|
+
<hr />
|
324
|
+
|
325
|
+
<p>Something else.</p>
|
326
|
+
>>>
|
327
|
+
|
328
|
+
|
329
|
+
# Inline HTML - Fancy HR
|
330
|
+
<<<
|
331
|
+
This is a regular paragraph.
|
332
|
+
|
333
|
+
<hr class="publishers-mark" id="first-hrule" />
|
334
|
+
|
335
|
+
Something else.
|
336
|
+
--- Should become:
|
337
|
+
<p>This is a regular paragraph.</p>
|
338
|
+
|
339
|
+
<hr class="publishers-mark" id="first-hrule" />
|
340
|
+
|
341
|
+
<p>Something else.</p>
|
342
|
+
>>>
|
343
|
+
|
344
|
+
|
345
|
+
# Inline HTML - Iframe
|
346
|
+
<<<
|
347
|
+
This is a regular paragraph.
|
348
|
+
|
349
|
+
<iframe src="foo.html" id="foo-frame"></iframe>
|
350
|
+
|
351
|
+
Something else.
|
352
|
+
--- Should become:
|
353
|
+
<p>This is a regular paragraph.</p>
|
354
|
+
|
355
|
+
<iframe src="foo.html" id="foo-frame"></iframe>
|
356
|
+
|
357
|
+
<p>Something else.</p>
|
358
|
+
>>>
|
359
|
+
|
360
|
+
|
361
|
+
# Inline HTML - mathml
|
362
|
+
<<<
|
363
|
+
Examples
|
364
|
+
--------
|
365
|
+
|
366
|
+
Now that we have met some of the key players, it is time to see what we can
|
367
|
+
do. Here are some examples and comments which illustrate the use of the basic
|
368
|
+
layout and token elements. Consider the expression x2 + 4x + 4 = 0. A basic
|
369
|
+
MathML presentation encoding for this would be:
|
370
|
+
|
371
|
+
<math>
|
372
|
+
<mrow>
|
373
|
+
<msup>
|
374
|
+
<mi>x</mi>
|
375
|
+
<mn>2</mn>
|
376
|
+
</msup>
|
377
|
+
<mo>+</mo>
|
378
|
+
<mn>4</mn>
|
379
|
+
<mi>x</mi>
|
380
|
+
<mo>+</mo>
|
381
|
+
<mn>4</mn>
|
382
|
+
<mo>=</mo>
|
383
|
+
<mn>0</mn>
|
384
|
+
</mrow>
|
385
|
+
</math>
|
386
|
+
|
387
|
+
This encoding will display as you would expect. However, if we were interested
|
388
|
+
in reusing this expression in unknown situations, we would likely want to spend
|
389
|
+
a little more effort analyzing and encoding the logical expression structure.
|
390
|
+
|
391
|
+
--- Should become:
|
392
|
+
<h2>Examples</h2>
|
393
|
+
|
394
|
+
<p>Now that we have met some of the key players, it is time to see what we can
|
395
|
+
do. Here are some examples and comments which illustrate the use of the basic
|
396
|
+
layout and token elements. Consider the expression x2 + 4x + 4 = 0. A basic
|
397
|
+
MathML presentation encoding for this would be:</p>
|
398
|
+
|
399
|
+
<math>
|
400
|
+
<mrow>
|
401
|
+
<msup>
|
402
|
+
<mi>x</mi>
|
403
|
+
<mn>2</mn>
|
404
|
+
</msup>
|
405
|
+
<mo>+</mo>
|
406
|
+
<mn>4</mn>
|
407
|
+
<mi>x</mi>
|
408
|
+
<mo>+</mo>
|
409
|
+
<mn>4</mn>
|
410
|
+
<mo>=</mo>
|
411
|
+
<mn>0</mn>
|
412
|
+
</mrow>
|
413
|
+
</math>
|
414
|
+
|
415
|
+
<p>This encoding will display as you would expect. However, if we were interested
|
416
|
+
in reusing this expression in unknown situations, we would likely want to spend
|
417
|
+
a little more effort analyzing and encoding the logical expression structure.</p>
|
418
|
+
>>>
|
419
|
+
|
420
|
+
|
421
|
+
# Span-level HTML
|
422
|
+
<<<
|
423
|
+
This is some stuff with a <span class="foo">spanned bit of text</span> in
|
424
|
+
it. And <del>this *should* be a bit of deleted text</del> which should be
|
425
|
+
preserved, and part of it emphasized.
|
426
|
+
--- Should become:
|
427
|
+
<p>This is some stuff with a <span class="foo">spanned bit of text</span> in
|
428
|
+
it. And <del>this <em>should</em> be a bit of deleted text</del> which should be
|
429
|
+
preserved, and part of it emphasized.</p>
|
430
|
+
>>>
|
431
|
+
|
432
|
+
# Inline HTML (Case-sensitivity)
|
433
|
+
<<<
|
434
|
+
This is a regular paragraph.
|
435
|
+
|
436
|
+
<TABLE>
|
437
|
+
<TR>
|
438
|
+
<TD>Foo</TD>
|
439
|
+
</TR>
|
440
|
+
</TABLE>
|
441
|
+
|
442
|
+
This is another regular paragraph.
|
443
|
+
--- Should become:
|
444
|
+
<p>This is a regular paragraph.</p>
|
445
|
+
|
446
|
+
<TABLE>
|
447
|
+
<TR>
|
448
|
+
<TD>Foo</TD>
|
449
|
+
</TR>
|
450
|
+
</TABLE>
|
451
|
+
|
452
|
+
<p>This is another regular paragraph.</p>
|
453
|
+
>>>
|
454
|
+
|
455
|
+
# Span-level HTML (Case-sensitivity)
|
456
|
+
<<<
|
457
|
+
This is some stuff with a <SPAN CLASS="foo">spanned bit of text</SPAN> in
|
458
|
+
it. And <DEL>this *should* be a bit of deleted text</DEL> which should be
|
459
|
+
preserved, and part of it emphasized.
|
460
|
+
--- Should become:
|
461
|
+
<p>This is some stuff with a <SPAN CLASS="foo">spanned bit of text</SPAN> in
|
462
|
+
it. And <DEL>this <em>should</em> be a bit of deleted text</DEL> which should be
|
463
|
+
preserved, and part of it emphasized.</p>
|
464
|
+
>>>
|
465
|
+
|
466
|
+
|
467
|
+
|
468
|
+
### [Code spans]
|
469
|
+
|
470
|
+
# Single backtick
|
471
|
+
<<<
|
472
|
+
Making `code` work for you
|
473
|
+
--- Should become:
|
474
|
+
<p>Making <code>code</code> work for you</p>
|
475
|
+
>>>
|
476
|
+
|
477
|
+
# Literal backtick with doubling
|
478
|
+
<<<
|
479
|
+
Making `` `code` `` work for you
|
480
|
+
--- Should become:
|
481
|
+
<p>Making <code>`code`</code> work for you</p>
|
482
|
+
>>>
|
483
|
+
|
484
|
+
# Many repetitions
|
485
|
+
<<<
|
486
|
+
Making `````code````` work for you
|
487
|
+
--- Should become:
|
488
|
+
<p>Making <code>code</code> work for you</p>
|
489
|
+
>>>
|
490
|
+
|
491
|
+
# Two in a row
|
492
|
+
<<<
|
493
|
+
This `thing` should be `two` spans.
|
494
|
+
--- Should become:
|
495
|
+
<p>This <code>thing</code> should be <code>two</code> spans.</p>
|
496
|
+
>>>
|
497
|
+
|
498
|
+
# At the beginning of a newline
|
499
|
+
<<<
|
500
|
+
I should think that the
|
501
|
+
`tar` command would be universal.
|
502
|
+
--- Should become:
|
503
|
+
<p>I should think that the
|
504
|
+
<code>tar</code> command would be universal.</p>
|
505
|
+
>>>
|
506
|
+
|
507
|
+
# Entity escaping
|
508
|
+
<<<
|
509
|
+
The left angle-bracket (`<`) can also be written as a decimal-encoded
|
510
|
+
(`<`) or hex-encoded (`<`) entity.
|
511
|
+
--- Should become:
|
512
|
+
<p>The left angle-bracket (<code>&lt;</code>) can also be written as a decimal-encoded
|
513
|
+
(<code>&#060;</code>) or hex-encoded (<code>&#x3c;</code>) entity.</p>
|
514
|
+
>>>
|
515
|
+
|
516
|
+
# At the beginning of a document (Bug #525)
|
517
|
+
<<<
|
518
|
+
`world` views
|
519
|
+
--- Should become:
|
520
|
+
<p><code>world</code> views</p>
|
521
|
+
>>>
|
522
|
+
|
523
|
+
|
524
|
+
|
525
|
+
|
526
|
+
### [Code blocks]
|
527
|
+
|
528
|
+
# Para plus code block (literal tab)
|
529
|
+
<<<
|
530
|
+
This is a chunk of code:
|
531
|
+
|
532
|
+
some.code > some.other_code
|
533
|
+
|
534
|
+
Some stuff.
|
535
|
+
--- Should become:
|
536
|
+
<p>This is a chunk of code:</p>
|
537
|
+
|
538
|
+
<pre><code>some.code > some.other_code
|
539
|
+
</code></pre>
|
540
|
+
|
541
|
+
<p>Some stuff.</p>
|
542
|
+
>>>
|
543
|
+
|
544
|
+
# Para plus code block (literal tab, no colon)
|
545
|
+
<<<
|
546
|
+
This is a chunk of code
|
547
|
+
|
548
|
+
some.code > some.other_code
|
549
|
+
|
550
|
+
Some stuff.
|
551
|
+
--- Should become:
|
552
|
+
<p>This is a chunk of code</p>
|
553
|
+
|
554
|
+
<pre><code>some.code > some.other_code
|
555
|
+
</code></pre>
|
556
|
+
|
557
|
+
<p>Some stuff.</p>
|
558
|
+
>>>
|
559
|
+
|
560
|
+
# Para plus code block (tab-width spaces)
|
561
|
+
<<<
|
562
|
+
This is a chunk of code:
|
563
|
+
|
564
|
+
some.code > some.other_code
|
565
|
+
|
566
|
+
Some stuff.
|
567
|
+
--- Should become:
|
568
|
+
<p>This is a chunk of code:</p>
|
569
|
+
|
570
|
+
<pre><code>some.code > some.other_code
|
571
|
+
</code></pre>
|
572
|
+
|
573
|
+
<p>Some stuff.</p>
|
574
|
+
>>>
|
575
|
+
|
576
|
+
# Para plus code block (tab-width spaces, no colon)
|
577
|
+
<<<
|
578
|
+
This is a chunk of code
|
579
|
+
|
580
|
+
some.code > some.other_code
|
581
|
+
|
582
|
+
Some stuff.
|
583
|
+
--- Should become:
|
584
|
+
<p>This is a chunk of code</p>
|
585
|
+
|
586
|
+
<pre><code>some.code > some.other_code
|
587
|
+
</code></pre>
|
588
|
+
|
589
|
+
<p>Some stuff.</p>
|
590
|
+
>>>
|
591
|
+
|
592
|
+
# Colon with preceeding space
|
593
|
+
<<<
|
594
|
+
A regular paragraph, without a colon. :
|
595
|
+
|
596
|
+
This is a code block.
|
597
|
+
|
598
|
+
Some stuff.
|
599
|
+
--- Should become:
|
600
|
+
<p>A regular paragraph, without a colon. :</p>
|
601
|
+
|
602
|
+
<pre><code>This is a code block.
|
603
|
+
</code></pre>
|
604
|
+
|
605
|
+
<p>Some stuff.</p>
|
606
|
+
>>>
|
607
|
+
|
608
|
+
# Single colon
|
609
|
+
<<<
|
610
|
+
:
|
611
|
+
|
612
|
+
some.code > some.other_code
|
613
|
+
|
614
|
+
Some stuff.
|
615
|
+
--- Should become:
|
616
|
+
<p>:</p>
|
617
|
+
|
618
|
+
<pre><code>some.code > some.other_code
|
619
|
+
</code></pre>
|
620
|
+
|
621
|
+
<p>Some stuff.</p>
|
622
|
+
>>>
|
623
|
+
|
624
|
+
# Preserve leading whitespace (Bug #541)
|
625
|
+
<<<
|
626
|
+
Examples:
|
627
|
+
|
628
|
+
# (Waste character because first line is flush left !!!)
|
629
|
+
# Example script1
|
630
|
+
x = 1
|
631
|
+
x += 1
|
632
|
+
puts x
|
633
|
+
|
634
|
+
Some stuff.
|
635
|
+
--- Should become:
|
636
|
+
<p>Examples:</p>
|
637
|
+
|
638
|
+
<pre><code> # (Waste character because first line is flush left !!!)
|
639
|
+
# Example script1
|
640
|
+
x = 1
|
641
|
+
x += 1
|
642
|
+
puts x
|
643
|
+
</code></pre>
|
644
|
+
|
645
|
+
<p>Some stuff.</p>
|
646
|
+
>>>
|
647
|
+
|
648
|
+
|
649
|
+
### [Horizontal Rules]
|
650
|
+
|
651
|
+
# Hrule 1
|
652
|
+
<<<
|
653
|
+
* * *
|
654
|
+
--- Should become:
|
655
|
+
<hr/>
|
656
|
+
>>>
|
657
|
+
|
658
|
+
# Hrule 2
|
659
|
+
<<<
|
660
|
+
***
|
661
|
+
--- Should become:
|
662
|
+
<hr/>
|
663
|
+
>>>
|
664
|
+
|
665
|
+
# Hrule 3
|
666
|
+
<<<
|
667
|
+
*****
|
668
|
+
--- Should become:
|
669
|
+
<hr/>
|
670
|
+
>>>
|
671
|
+
|
672
|
+
# Hrule 4
|
673
|
+
<<<
|
674
|
+
- - -
|
675
|
+
--- Should become:
|
676
|
+
<hr/>
|
677
|
+
>>>
|
678
|
+
|
679
|
+
# Hrule 5
|
680
|
+
<<<
|
681
|
+
---------------------------------------
|
682
|
+
--- Should become:
|
683
|
+
<hr/>
|
684
|
+
>>>
|
685
|
+
|
686
|
+
|
687
|
+
### [Titles]
|
688
|
+
|
689
|
+
# setext-style h1
|
690
|
+
<<<
|
691
|
+
Title Text
|
692
|
+
=
|
693
|
+
--- Should become:
|
694
|
+
<h1>Title Text</h1>
|
695
|
+
>>>
|
696
|
+
|
697
|
+
<<<
|
698
|
+
Title Text
|
699
|
+
===
|
700
|
+
--- Should become:
|
701
|
+
<h1>Title Text</h1>
|
702
|
+
>>>
|
703
|
+
|
704
|
+
<<<
|
705
|
+
Title Text
|
706
|
+
==========
|
707
|
+
--- Should become:
|
708
|
+
<h1>Title Text</h1>
|
709
|
+
>>>
|
710
|
+
|
711
|
+
# setext-style h2
|
712
|
+
<<<
|
713
|
+
Title Text
|
714
|
+
-
|
715
|
+
--- Should become:
|
716
|
+
<h2>Title Text</h2>
|
717
|
+
>>>
|
718
|
+
|
719
|
+
<<<
|
720
|
+
Title Text
|
721
|
+
---
|
722
|
+
--- Should become:
|
723
|
+
<h2>Title Text</h2>
|
724
|
+
>>>
|
725
|
+
|
726
|
+
<<<
|
727
|
+
Title Text
|
728
|
+
----------
|
729
|
+
--- Should become:
|
730
|
+
<h2>Title Text</h2>
|
731
|
+
>>>
|
732
|
+
|
733
|
+
# ATX-style h1
|
734
|
+
<<<
|
735
|
+
# Title Text
|
736
|
+
--- Should become:
|
737
|
+
<h1>Title Text</h1>
|
738
|
+
>>>
|
739
|
+
|
740
|
+
<<<
|
741
|
+
# Title Text #
|
742
|
+
--- Should become:
|
743
|
+
<h1>Title Text</h1>
|
744
|
+
>>>
|
745
|
+
|
746
|
+
<<<
|
747
|
+
# Title Text ###
|
748
|
+
--- Should become:
|
749
|
+
<h1>Title Text</h1>
|
750
|
+
>>>
|
751
|
+
|
752
|
+
<<<
|
753
|
+
# Title Text #####
|
754
|
+
--- Should become:
|
755
|
+
<h1>Title Text</h1>
|
756
|
+
>>>
|
757
|
+
|
758
|
+
# ATX-style h2
|
759
|
+
<<<
|
760
|
+
## Title Text
|
761
|
+
--- Should become:
|
762
|
+
<h2>Title Text</h2>
|
763
|
+
>>>
|
764
|
+
|
765
|
+
<<<
|
766
|
+
## Title Text #
|
767
|
+
--- Should become:
|
768
|
+
<h2>Title Text</h2>
|
769
|
+
>>>
|
770
|
+
|
771
|
+
<<<
|
772
|
+
## Title Text ###
|
773
|
+
--- Should become:
|
774
|
+
<h2>Title Text</h2>
|
775
|
+
>>>
|
776
|
+
|
777
|
+
<<<
|
778
|
+
## Title Text #####
|
779
|
+
--- Should become:
|
780
|
+
<h2>Title Text</h2>
|
781
|
+
>>>
|
782
|
+
|
783
|
+
# ATX-style h3
|
784
|
+
<<<
|
785
|
+
### Title Text
|
786
|
+
--- Should become:
|
787
|
+
<h3>Title Text</h3>
|
788
|
+
>>>
|
789
|
+
|
790
|
+
<<<
|
791
|
+
### Title Text #
|
792
|
+
--- Should become:
|
793
|
+
<h3>Title Text</h3>
|
794
|
+
>>>
|
795
|
+
|
796
|
+
<<<
|
797
|
+
### Title Text ###
|
798
|
+
--- Should become:
|
799
|
+
<h3>Title Text</h3>
|
800
|
+
>>>
|
801
|
+
|
802
|
+
<<<
|
803
|
+
### Title Text #####
|
804
|
+
--- Should become:
|
805
|
+
<h3>Title Text</h3>
|
806
|
+
>>>
|
807
|
+
|
808
|
+
# ATX-style h4
|
809
|
+
<<<
|
810
|
+
#### Title Text
|
811
|
+
--- Should become:
|
812
|
+
<h4>Title Text</h4>
|
813
|
+
>>>
|
814
|
+
|
815
|
+
<<<
|
816
|
+
#### Title Text #
|
817
|
+
--- Should become:
|
818
|
+
<h4>Title Text</h4>
|
819
|
+
>>>
|
820
|
+
|
821
|
+
<<<
|
822
|
+
#### Title Text ###
|
823
|
+
--- Should become:
|
824
|
+
<h4>Title Text</h4>
|
825
|
+
>>>
|
826
|
+
|
827
|
+
<<<
|
828
|
+
#### Title Text #####
|
829
|
+
--- Should become:
|
830
|
+
<h4>Title Text</h4>
|
831
|
+
>>>
|
832
|
+
|
833
|
+
# ATX-style h5
|
834
|
+
<<<
|
835
|
+
##### Title Text
|
836
|
+
--- Should become:
|
837
|
+
<h5>Title Text</h5>
|
838
|
+
>>>
|
839
|
+
|
840
|
+
<<<
|
841
|
+
##### Title Text #
|
842
|
+
--- Should become:
|
843
|
+
<h5>Title Text</h5>
|
844
|
+
>>>
|
845
|
+
|
846
|
+
<<<
|
847
|
+
##### Title Text ###
|
848
|
+
--- Should become:
|
849
|
+
<h5>Title Text</h5>
|
850
|
+
>>>
|
851
|
+
|
852
|
+
<<<
|
853
|
+
##### Title Text #####
|
854
|
+
--- Should become:
|
855
|
+
<h5>Title Text</h5>
|
856
|
+
>>>
|
857
|
+
|
858
|
+
# ATX-style h6
|
859
|
+
<<<
|
860
|
+
###### Title Text
|
861
|
+
--- Should become:
|
862
|
+
<h6>Title Text</h6>
|
863
|
+
>>>
|
864
|
+
|
865
|
+
<<<
|
866
|
+
###### Title Text #
|
867
|
+
--- Should become:
|
868
|
+
<h6>Title Text</h6>
|
869
|
+
>>>
|
870
|
+
|
871
|
+
<<<
|
872
|
+
###### Title Text ###
|
873
|
+
--- Should become:
|
874
|
+
<h6>Title Text</h6>
|
875
|
+
>>>
|
876
|
+
|
877
|
+
<<<
|
878
|
+
###### Title Text #####
|
879
|
+
--- Should become:
|
880
|
+
<h6>Title Text</h6>
|
881
|
+
>>>
|
882
|
+
|
883
|
+
|
884
|
+
### [Blockquotes]
|
885
|
+
|
886
|
+
# Regular 1-level blockquotes
|
887
|
+
<<<
|
888
|
+
> Email-style angle brackets
|
889
|
+
> are used for blockquotes.
|
890
|
+
--- Should become:
|
891
|
+
<blockquote>
|
892
|
+
<p>Email-style angle brackets
|
893
|
+
are used for blockquotes.</p>
|
894
|
+
</blockquote>
|
895
|
+
>>>
|
896
|
+
|
897
|
+
# Doubled blockquotes
|
898
|
+
<<<
|
899
|
+
> > And, they can be nested.
|
900
|
+
--- Should become:
|
901
|
+
<blockquote>
|
902
|
+
<blockquote>
|
903
|
+
<p>And, they can be nested.</p>
|
904
|
+
</blockquote>
|
905
|
+
</blockquote>
|
906
|
+
>>>
|
907
|
+
|
908
|
+
# Nested blockquotes
|
909
|
+
<<<
|
910
|
+
> Email-style angle brackets
|
911
|
+
> are used for blockquotes.
|
912
|
+
|
913
|
+
> > And, they can be nested.
|
914
|
+
--- Should become:
|
915
|
+
<blockquote>
|
916
|
+
<p>Email-style angle brackets
|
917
|
+
are used for blockquotes.</p>
|
918
|
+
|
919
|
+
<blockquote>
|
920
|
+
<p>And, they can be nested.</p>
|
921
|
+
</blockquote>
|
922
|
+
</blockquote>
|
923
|
+
>>>
|
924
|
+
|
925
|
+
# Lazy blockquotes
|
926
|
+
<<<
|
927
|
+
> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
|
928
|
+
consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
|
929
|
+
Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
|
930
|
+
|
931
|
+
> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
|
932
|
+
id sem consectetuer libero luctus adipiscing.
|
933
|
+
--- Should become:
|
934
|
+
<blockquote>
|
935
|
+
<p>This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
|
936
|
+
consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
|
937
|
+
Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.</p>
|
938
|
+
|
939
|
+
<p>Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
|
940
|
+
id sem consectetuer libero luctus adipiscing.</p>
|
941
|
+
</blockquote>
|
942
|
+
>>>
|
943
|
+
|
944
|
+
|
945
|
+
# Blockquotes containing other markdown elements
|
946
|
+
<<<
|
947
|
+
> ## This is a header.
|
948
|
+
>
|
949
|
+
> 1. This is the first list item.
|
950
|
+
> 2. This is the second list item.
|
951
|
+
>
|
952
|
+
> Here's some example code:
|
953
|
+
>
|
954
|
+
> return shell_exec("echo $input | $markdown_script");
|
955
|
+
--- Should become:
|
956
|
+
<blockquote>
|
957
|
+
<h2>This is a header.</h2>
|
958
|
+
|
959
|
+
<ol>
|
960
|
+
<li>This is the first list item.</li>
|
961
|
+
<li>This is the second list item.</li>
|
962
|
+
</ol>
|
963
|
+
|
964
|
+
<p>Here's some example code:</p>
|
965
|
+
|
966
|
+
<pre><code>return shell_exec("echo $input | $markdown_script");
|
967
|
+
</code></pre>
|
968
|
+
</blockquote>
|
969
|
+
>>>
|
970
|
+
|
971
|
+
# Blockquotes with a <pre> section
|
972
|
+
<<<
|
973
|
+
> The best approximation of the problem is the following code:
|
974
|
+
>
|
975
|
+
> <pre>
|
976
|
+
> foo + bar; foo.factorize; foo.display
|
977
|
+
> </pre>
|
978
|
+
>
|
979
|
+
> This should result in an error on any little-endian platform.
|
980
|
+
--- Should become:
|
981
|
+
<blockquote>
|
982
|
+
<p>The best approximation of the problem is the following code:</p>
|
983
|
+
|
984
|
+
<pre>
|
985
|
+
foo + bar; foo.factorize; foo.display
|
986
|
+
</pre>
|
987
|
+
|
988
|
+
<p>This should result in an error on any little-endian platform.</p>
|
989
|
+
</blockquote>
|
990
|
+
>>>
|
991
|
+
|
992
|
+
|
993
|
+
|
994
|
+
### [Images]
|
995
|
+
|
996
|
+
# Inline image with title
|
997
|
+
<<<
|
998
|
+
![alt text](/path/img.jpg "Title")
|
999
|
+
--- Should become:
|
1000
|
+
<p><img src="/path/img.jpg" alt="alt text" title="Title"/></p>
|
1001
|
+
>>>
|
1002
|
+
|
1003
|
+
# Inline image with title (single-quotes)
|
1004
|
+
<<<
|
1005
|
+
![alt text](/path/img.jpg 'Title')
|
1006
|
+
--- Should become:
|
1007
|
+
<p><img src="/path/img.jpg" alt="alt text" title="Title"/></p>
|
1008
|
+
>>>
|
1009
|
+
|
1010
|
+
# Inline image with title (with embedded quotes)
|
1011
|
+
<<<
|
1012
|
+
![alt text](/path/img.jpg 'The "Title" Image')
|
1013
|
+
--- Should become:
|
1014
|
+
<p><img src="/path/img.jpg" alt="alt text" title="The "Title" Image"/></p>
|
1015
|
+
>>>
|
1016
|
+
|
1017
|
+
# Inline image without title
|
1018
|
+
<<<
|
1019
|
+
![alt text](/path/img.jpg)
|
1020
|
+
--- Should become:
|
1021
|
+
<p><img src="/path/img.jpg" alt="alt text"/></p>
|
1022
|
+
>>>
|
1023
|
+
|
1024
|
+
# Inline image with quoted alt text
|
1025
|
+
<<<
|
1026
|
+
![the "alt text"](/path/img.jpg)
|
1027
|
+
--- Should become:
|
1028
|
+
<p><img src="/path/img.jpg" alt="the "alt text""/></p>
|
1029
|
+
>>>
|
1030
|
+
|
1031
|
+
|
1032
|
+
# Reference image
|
1033
|
+
<<<
|
1034
|
+
![alt text][id]
|
1035
|
+
|
1036
|
+
[id]: /url/to/img.jpg "Title"
|
1037
|
+
--- Should become:
|
1038
|
+
<p><img src="/url/to/img.jpg" alt="alt text" title="Title"/></p>
|
1039
|
+
>>>
|
1040
|
+
|
1041
|
+
|
1042
|
+
|
1043
|
+
### [Emphasis]
|
1044
|
+
|
1045
|
+
# Emphasis (<em>) with asterisks
|
1046
|
+
<<<
|
1047
|
+
Use *single splats* for emphasis.
|
1048
|
+
--- Should become:
|
1049
|
+
<p>Use <em>single splats</em> for emphasis.</p>
|
1050
|
+
>>>
|
1051
|
+
|
1052
|
+
# Emphasis (<em>) on two characters with asterisks
|
1053
|
+
<<<
|
1054
|
+
Use *em* for emphasis.
|
1055
|
+
--- Should become:
|
1056
|
+
<p>Use <em>em</em> for emphasis.</p>
|
1057
|
+
>>>
|
1058
|
+
|
1059
|
+
# Emphasis (<em>) with underscores
|
1060
|
+
<<<
|
1061
|
+
Use _underscores_ for emphasis.
|
1062
|
+
--- Should become:
|
1063
|
+
<p>Use <em>underscores</em> for emphasis.</p>
|
1064
|
+
>>>
|
1065
|
+
|
1066
|
+
# Emphasis (<em>) on two characters with underscores
|
1067
|
+
<<<
|
1068
|
+
Use _em_ for emphasis.
|
1069
|
+
--- Should become:
|
1070
|
+
<p>Use <em>em</em> for emphasis.</p>
|
1071
|
+
>>>
|
1072
|
+
|
1073
|
+
# Strong emphasis (<strong>) with asterisks
|
1074
|
+
<<<
|
1075
|
+
Use **double splats** for more emphasis.
|
1076
|
+
--- Should become:
|
1077
|
+
<p>Use <strong>double splats</strong> for more emphasis.</p>
|
1078
|
+
>>>
|
1079
|
+
|
1080
|
+
# Strong emphasis (<strong>) with underscores
|
1081
|
+
<<<
|
1082
|
+
Use __doubled underscores__ for more emphasis.
|
1083
|
+
--- Should become:
|
1084
|
+
<p>Use <strong>doubled underscores</strong> for more emphasis.</p>
|
1085
|
+
>>>
|
1086
|
+
|
1087
|
+
# Combined emphasis types 1
|
1088
|
+
<<<
|
1089
|
+
Use *single splats* or _single unders_ for normal emphasis.
|
1090
|
+
--- Should become:
|
1091
|
+
<p>Use <em>single splats</em> or <em>single unders</em> for normal emphasis.</p>
|
1092
|
+
>>>
|
1093
|
+
|
1094
|
+
# Combined emphasis types 2
|
1095
|
+
<<<
|
1096
|
+
Use _single unders_ for normal emphasis
|
1097
|
+
or __double them__ for strong emphasis.
|
1098
|
+
--- Should become:
|
1099
|
+
<p>Use <em>single unders</em> for normal emphasis
|
1100
|
+
or <strong>double them</strong> for strong emphasis.</p>
|
1101
|
+
>>>
|
1102
|
+
|
1103
|
+
# Emphasis containing escaped metachars
|
1104
|
+
<<<
|
1105
|
+
You can include literal *\*splats\** by escaping them.
|
1106
|
+
--- Should become:
|
1107
|
+
<p>You can include literal <em>*splats*</em> by escaping them.</p>
|
1108
|
+
>>>
|
1109
|
+
|
1110
|
+
# Two instances of asterisked emphasis on one line
|
1111
|
+
<<<
|
1112
|
+
If there's *two* splatted parts on a *single line* it should still work.
|
1113
|
+
--- Should become:
|
1114
|
+
<p>If there's <em>two</em> splatted parts on a <em>single line</em> it should still work.</p>
|
1115
|
+
>>>
|
1116
|
+
|
1117
|
+
# Two instances of double asterisked emphasis on one line
|
1118
|
+
<<<
|
1119
|
+
This **doubled** one should **work too**.
|
1120
|
+
--- Should become:
|
1121
|
+
<p>This <strong>doubled</strong> one should <strong>work too</strong>.</p>
|
1122
|
+
>>>
|
1123
|
+
|
1124
|
+
# Two instances of underscore emphasis on one line
|
1125
|
+
<<<
|
1126
|
+
If there's _two_ underbarred parts on a _single line_ it should still work.
|
1127
|
+
--- Should become:
|
1128
|
+
<p>If there's <em>two</em> underbarred parts on a <em>single line</em> it should still work.</p>
|
1129
|
+
>>>
|
1130
|
+
|
1131
|
+
# Two instances of doubled underscore emphasis on one line
|
1132
|
+
<<<
|
1133
|
+
This __doubled__ one should __work too__.
|
1134
|
+
--- Should become:
|
1135
|
+
<p>This <strong>doubled</strong> one should <strong>work too</strong>.</p>
|
1136
|
+
>>>
|
1137
|
+
|
1138
|
+
# Initial emphasis (asterisk)
|
1139
|
+
<<<
|
1140
|
+
*Something* like this should be bold.
|
1141
|
+
--- Should become:
|
1142
|
+
<p><em>Something</em> like this should be bold.</p>
|
1143
|
+
>>>
|
1144
|
+
|
1145
|
+
# Initial emphasis (underscore)
|
1146
|
+
<<<
|
1147
|
+
_Something_ like this should be bold.
|
1148
|
+
--- Should become:
|
1149
|
+
<p><em>Something</em> like this should be bold.</p>
|
1150
|
+
>>>
|
1151
|
+
|
1152
|
+
# Initial strong emphasis (asterisk)
|
1153
|
+
<<<
|
1154
|
+
**Something** like this should be bold.
|
1155
|
+
--- Should become:
|
1156
|
+
<p><strong>Something</strong> like this should be bold.</p>
|
1157
|
+
>>>
|
1158
|
+
|
1159
|
+
# Initial strong emphasis (underscore)
|
1160
|
+
<<<
|
1161
|
+
__Something__ like this should be bold.
|
1162
|
+
--- Should become:
|
1163
|
+
<p><strong>Something</strong> like this should be bold.</p>
|
1164
|
+
>>>
|
1165
|
+
|
1166
|
+
# Partial-word emphasis (Bug #568)
|
1167
|
+
<<<
|
1168
|
+
**E**xtended **TURN**
|
1169
|
+
--- Should become:
|
1170
|
+
<p><strong>E</strong>xtended <strong>TURN</strong></p>
|
1171
|
+
>>>
|
1172
|
+
|
1173
|
+
|
1174
|
+
|
1175
|
+
### [Links]
|
1176
|
+
|
1177
|
+
# Inline link, no title
|
1178
|
+
<<<
|
1179
|
+
An [example](http://url.com/).
|
1180
|
+
--- Should become:
|
1181
|
+
<p>An <a href="http://url.com/">example</a>.</p>
|
1182
|
+
>>>
|
1183
|
+
|
1184
|
+
# Inline link with title
|
1185
|
+
<<<
|
1186
|
+
An [example](http://url.com/ "Check out url.com!").
|
1187
|
+
--- Should become:
|
1188
|
+
<p>An <a href="http://url.com/" title="Check out url.com!">example</a>.</p>
|
1189
|
+
>>>
|
1190
|
+
|
1191
|
+
# Reference-style link, no title
|
1192
|
+
<<<
|
1193
|
+
An [example][ex] reference-style link.
|
1194
|
+
|
1195
|
+
[ex]: http://www.bluefi.com/
|
1196
|
+
--- Should become:
|
1197
|
+
<p>An <a href="http://www.bluefi.com/">example</a> reference-style link.</p>
|
1198
|
+
>>>
|
1199
|
+
|
1200
|
+
# Reference-style link with quoted title
|
1201
|
+
<<<
|
1202
|
+
An [example][ex] reference-style link.
|
1203
|
+
|
1204
|
+
[ex]: http://www.bluefi.com/ "Check out our air."
|
1205
|
+
--- Should become:
|
1206
|
+
<p>An <a href="http://www.bluefi.com/" title="Check out our air.">example</a> reference-style link.</p>
|
1207
|
+
>>>
|
1208
|
+
|
1209
|
+
# Reference-style link with paren title
|
1210
|
+
<<<
|
1211
|
+
An [example][ex] reference-style link.
|
1212
|
+
|
1213
|
+
[ex]: http://www.bluefi.com/ (Check out our air.)
|
1214
|
+
--- Should become:
|
1215
|
+
<p>An <a href="http://www.bluefi.com/" title="Check out our air.">example</a> reference-style link.</p>
|
1216
|
+
>>>
|
1217
|
+
|
1218
|
+
# Reference-style link with one of each (hehe)
|
1219
|
+
<<<
|
1220
|
+
An [example][ex] reference-style link.
|
1221
|
+
|
1222
|
+
[ex]: http://www.bluefi.com/ "Check out our air.)
|
1223
|
+
--- Should become:
|
1224
|
+
<p>An <a href="http://www.bluefi.com/" title="Check out our air.">example</a> reference-style link.</p>
|
1225
|
+
>>>
|
1226
|
+
|
1227
|
+
" <- For syntax highlighting
|
1228
|
+
|
1229
|
+
# Reference-style link with intervening space
|
1230
|
+
<<<
|
1231
|
+
You can split the [linked part] [ex] from
|
1232
|
+
the reference part with a single space.
|
1233
|
+
|
1234
|
+
[ex]: http://www.treefrog.com/ "for some reason"
|
1235
|
+
--- Should become:
|
1236
|
+
<p>You can split the <a href="http://www.treefrog.com/" title="for some reason">linked part</a> from
|
1237
|
+
the reference part with a single space.</p>
|
1238
|
+
>>>
|
1239
|
+
|
1240
|
+
# Reference-style link with intervening space
|
1241
|
+
<<<
|
1242
|
+
You can split the [linked part]
|
1243
|
+
[ex] from the reference part
|
1244
|
+
with a newline in case your editor wraps it there, I guess.
|
1245
|
+
|
1246
|
+
[ex]: http://www.treefrog.com/
|
1247
|
+
--- Should become:
|
1248
|
+
<p>You can split the <a href="http://www.treefrog.com/">linked part</a> from the reference part
|
1249
|
+
with a newline in case your editor wraps it there, I guess.</p>
|
1250
|
+
>>>
|
1251
|
+
|
1252
|
+
# Reference-style anchors
|
1253
|
+
<<<
|
1254
|
+
I get 10 times more traffic from [Google] [1] than from
|
1255
|
+
[Yahoo] [2] or [MSN] [3].
|
1256
|
+
|
1257
|
+
[1]: http://google.com/ "Google"
|
1258
|
+
[2]: http://search.yahoo.com/ "Yahoo Search"
|
1259
|
+
[3]: http://search.msn.com/ "MSN Search"
|
1260
|
+
--- Should become:
|
1261
|
+
<p>I get 10 times more traffic from <a href="http://google.com/" title="Google">Google</a> than from
|
1262
|
+
<a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p>
|
1263
|
+
>>>
|
1264
|
+
|
1265
|
+
# Implicit name-link shortcut anchors
|
1266
|
+
<<<
|
1267
|
+
I get 10 times more traffic from [Google][] than from
|
1268
|
+
[Yahoo][] or [MSN][].
|
1269
|
+
|
1270
|
+
[google]: http://google.com/ "Google"
|
1271
|
+
[yahoo]: http://search.yahoo.com/ "Yahoo Search"
|
1272
|
+
[msn]: http://search.msn.com/ "MSN Search"
|
1273
|
+
--- Should become:
|
1274
|
+
<p>I get 10 times more traffic from <a href="http://google.com/" title="Google">Google</a> than from
|
1275
|
+
<a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p>
|
1276
|
+
>>>
|
1277
|
+
|
1278
|
+
# Inline anchors
|
1279
|
+
<<<
|
1280
|
+
I get 10 times more traffic from [Google](http://google.com/ "Google")
|
1281
|
+
than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or
|
1282
|
+
[MSN](http://search.msn.com/ "MSN Search").
|
1283
|
+
--- Should become:
|
1284
|
+
<p>I get 10 times more traffic from <a href="http://google.com/" title="Google">Google</a>
|
1285
|
+
than from <a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a> or
|
1286
|
+
<a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p>
|
1287
|
+
>>>
|
1288
|
+
|
1289
|
+
# Graceful fail for unclosed brackets (and bug #524)
|
1290
|
+
<<<
|
1291
|
+
This is just a [bracket opener; it should fail gracefully.
|
1292
|
+
--- Should become:
|
1293
|
+
<p>This is just a [bracket opener; it should fail gracefully.</p>
|
1294
|
+
>>>
|
1295
|
+
|
1296
|
+
# Unresolved reference-style links (Bug #620)
|
1297
|
+
<<<
|
1298
|
+
This is an unresolved [url][1].
|
1299
|
+
--- Should become:
|
1300
|
+
<p>This is an unresolved [url][1].</p>
|
1301
|
+
>>>
|
1302
|
+
|
1303
|
+
|
1304
|
+
### [Auto-links]
|
1305
|
+
|
1306
|
+
# Plain HTTP link
|
1307
|
+
<<<
|
1308
|
+
This is a reference to <http://www.FaerieMUD.org/>. You should follow it.
|
1309
|
+
--- Should become:
|
1310
|
+
<p>This is a reference to <a href="http://www.FaerieMUD.org/">http://www.FaerieMUD.org/</a>. You should follow it.</p>
|
1311
|
+
>>>
|
1312
|
+
|
1313
|
+
# FTP link
|
1314
|
+
<<<
|
1315
|
+
Why not download your very own chandelier from <ftp://ftp.usuc.edu/pub/foof/mir/>?
|
1316
|
+
--- Should become:
|
1317
|
+
<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>
|
1318
|
+
>>>
|
1319
|
+
|
1320
|
+
|
1321
|
+
### [Lists]
|
1322
|
+
|
1323
|
+
# Unordered list
|
1324
|
+
<<<
|
1325
|
+
* Red
|
1326
|
+
* Green
|
1327
|
+
* Blue
|
1328
|
+
--- Should become:
|
1329
|
+
<ul>
|
1330
|
+
<li>Red</li>
|
1331
|
+
<li>Green</li>
|
1332
|
+
<li>Blue</li>
|
1333
|
+
</ul>
|
1334
|
+
>>>
|
1335
|
+
|
1336
|
+
# Unordered list w/alt bullets
|
1337
|
+
<<<
|
1338
|
+
- Red
|
1339
|
+
- Green
|
1340
|
+
- Blue
|
1341
|
+
--- Should become:
|
1342
|
+
<ul>
|
1343
|
+
<li>Red</li>
|
1344
|
+
<li>Green</li>
|
1345
|
+
<li>Blue</li>
|
1346
|
+
</ul>
|
1347
|
+
>>>
|
1348
|
+
|
1349
|
+
# Unordered list w/alt bullets 2
|
1350
|
+
<<<
|
1351
|
+
+ Red
|
1352
|
+
+ Green
|
1353
|
+
+ Blue
|
1354
|
+
--- Should become:
|
1355
|
+
<ul>
|
1356
|
+
<li>Red</li>
|
1357
|
+
<li>Green</li>
|
1358
|
+
<li>Blue</li>
|
1359
|
+
</ul>
|
1360
|
+
>>>
|
1361
|
+
|
1362
|
+
# Unordered list w/mixed bullets
|
1363
|
+
<<<
|
1364
|
+
+ Red
|
1365
|
+
- Green
|
1366
|
+
* Blue
|
1367
|
+
--- Should become:
|
1368
|
+
<ul>
|
1369
|
+
<li>Red</li>
|
1370
|
+
<li>Green</li>
|
1371
|
+
<li>Blue</li>
|
1372
|
+
</ul>
|
1373
|
+
>>>
|
1374
|
+
|
1375
|
+
# Ordered list
|
1376
|
+
<<<
|
1377
|
+
1. Bird
|
1378
|
+
2. McHale
|
1379
|
+
3. Parish
|
1380
|
+
--- Should become:
|
1381
|
+
<ol>
|
1382
|
+
<li>Bird</li>
|
1383
|
+
<li>McHale</li>
|
1384
|
+
<li>Parish</li>
|
1385
|
+
</ol>
|
1386
|
+
>>>
|
1387
|
+
|
1388
|
+
# Ordered list, any numbers
|
1389
|
+
<<<
|
1390
|
+
1. Bird
|
1391
|
+
1. McHale
|
1392
|
+
1. Parish
|
1393
|
+
--- Should become:
|
1394
|
+
<ol>
|
1395
|
+
<li>Bird</li>
|
1396
|
+
<li>McHale</li>
|
1397
|
+
<li>Parish</li>
|
1398
|
+
</ol>
|
1399
|
+
>>>
|
1400
|
+
|
1401
|
+
# Ordered list, any numbers 2
|
1402
|
+
<<<
|
1403
|
+
3. Bird
|
1404
|
+
1. McHale
|
1405
|
+
8. Parish
|
1406
|
+
--- Should become:
|
1407
|
+
<ol>
|
1408
|
+
<li>Bird</li>
|
1409
|
+
<li>McHale</li>
|
1410
|
+
<li>Parish</li>
|
1411
|
+
</ol>
|
1412
|
+
>>>
|
1413
|
+
|
1414
|
+
# Hanging indents
|
1415
|
+
<<<
|
1416
|
+
* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
|
1417
|
+
Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
|
1418
|
+
viverra nec, fringilla in, laoreet vitae, risus.
|
1419
|
+
* Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
|
1420
|
+
Suspendisse id sem consectetuer libero luctus adipiscing.
|
1421
|
+
--- Should become:
|
1422
|
+
<ul>
|
1423
|
+
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
|
1424
|
+
Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
|
1425
|
+
viverra nec, fringilla in, laoreet vitae, risus.</li>
|
1426
|
+
<li>Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
|
1427
|
+
Suspendisse id sem consectetuer libero luctus adipiscing.</li>
|
1428
|
+
</ul>
|
1429
|
+
>>>
|
1430
|
+
|
1431
|
+
# Lazy indents
|
1432
|
+
<<<
|
1433
|
+
* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
|
1434
|
+
Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
|
1435
|
+
viverra nec, fringilla in, laoreet vitae, risus.
|
1436
|
+
* Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
|
1437
|
+
Suspendisse id sem consectetuer libero luctus adipiscing.
|
1438
|
+
--- Should become:
|
1439
|
+
<ul>
|
1440
|
+
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
|
1441
|
+
Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
|
1442
|
+
viverra nec, fringilla in, laoreet vitae, risus.</li>
|
1443
|
+
<li>Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
|
1444
|
+
Suspendisse id sem consectetuer libero luctus adipiscing.</li>
|
1445
|
+
</ul>
|
1446
|
+
>>>
|
1447
|
+
|
1448
|
+
# Paragraph wrapped list items
|
1449
|
+
<<<
|
1450
|
+
* Bird
|
1451
|
+
|
1452
|
+
* Magic
|
1453
|
+
--- Should become:
|
1454
|
+
<ul>
|
1455
|
+
<li><p>Bird</p></li>
|
1456
|
+
<li><p>Magic</p></li>
|
1457
|
+
</ul>
|
1458
|
+
>>>
|
1459
|
+
|
1460
|
+
# Multi-paragraph list items
|
1461
|
+
<<<
|
1462
|
+
1. This is a list item with two paragraphs. Lorem ipsum dolor
|
1463
|
+
sit amet, consectetuer adipiscing elit. Aliquam hendrerit
|
1464
|
+
mi posuere lectus.
|
1465
|
+
|
1466
|
+
Vestibulum enim wisi, viverra nec, fringilla in, laoreet
|
1467
|
+
vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
|
1468
|
+
sit amet velit.
|
1469
|
+
|
1470
|
+
2. Suspendisse id sem consectetuer libero luctus adipiscing.
|
1471
|
+
--- Should become:
|
1472
|
+
<ol>
|
1473
|
+
<li><p>This is a list item with two paragraphs. Lorem ipsum dolor
|
1474
|
+
sit amet, consectetuer adipiscing elit. Aliquam hendrerit
|
1475
|
+
mi posuere lectus.</p>
|
1476
|
+
|
1477
|
+
<p>Vestibulum enim wisi, viverra nec, fringilla in, laoreet
|
1478
|
+
vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
|
1479
|
+
sit amet velit.</p></li>
|
1480
|
+
<li><p>Suspendisse id sem consectetuer libero luctus adipiscing.</p></li>
|
1481
|
+
</ol>
|
1482
|
+
>>>
|
1483
|
+
|
1484
|
+
# Lazy multi-paragraphs
|
1485
|
+
<<<
|
1486
|
+
* This is a list item with two paragraphs.
|
1487
|
+
|
1488
|
+
This is the second paragraph in the list item. You're
|
1489
|
+
only required to indent the first line. Lorem ipsum dolor
|
1490
|
+
sit amet, consectetuer adipiscing elit.
|
1491
|
+
|
1492
|
+
* Another item in the same list.
|
1493
|
+
--- Should become:
|
1494
|
+
<ul>
|
1495
|
+
<li><p>This is a list item with two paragraphs.</p>
|
1496
|
+
|
1497
|
+
<p>This is the second paragraph in the list item. You're
|
1498
|
+
only required to indent the first line. Lorem ipsum dolor
|
1499
|
+
sit amet, consectetuer adipiscing elit.</p></li>
|
1500
|
+
<li><p>Another item in the same list.</p></li>
|
1501
|
+
</ul>
|
1502
|
+
>>>
|
1503
|
+
|
1504
|
+
# Blockquote in list item
|
1505
|
+
<<<
|
1506
|
+
* A list item with a blockquote:
|
1507
|
+
|
1508
|
+
> This is a blockquote
|
1509
|
+
> inside a list item.
|
1510
|
+
--- Should become:
|
1511
|
+
<ul>
|
1512
|
+
<li><p>A list item with a blockquote:</p>
|
1513
|
+
|
1514
|
+
<blockquote>
|
1515
|
+
<p>This is a blockquote
|
1516
|
+
inside a list item.</p>
|
1517
|
+
</blockquote></li>
|
1518
|
+
</ul>
|
1519
|
+
>>>
|
1520
|
+
|
1521
|
+
# Code block in list item
|
1522
|
+
<<<
|
1523
|
+
* A list item with a code block:
|
1524
|
+
|
1525
|
+
<code goes here>
|
1526
|
+
--- Should become:
|
1527
|
+
<ul>
|
1528
|
+
<li><p>A list item with a code block:</p>
|
1529
|
+
|
1530
|
+
<pre><code><code goes here>
|
1531
|
+
</code></pre></li>
|
1532
|
+
</ul>
|
1533
|
+
>>>
|
1534
|
+
|
1535
|
+
# Backslash-escaped number-period-space
|
1536
|
+
<<<
|
1537
|
+
1986\. What a great season.
|
1538
|
+
--- Should become:
|
1539
|
+
<p>1986. What a great season.</p>
|
1540
|
+
>>>
|
1541
|
+
|