all repos — grayfriday @ 7ad5f9c1197c54c0be24fb0b0b1d75eb7ef19d89

blackfriday fork with a few changes

block_test.go (view raw)

   1//
   2// Blackfriday Markdown Processor
   3// Available at http://github.com/russross/blackfriday
   4//
   5// Copyright © 2011 Russ Ross <russ@russross.com>.
   6// Distributed under the Simplified BSD License.
   7// See README.md for details.
   8//
   9
  10//
  11// Unit tests for block parsing
  12//
  13
  14package blackfriday
  15
  16import (
  17	"testing"
  18)
  19
  20func runMarkdownBlock(input string, extensions int) string {
  21	htmlFlags := 0
  22	htmlFlags |= HTML_USE_XHTML
  23
  24	renderer := HtmlRenderer(htmlFlags, "", "")
  25
  26	return string(Markdown([]byte(input), renderer, extensions))
  27}
  28
  29func doTestsBlock(t *testing.T, tests []string, extensions int) {
  30	// catch and report panics
  31	var candidate string
  32	defer func() {
  33		if err := recover(); err != nil {
  34			t.Errorf("\npanic while processing [%#v]\n", candidate)
  35		}
  36	}()
  37
  38	for i := 0; i+1 < len(tests); i += 2 {
  39		input := tests[i]
  40		candidate = input
  41		expected := tests[i+1]
  42		actual := runMarkdownBlock(candidate, extensions)
  43		if actual != expected {
  44			t.Errorf("\nInput   [%#v]\nExpected[%#v]\nActual  [%#v]",
  45				candidate, expected, actual)
  46		}
  47
  48		// now test every substring to stress test bounds checking
  49		if !testing.Short() {
  50			for start := 0; start < len(input); start++ {
  51				for end := start + 1; end <= len(input); end++ {
  52					candidate = input[start:end]
  53					_ = runMarkdownBlock(candidate, extensions)
  54				}
  55			}
  56		}
  57	}
  58}
  59
  60func TestPrefixHeaderNoExtensions(t *testing.T) {
  61	var tests = []string{
  62		"# Header 1\n",
  63		"<h1>Header 1</h1>\n",
  64
  65		"## Header 2\n",
  66		"<h2>Header 2</h2>\n",
  67
  68		"### Header 3\n",
  69		"<h3>Header 3</h3>\n",
  70
  71		"#### Header 4\n",
  72		"<h4>Header 4</h4>\n",
  73
  74		"##### Header 5\n",
  75		"<h5>Header 5</h5>\n",
  76
  77		"###### Header 6\n",
  78		"<h6>Header 6</h6>\n",
  79
  80		"####### Header 7\n",
  81		"<h6># Header 7</h6>\n",
  82
  83		"#Header 1\n",
  84		"<h1>Header 1</h1>\n",
  85
  86		"##Header 2\n",
  87		"<h2>Header 2</h2>\n",
  88
  89		"###Header 3\n",
  90		"<h3>Header 3</h3>\n",
  91
  92		"####Header 4\n",
  93		"<h4>Header 4</h4>\n",
  94
  95		"#####Header 5\n",
  96		"<h5>Header 5</h5>\n",
  97
  98		"######Header 6\n",
  99		"<h6>Header 6</h6>\n",
 100
 101		"#######Header 7\n",
 102		"<h6>#Header 7</h6>\n",
 103
 104		"Hello\n# Header 1\nGoodbye\n",
 105		"<p>Hello</p>\n\n<h1>Header 1</h1>\n\n<p>Goodbye</p>\n",
 106
 107		"* List\n# Header\n* List\n",
 108		"<ul>\n<li><p>List</p>\n\n<h1>Header</h1></li>\n\n<li><p>List</p></li>\n</ul>\n",
 109
 110		"* List\n#Header\n* List\n",
 111		"<ul>\n<li><p>List</p>\n\n<h1>Header</h1></li>\n\n<li><p>List</p></li>\n</ul>\n",
 112
 113		"*   List\n    * Nested list\n    # Nested header\n",
 114		"<ul>\n<li><p>List</p>\n\n<ul>\n<li><p>Nested list</p>\n\n" +
 115			"<h1>Nested header</h1></li>\n</ul></li>\n</ul>\n",
 116	}
 117	doTestsBlock(t, tests, 0)
 118}
 119
 120func TestPrefixHeaderSpaceExtension(t *testing.T) {
 121	var tests = []string{
 122		"# Header 1\n",
 123		"<h1>Header 1</h1>\n",
 124
 125		"## Header 2\n",
 126		"<h2>Header 2</h2>\n",
 127
 128		"### Header 3\n",
 129		"<h3>Header 3</h3>\n",
 130
 131		"#### Header 4\n",
 132		"<h4>Header 4</h4>\n",
 133
 134		"##### Header 5\n",
 135		"<h5>Header 5</h5>\n",
 136
 137		"###### Header 6\n",
 138		"<h6>Header 6</h6>\n",
 139
 140		"####### Header 7\n",
 141		"<p>####### Header 7</p>\n",
 142
 143		"#Header 1\n",
 144		"<p>#Header 1</p>\n",
 145
 146		"##Header 2\n",
 147		"<p>##Header 2</p>\n",
 148
 149		"###Header 3\n",
 150		"<p>###Header 3</p>\n",
 151
 152		"####Header 4\n",
 153		"<p>####Header 4</p>\n",
 154
 155		"#####Header 5\n",
 156		"<p>#####Header 5</p>\n",
 157
 158		"######Header 6\n",
 159		"<p>######Header 6</p>\n",
 160
 161		"#######Header 7\n",
 162		"<p>#######Header 7</p>\n",
 163
 164		"Hello\n# Header 1\nGoodbye\n",
 165		"<p>Hello</p>\n\n<h1>Header 1</h1>\n\n<p>Goodbye</p>\n",
 166
 167		"* List\n# Header\n* List\n",
 168		"<ul>\n<li><p>List</p>\n\n<h1>Header</h1></li>\n\n<li><p>List</p></li>\n</ul>\n",
 169
 170		"* List\n#Header\n* List\n",
 171		"<ul>\n<li>List\n#Header</li>\n<li>List</li>\n</ul>\n",
 172
 173		"*   List\n    * Nested list\n    # Nested header\n",
 174		"<ul>\n<li><p>List</p>\n\n<ul>\n<li><p>Nested list</p>\n\n" +
 175			"<h1>Nested header</h1></li>\n</ul></li>\n</ul>\n",
 176	}
 177	doTestsBlock(t, tests, EXTENSION_SPACE_HEADERS)
 178}
 179
 180func TestPrefixHeaderIdExtension(t *testing.T) {
 181	var tests = []string{
 182		"# Header 1 {#someid}\n",
 183		"<h1 id=\"someid\">Header 1</h1>\n",
 184
 185		"# Header 1 {#someid}   \n",
 186		"<h1 id=\"someid\">Header 1</h1>\n",
 187
 188		"# Header 1         {#someid}\n",
 189		"<h1 id=\"someid\">Header 1</h1>\n",
 190
 191		"# Header 1 {#someid\n",
 192		"<h1>Header 1 {#someid</h1>\n",
 193
 194		"# Header 1 {#someid\n",
 195		"<h1>Header 1 {#someid</h1>\n",
 196
 197		"# Header 1 {#someid}}\n",
 198		"<h1 id=\"someid\">Header 1</h1>\n\n<p>}</p>\n",
 199
 200		"## Header 2 {#someid}\n",
 201		"<h2 id=\"someid\">Header 2</h2>\n",
 202
 203		"### Header 3 {#someid}\n",
 204		"<h3 id=\"someid\">Header 3</h3>\n",
 205
 206		"#### Header 4 {#someid}\n",
 207		"<h4 id=\"someid\">Header 4</h4>\n",
 208
 209		"##### Header 5 {#someid}\n",
 210		"<h5 id=\"someid\">Header 5</h5>\n",
 211
 212		"###### Header 6 {#someid}\n",
 213		"<h6 id=\"someid\">Header 6</h6>\n",
 214
 215		"####### Header 7 {#someid}\n",
 216		"<h6 id=\"someid\"># Header 7</h6>\n",
 217
 218		"Hello\n# Header 1\nGoodbye\n",
 219		"<p>Hello</p>\n\n<h1>Header 1</h1>\n\n<p>Goodbye</p>\n",
 220
 221		"* List\n# Header {#someid}\n* List\n",
 222		"<ul>\n<li><p>List</p>\n\n<h1 id=\"someid\">Header</h1></li>\n\n<li><p>List</p></li>\n</ul>\n",
 223
 224		"* List\n#Header {#someid}\n* List\n",
 225		"<ul>\n<li><p>List</p>\n\n<h1 id=\"someid\">Header</h1></li>\n\n<li><p>List</p></li>\n</ul>\n",
 226
 227		"*   List\n    * Nested list\n    # Nested header {#someid}\n",
 228		"<ul>\n<li><p>List</p>\n\n<ul>\n<li><p>Nested list</p>\n\n" +
 229			"<h1 id=\"someid\">Nested header</h1></li>\n</ul></li>\n</ul>\n",
 230	}
 231	doTestsBlock(t, tests, EXTENSION_HEADER_IDS)
 232}
 233
 234func TestUnderlineHeaders(t *testing.T) {
 235	var tests = []string{
 236		"Header 1\n========\n",
 237		"<h1>Header 1</h1>\n",
 238
 239		"Header 2\n--------\n",
 240		"<h2>Header 2</h2>\n",
 241
 242		"A\n=\n",
 243		"<h1>A</h1>\n",
 244
 245		"B\n-\n",
 246		"<h2>B</h2>\n",
 247
 248		"Paragraph\nHeader\n=\n",
 249		"<p>Paragraph</p>\n\n<h1>Header</h1>\n",
 250
 251		"Header\n===\nParagraph\n",
 252		"<h1>Header</h1>\n\n<p>Paragraph</p>\n",
 253
 254		"Header\n===\nAnother header\n---\n",
 255		"<h1>Header</h1>\n\n<h2>Another header</h2>\n",
 256
 257		"   Header\n======\n",
 258		"<h1>Header</h1>\n",
 259
 260		"    Code\n========\n",
 261		"<pre><code>Code\n</code></pre>\n\n<p>========</p>\n",
 262
 263		"Header with *inline*\n=====\n",
 264		"<h1>Header with <em>inline</em></h1>\n",
 265
 266		"*   List\n    * Sublist\n    Not a header\n    ------\n",
 267		"<ul>\n<li>List\n\n<ul>\n<li>Sublist\nNot a header\n------</li>\n</ul></li>\n</ul>\n",
 268
 269		"Paragraph\n\n\n\n\nHeader\n===\n",
 270		"<p>Paragraph</p>\n\n<h1>Header</h1>\n",
 271
 272		"Trailing space \n====        \n\n",
 273		"<h1>Trailing space</h1>\n",
 274
 275		"Trailing spaces\n====        \n\n",
 276		"<h1>Trailing spaces</h1>\n",
 277
 278		"Double underline\n=====\n=====\n",
 279		"<h1>Double underline</h1>\n\n<p>=====</p>\n",
 280	}
 281	doTestsBlock(t, tests, 0)
 282}
 283
 284func TestHorizontalRule(t *testing.T) {
 285	var tests = []string{
 286		"-\n",
 287		"<p>-</p>\n",
 288
 289		"--\n",
 290		"<p>--</p>\n",
 291
 292		"---\n",
 293		"<hr />\n",
 294
 295		"----\n",
 296		"<hr />\n",
 297
 298		"*\n",
 299		"<p>*</p>\n",
 300
 301		"**\n",
 302		"<p>**</p>\n",
 303
 304		"***\n",
 305		"<hr />\n",
 306
 307		"****\n",
 308		"<hr />\n",
 309
 310		"_\n",
 311		"<p>_</p>\n",
 312
 313		"__\n",
 314		"<p>__</p>\n",
 315
 316		"___\n",
 317		"<hr />\n",
 318
 319		"____\n",
 320		"<hr />\n",
 321
 322		"-*-\n",
 323		"<p>-*-</p>\n",
 324
 325		"- - -\n",
 326		"<hr />\n",
 327
 328		"* * *\n",
 329		"<hr />\n",
 330
 331		"_ _ _\n",
 332		"<hr />\n",
 333
 334		"-----*\n",
 335		"<p>-----*</p>\n",
 336
 337		"   ------   \n",
 338		"<hr />\n",
 339
 340		"Hello\n***\n",
 341		"<p>Hello</p>\n\n<hr />\n",
 342
 343		"---\n***\n___\n",
 344		"<hr />\n\n<hr />\n\n<hr />\n",
 345	}
 346	doTestsBlock(t, tests, 0)
 347}
 348
 349func TestUnorderedList(t *testing.T) {
 350	var tests = []string{
 351		"* Hello\n",
 352		"<ul>\n<li>Hello</li>\n</ul>\n",
 353
 354		"* Yin\n* Yang\n",
 355		"<ul>\n<li>Yin</li>\n<li>Yang</li>\n</ul>\n",
 356
 357		"* Ting\n* Bong\n* Goo\n",
 358		"<ul>\n<li>Ting</li>\n<li>Bong</li>\n<li>Goo</li>\n</ul>\n",
 359
 360		"* Yin\n\n* Yang\n",
 361		"<ul>\n<li><p>Yin</p></li>\n\n<li><p>Yang</p></li>\n</ul>\n",
 362
 363		"* Ting\n\n* Bong\n* Goo\n",
 364		"<ul>\n<li><p>Ting</p></li>\n\n<li><p>Bong</p></li>\n\n<li><p>Goo</p></li>\n</ul>\n",
 365
 366		"+ Hello\n",
 367		"<ul>\n<li>Hello</li>\n</ul>\n",
 368
 369		"+ Yin\n+ Yang\n",
 370		"<ul>\n<li>Yin</li>\n<li>Yang</li>\n</ul>\n",
 371
 372		"+ Ting\n+ Bong\n+ Goo\n",
 373		"<ul>\n<li>Ting</li>\n<li>Bong</li>\n<li>Goo</li>\n</ul>\n",
 374
 375		"+ Yin\n\n+ Yang\n",
 376		"<ul>\n<li><p>Yin</p></li>\n\n<li><p>Yang</p></li>\n</ul>\n",
 377
 378		"+ Ting\n\n+ Bong\n+ Goo\n",
 379		"<ul>\n<li><p>Ting</p></li>\n\n<li><p>Bong</p></li>\n\n<li><p>Goo</p></li>\n</ul>\n",
 380
 381		"- Hello\n",
 382		"<ul>\n<li>Hello</li>\n</ul>\n",
 383
 384		"- Yin\n- Yang\n",
 385		"<ul>\n<li>Yin</li>\n<li>Yang</li>\n</ul>\n",
 386
 387		"- Ting\n- Bong\n- Goo\n",
 388		"<ul>\n<li>Ting</li>\n<li>Bong</li>\n<li>Goo</li>\n</ul>\n",
 389
 390		"- Yin\n\n- Yang\n",
 391		"<ul>\n<li><p>Yin</p></li>\n\n<li><p>Yang</p></li>\n</ul>\n",
 392
 393		"- Ting\n\n- Bong\n- Goo\n",
 394		"<ul>\n<li><p>Ting</p></li>\n\n<li><p>Bong</p></li>\n\n<li><p>Goo</p></li>\n</ul>\n",
 395
 396		"*Hello\n",
 397		"<p>*Hello</p>\n",
 398
 399		"*   Hello \n",
 400		"<ul>\n<li>Hello</li>\n</ul>\n",
 401
 402		"*   Hello \n    Next line \n",
 403		"<ul>\n<li>Hello\nNext line</li>\n</ul>\n",
 404
 405		"Paragraph\n* No linebreak\n",
 406		"<p>Paragraph\n* No linebreak</p>\n",
 407
 408		"Paragraph\n\n* Linebreak\n",
 409		"<p>Paragraph</p>\n\n<ul>\n<li>Linebreak</li>\n</ul>\n",
 410
 411		"*   List\n    * Nested list\n",
 412		"<ul>\n<li>List\n\n<ul>\n<li>Nested list</li>\n</ul></li>\n</ul>\n",
 413
 414		"*   List\n\n    * Nested list\n",
 415		"<ul>\n<li><p>List</p>\n\n<ul>\n<li>Nested list</li>\n</ul></li>\n</ul>\n",
 416
 417		"*   List\n    Second line\n\n    + Nested\n",
 418		"<ul>\n<li><p>List\nSecond line</p>\n\n<ul>\n<li>Nested</li>\n</ul></li>\n</ul>\n",
 419
 420		"*   List\n    + Nested\n\n    Continued\n",
 421		"<ul>\n<li><p>List</p>\n\n<ul>\n<li>Nested</li>\n</ul>\n\n<p>Continued</p></li>\n</ul>\n",
 422
 423		"*   List\n   * shallow indent\n",
 424		"<ul>\n<li>List\n\n<ul>\n<li>shallow indent</li>\n</ul></li>\n</ul>\n",
 425
 426		"* List\n" +
 427			" * shallow indent\n" +
 428			"  * part of second list\n" +
 429			"   * still second\n" +
 430			"    * almost there\n" +
 431			"     * third level\n",
 432		"<ul>\n" +
 433			"<li>List\n\n" +
 434			"<ul>\n" +
 435			"<li>shallow indent</li>\n" +
 436			"<li>part of second list</li>\n" +
 437			"<li>still second</li>\n" +
 438			"<li>almost there\n\n" +
 439			"<ul>\n" +
 440			"<li>third level</li>\n" +
 441			"</ul></li>\n" +
 442			"</ul></li>\n" +
 443			"</ul>\n",
 444
 445		"* List\n        extra indent, same paragraph\n",
 446		"<ul>\n<li>List\n    extra indent, same paragraph</li>\n</ul>\n",
 447
 448		"* List\n\n        code block\n",
 449		"<ul>\n<li><p>List</p>\n\n<pre><code>code block\n</code></pre></li>\n</ul>\n",
 450
 451		"* List\n\n          code block with spaces\n",
 452		"<ul>\n<li><p>List</p>\n\n<pre><code>  code block with spaces\n</code></pre></li>\n</ul>\n",
 453
 454		"* List\n\n    * sublist\n\n    normal text\n\n    * another sublist\n",
 455		"<ul>\n<li><p>List</p>\n\n<ul>\n<li>sublist</li>\n</ul>\n\n<p>normal text</p>\n\n<ul>\n<li>another sublist</li>\n</ul></li>\n</ul>\n",
 456	}
 457	doTestsBlock(t, tests, 0)
 458}
 459
 460func TestOrderedList(t *testing.T) {
 461	var tests = []string{
 462		"1. Hello\n",
 463		"<ol>\n<li>Hello</li>\n</ol>\n",
 464
 465		"1. Yin\n2. Yang\n",
 466		"<ol>\n<li>Yin</li>\n<li>Yang</li>\n</ol>\n",
 467
 468		"1. Ting\n2. Bong\n3. Goo\n",
 469		"<ol>\n<li>Ting</li>\n<li>Bong</li>\n<li>Goo</li>\n</ol>\n",
 470
 471		"1. Yin\n\n2. Yang\n",
 472		"<ol>\n<li><p>Yin</p></li>\n\n<li><p>Yang</p></li>\n</ol>\n",
 473
 474		"1. Ting\n\n2. Bong\n3. Goo\n",
 475		"<ol>\n<li><p>Ting</p></li>\n\n<li><p>Bong</p></li>\n\n<li><p>Goo</p></li>\n</ol>\n",
 476
 477		"1 Hello\n",
 478		"<p>1 Hello</p>\n",
 479
 480		"1.Hello\n",
 481		"<p>1.Hello</p>\n",
 482
 483		"1.  Hello \n",
 484		"<ol>\n<li>Hello</li>\n</ol>\n",
 485
 486		"1.  Hello \n    Next line \n",
 487		"<ol>\n<li>Hello\nNext line</li>\n</ol>\n",
 488
 489		"Paragraph\n1. No linebreak\n",
 490		"<p>Paragraph\n1. No linebreak</p>\n",
 491
 492		"Paragraph\n\n1. Linebreak\n",
 493		"<p>Paragraph</p>\n\n<ol>\n<li>Linebreak</li>\n</ol>\n",
 494
 495		"1.  List\n    1. Nested list\n",
 496		"<ol>\n<li>List\n\n<ol>\n<li>Nested list</li>\n</ol></li>\n</ol>\n",
 497
 498		"1.  List\n\n    1. Nested list\n",
 499		"<ol>\n<li><p>List</p>\n\n<ol>\n<li>Nested list</li>\n</ol></li>\n</ol>\n",
 500
 501		"1.  List\n    Second line\n\n    1. Nested\n",
 502		"<ol>\n<li><p>List\nSecond line</p>\n\n<ol>\n<li>Nested</li>\n</ol></li>\n</ol>\n",
 503
 504		"1.  List\n    1. Nested\n\n    Continued\n",
 505		"<ol>\n<li><p>List</p>\n\n<ol>\n<li>Nested</li>\n</ol>\n\n<p>Continued</p></li>\n</ol>\n",
 506
 507		"1.  List\n   1. shallow indent\n",
 508		"<ol>\n<li>List\n\n<ol>\n<li>shallow indent</li>\n</ol></li>\n</ol>\n",
 509
 510		"1. List\n" +
 511			" 1. shallow indent\n" +
 512			"  2. part of second list\n" +
 513			"   3. still second\n" +
 514			"    4. almost there\n" +
 515			"     1. third level\n",
 516		"<ol>\n" +
 517			"<li>List\n\n" +
 518			"<ol>\n" +
 519			"<li>shallow indent</li>\n" +
 520			"<li>part of second list</li>\n" +
 521			"<li>still second</li>\n" +
 522			"<li>almost there\n\n" +
 523			"<ol>\n" +
 524			"<li>third level</li>\n" +
 525			"</ol></li>\n" +
 526			"</ol></li>\n" +
 527			"</ol>\n",
 528
 529		"1. List\n        extra indent, same paragraph\n",
 530		"<ol>\n<li>List\n    extra indent, same paragraph</li>\n</ol>\n",
 531
 532		"1. List\n\n        code block\n",
 533		"<ol>\n<li><p>List</p>\n\n<pre><code>code block\n</code></pre></li>\n</ol>\n",
 534
 535		"1. List\n\n          code block with spaces\n",
 536		"<ol>\n<li><p>List</p>\n\n<pre><code>  code block with spaces\n</code></pre></li>\n</ol>\n",
 537
 538		"1. List\n    * Mixted list\n",
 539		"<ol>\n<li>List\n\n<ul>\n<li>Mixted list</li>\n</ul></li>\n</ol>\n",
 540
 541		"1. List\n * Mixed list\n",
 542		"<ol>\n<li>List\n\n<ul>\n<li>Mixed list</li>\n</ul></li>\n</ol>\n",
 543
 544		"* Start with unordered\n 1. Ordered\n",
 545		"<ul>\n<li>Start with unordered\n\n<ol>\n<li>Ordered</li>\n</ol></li>\n</ul>\n",
 546
 547		"* Start with unordered\n    1. Ordered\n",
 548		"<ul>\n<li>Start with unordered\n\n<ol>\n<li>Ordered</li>\n</ol></li>\n</ul>\n",
 549
 550		"1. numbers\n1. are ignored\n",
 551		"<ol>\n<li>numbers</li>\n<li>are ignored</li>\n</ol>\n",
 552	}
 553	doTestsBlock(t, tests, 0)
 554}
 555
 556func TestPreformattedHtml(t *testing.T) {
 557	var tests = []string{
 558		"<div></div>\n",
 559		"<div></div>\n",
 560
 561		"<div>\n</div>\n",
 562		"<div>\n</div>\n",
 563
 564		"<div>\n</div>\nParagraph\n",
 565		"<p><div>\n</div>\nParagraph</p>\n",
 566
 567		"<div class=\"foo\">\n</div>\n",
 568		"<div class=\"foo\">\n</div>\n",
 569
 570		"<div>\nAnything here\n</div>\n",
 571		"<div>\nAnything here\n</div>\n",
 572
 573		"<div>\n  Anything here\n</div>\n",
 574		"<div>\n  Anything here\n</div>\n",
 575
 576		"<div>\nAnything here\n  </div>\n",
 577		"<div>\nAnything here\n  </div>\n",
 578
 579		"<div>\nThis is *not* &proceessed\n</div>\n",
 580		"<div>\nThis is *not* &proceessed\n</div>\n",
 581
 582		"<faketag>\n  Something\n</faketag>\n",
 583		"<p><faketag>\n  Something\n</faketag></p>\n",
 584
 585		"<div>\n  Something here\n</divv>\n",
 586		"<p><div>\n  Something here\n</divv></p>\n",
 587
 588		"Paragraph\n<div>\nHere? >&<\n</div>\n",
 589		"<p>Paragraph\n<div>\nHere? &gt;&amp;&lt;\n</div></p>\n",
 590
 591		"Paragraph\n\n<div>\nHow about here? >&<\n</div>\n",
 592		"<p>Paragraph</p>\n\n<div>\nHow about here? >&<\n</div>\n",
 593
 594		"Paragraph\n<div>\nHere? >&<\n</div>\nAnd here?\n",
 595		"<p>Paragraph\n<div>\nHere? &gt;&amp;&lt;\n</div>\nAnd here?</p>\n",
 596
 597		"Paragraph\n\n<div>\nHow about here? >&<\n</div>\nAnd here?\n",
 598		"<p>Paragraph</p>\n\n<p><div>\nHow about here? &gt;&amp;&lt;\n</div>\nAnd here?</p>\n",
 599
 600		"Paragraph\n<div>\nHere? >&<\n</div>\n\nAnd here?\n",
 601		"<p>Paragraph\n<div>\nHere? &gt;&amp;&lt;\n</div></p>\n\n<p>And here?</p>\n",
 602
 603		"Paragraph\n\n<div>\nHow about here? >&<\n</div>\n\nAnd here?\n",
 604		"<p>Paragraph</p>\n\n<div>\nHow about here? >&<\n</div>\n\n<p>And here?</p>\n",
 605	}
 606	doTestsBlock(t, tests, 0)
 607}
 608
 609func TestPreformattedHtmlLax(t *testing.T) {
 610	var tests = []string{
 611		"Paragraph\n<div>\nHere? >&<\n</div>\n",
 612		"<p>Paragraph</p>\n\n<div>\nHere? >&<\n</div>\n",
 613
 614		"Paragraph\n\n<div>\nHow about here? >&<\n</div>\n",
 615		"<p>Paragraph</p>\n\n<div>\nHow about here? >&<\n</div>\n",
 616
 617		"Paragraph\n<div>\nHere? >&<\n</div>\nAnd here?\n",
 618		"<p>Paragraph</p>\n\n<div>\nHere? >&<\n</div>\n\n<p>And here?</p>\n",
 619
 620		"Paragraph\n\n<div>\nHow about here? >&<\n</div>\nAnd here?\n",
 621		"<p>Paragraph</p>\n\n<div>\nHow about here? >&<\n</div>\n\n<p>And here?</p>\n",
 622
 623		"Paragraph\n<div>\nHere? >&<\n</div>\n\nAnd here?\n",
 624		"<p>Paragraph</p>\n\n<div>\nHere? >&<\n</div>\n\n<p>And here?</p>\n",
 625
 626		"Paragraph\n\n<div>\nHow about here? >&<\n</div>\n\nAnd here?\n",
 627		"<p>Paragraph</p>\n\n<div>\nHow about here? >&<\n</div>\n\n<p>And here?</p>\n",
 628	}
 629	doTestsBlock(t, tests, EXTENSION_LAX_HTML_BLOCKS)
 630}
 631
 632func TestFencedCodeBlock(t *testing.T) {
 633	var tests = []string{
 634		"``` go\nfunc foo() bool {\n\treturn true;\n}\n```\n",
 635		"<pre><code class=\"go\">func foo() bool {\n    return true;\n}\n</code></pre>\n",
 636
 637		"``` c\n/* special & char < > \" escaping */\n```\n",
 638		"<pre><code class=\"c\">/* special &amp; char &lt; &gt; &quot; escaping */\n</code></pre>\n",
 639
 640		"``` c\nno *inline* processing ~~of text~~\n```\n",
 641		"<pre><code class=\"c\">no *inline* processing ~~of text~~\n</code></pre>\n",
 642
 643		"```\nNo language\n```\n",
 644		"<pre><code>No language\n</code></pre>\n",
 645
 646		"``` {ocaml}\nlanguage in braces\n```\n",
 647		"<pre><code class=\"ocaml\">language in braces\n</code></pre>\n",
 648
 649		"```    {ocaml}      \nwith extra whitespace\n```\n",
 650		"<pre><code class=\"ocaml\">with extra whitespace\n</code></pre>\n",
 651
 652		"```{   ocaml   }\nwith extra whitespace\n```\n",
 653		"<pre><code class=\"ocaml\">with extra whitespace\n</code></pre>\n",
 654
 655		"~ ~~ java\nWith whitespace\n~~~\n",
 656		"<p>~ ~~ java\nWith whitespace\n~~~</p>\n",
 657
 658		"~~\nonly two\n~~\n",
 659		"<p>~~\nonly two\n~~</p>\n",
 660
 661		"```` python\nextra\n````\n",
 662		"<pre><code class=\"python\">extra\n</code></pre>\n",
 663
 664		"~~~ perl\nthree to start, four to end\n~~~~\n",
 665		"<p>~~~ perl\nthree to start, four to end\n~~~~</p>\n",
 666
 667		"~~~~ perl\nfour to start, three to end\n~~~\n",
 668		"<p>~~~~ perl\nfour to start, three to end\n~~~</p>\n",
 669
 670		"~~~ bash\ntildes\n~~~\n",
 671		"<pre><code class=\"bash\">tildes\n</code></pre>\n",
 672
 673		"``` lisp\nno ending\n",
 674		"<p>``` lisp\nno ending</p>\n",
 675
 676		"~~~ lisp\nend with language\n~~~ lisp\n",
 677		"<p>~~~ lisp\nend with language\n~~~ lisp</p>\n",
 678
 679		"```\nmismatched begin and end\n~~~\n",
 680		"<p>```\nmismatched begin and end\n~~~</p>\n",
 681
 682		"~~~\nmismatched begin and end\n```\n",
 683		"<p>~~~\nmismatched begin and end\n```</p>\n",
 684
 685		"   ``` oz\nleading spaces\n```\n",
 686		"<pre><code class=\"oz\">leading spaces\n</code></pre>\n",
 687
 688		"  ``` oz\nleading spaces\n ```\n",
 689		"<pre><code class=\"oz\">leading spaces\n</code></pre>\n",
 690
 691		" ``` oz\nleading spaces\n  ```\n",
 692		"<pre><code class=\"oz\">leading spaces\n</code></pre>\n",
 693
 694		"``` oz\nleading spaces\n   ```\n",
 695		"<pre><code class=\"oz\">leading spaces\n</code></pre>\n",
 696
 697		"    ``` oz\nleading spaces\n    ```\n",
 698		"<pre><code>``` oz\n</code></pre>\n\n<p>leading spaces\n    ```</p>\n",
 699	}
 700	doTestsBlock(t, tests, EXTENSION_FENCED_CODE)
 701}
 702
 703func TestTable(t *testing.T) {
 704	var tests = []string{
 705		"a | b\n---|---\nc | d\n",
 706		"<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n</tr>\n</thead>\n\n" +
 707			"<tbody>\n<tr>\n<td>c</td>\n<td>d</td>\n</tr>\n</tbody>\n</table>\n",
 708
 709		"a | b\n---|--\nc | d\n",
 710		"<p>a | b\n---|--\nc | d</p>\n",
 711
 712		"|a|b|c|d|\n|----|----|----|---|\n|e|f|g|h|\n",
 713		"<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n<th>c</th>\n<th>d</th>\n</tr>\n</thead>\n\n" +
 714			"<tbody>\n<tr>\n<td>e</td>\n<td>f</td>\n<td>g</td>\n<td>h</td>\n</tr>\n</tbody>\n</table>\n",
 715
 716		"*a*|__b__|[c](C)|d\n---|---|---|---\ne|f|g|h\n",
 717		"<table>\n<thead>\n<tr>\n<th><em>a</em></th>\n<th><strong>b</strong></th>\n<th><a href=\"C\">c</a></th>\n<th>d</th>\n</tr>\n</thead>\n\n" +
 718			"<tbody>\n<tr>\n<td>e</td>\n<td>f</td>\n<td>g</td>\n<td>h</td>\n</tr>\n</tbody>\n</table>\n",
 719
 720		"a|b|c\n---|---|---\nd|e|f\ng|h\ni|j|k|l|m\nn|o|p\n",
 721		"<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n<th>c</th>\n</tr>\n</thead>\n\n" +
 722			"<tbody>\n<tr>\n<td>d</td>\n<td>e</td>\n<td>f</td>\n</tr>\n\n" +
 723			"<tr>\n<td>g</td>\n<td>h</td>\n<td></td>\n</tr>\n\n" +
 724			"<tr>\n<td>i</td>\n<td>j</td>\n<td>k</td>\n</tr>\n\n" +
 725			"<tr>\n<td>n</td>\n<td>o</td>\n<td>p</td>\n</tr>\n</tbody>\n</table>\n",
 726
 727		"a|b|c\n---|---|---\n*d*|__e__|f\n",
 728		"<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n<th>c</th>\n</tr>\n</thead>\n\n" +
 729			"<tbody>\n<tr>\n<td><em>d</em></td>\n<td><strong>e</strong></td>\n<td>f</td>\n</tr>\n</tbody>\n</table>\n",
 730
 731		"a|b|c|d\n:--|--:|:-:|---\ne|f|g|h\n",
 732		"<table>\n<thead>\n<tr>\n<th align=\"left\">a</th>\n<th align=\"right\">b</th>\n" +
 733			"<th align=\"center\">c</th>\n<th>d</th>\n</tr>\n</thead>\n\n" +
 734			"<tbody>\n<tr>\n<td align=\"left\">e</td>\n<td align=\"right\">f</td>\n" +
 735			"<td align=\"center\">g</td>\n<td>h</td>\n</tr>\n</tbody>\n</table>\n",
 736
 737		"a|b|c\n---|---|---\n",
 738		"<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n<th>c</th>\n</tr>\n</thead>\n\n<tbody>\n</tbody>\n</table>\n",
 739
 740		"a| b|c | d | e\n---|---|---|---|---\nf| g|h | i |j\n",
 741		"<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n<th>c</th>\n<th>d</th>\n<th>e</th>\n</tr>\n</thead>\n\n" +
 742			"<tbody>\n<tr>\n<td>f</td>\n<td>g</td>\n<td>h</td>\n<td>i</td>\n<td>j</td>\n</tr>\n</tbody>\n</table>\n",
 743
 744		"a|b\\|c|d\n---|---|---\nf|g\\|h|i\n",
 745		"<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b|c</th>\n<th>d</th>\n</tr>\n</thead>\n\n<tbody>\n<tr>\n<td>f</td>\n<td>g|h</td>\n<td>i</td>\n</tr>\n</tbody>\n</table>\n",
 746	}
 747	doTestsBlock(t, tests, EXTENSION_TABLES)
 748}
 749
 750func TestUnorderedListWith_EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK(t *testing.T) {
 751	var tests = []string{
 752		"* Hello\n",
 753		"<ul>\n<li>Hello</li>\n</ul>\n",
 754
 755		"* Yin\n* Yang\n",
 756		"<ul>\n<li>Yin</li>\n<li>Yang</li>\n</ul>\n",
 757
 758		"* Ting\n* Bong\n* Goo\n",
 759		"<ul>\n<li>Ting</li>\n<li>Bong</li>\n<li>Goo</li>\n</ul>\n",
 760
 761		"* Yin\n\n* Yang\n",
 762		"<ul>\n<li><p>Yin</p></li>\n\n<li><p>Yang</p></li>\n</ul>\n",
 763
 764		"* Ting\n\n* Bong\n* Goo\n",
 765		"<ul>\n<li><p>Ting</p></li>\n\n<li><p>Bong</p></li>\n\n<li><p>Goo</p></li>\n</ul>\n",
 766
 767		"+ Hello\n",
 768		"<ul>\n<li>Hello</li>\n</ul>\n",
 769
 770		"+ Yin\n+ Yang\n",
 771		"<ul>\n<li>Yin</li>\n<li>Yang</li>\n</ul>\n",
 772
 773		"+ Ting\n+ Bong\n+ Goo\n",
 774		"<ul>\n<li>Ting</li>\n<li>Bong</li>\n<li>Goo</li>\n</ul>\n",
 775
 776		"+ Yin\n\n+ Yang\n",
 777		"<ul>\n<li><p>Yin</p></li>\n\n<li><p>Yang</p></li>\n</ul>\n",
 778
 779		"+ Ting\n\n+ Bong\n+ Goo\n",
 780		"<ul>\n<li><p>Ting</p></li>\n\n<li><p>Bong</p></li>\n\n<li><p>Goo</p></li>\n</ul>\n",
 781
 782		"- Hello\n",
 783		"<ul>\n<li>Hello</li>\n</ul>\n",
 784
 785		"- Yin\n- Yang\n",
 786		"<ul>\n<li>Yin</li>\n<li>Yang</li>\n</ul>\n",
 787
 788		"- Ting\n- Bong\n- Goo\n",
 789		"<ul>\n<li>Ting</li>\n<li>Bong</li>\n<li>Goo</li>\n</ul>\n",
 790
 791		"- Yin\n\n- Yang\n",
 792		"<ul>\n<li><p>Yin</p></li>\n\n<li><p>Yang</p></li>\n</ul>\n",
 793
 794		"- Ting\n\n- Bong\n- Goo\n",
 795		"<ul>\n<li><p>Ting</p></li>\n\n<li><p>Bong</p></li>\n\n<li><p>Goo</p></li>\n</ul>\n",
 796
 797		"*Hello\n",
 798		"<p>*Hello</p>\n",
 799
 800		"*   Hello \n",
 801		"<ul>\n<li>Hello</li>\n</ul>\n",
 802
 803		"*   Hello \n    Next line \n",
 804		"<ul>\n<li>Hello\nNext line</li>\n</ul>\n",
 805
 806		"Paragraph\n* No linebreak\n",
 807		"<p>Paragraph</p>\n\n<ul>\n<li>No linebreak</li>\n</ul>\n",
 808
 809		"Paragraph\n\n* Linebreak\n",
 810		"<p>Paragraph</p>\n\n<ul>\n<li>Linebreak</li>\n</ul>\n",
 811
 812		"*   List\n    * Nested list\n",
 813		"<ul>\n<li>List\n\n<ul>\n<li>Nested list</li>\n</ul></li>\n</ul>\n",
 814
 815		"*   List\n\n    * Nested list\n",
 816		"<ul>\n<li><p>List</p>\n\n<ul>\n<li>Nested list</li>\n</ul></li>\n</ul>\n",
 817
 818		"*   List\n    Second line\n\n    + Nested\n",
 819		"<ul>\n<li><p>List\nSecond line</p>\n\n<ul>\n<li>Nested</li>\n</ul></li>\n</ul>\n",
 820
 821		"*   List\n    + Nested\n\n    Continued\n",
 822		"<ul>\n<li><p>List</p>\n\n<ul>\n<li>Nested</li>\n</ul>\n\n<p>Continued</p></li>\n</ul>\n",
 823
 824		"*   List\n   * shallow indent\n",
 825		"<ul>\n<li>List\n\n<ul>\n<li>shallow indent</li>\n</ul></li>\n</ul>\n",
 826
 827		"* List\n" +
 828			" * shallow indent\n" +
 829			"  * part of second list\n" +
 830			"   * still second\n" +
 831			"    * almost there\n" +
 832			"     * third level\n",
 833		"<ul>\n" +
 834			"<li>List\n\n" +
 835			"<ul>\n" +
 836			"<li>shallow indent</li>\n" +
 837			"<li>part of second list</li>\n" +
 838			"<li>still second</li>\n" +
 839			"<li>almost there\n\n" +
 840			"<ul>\n" +
 841			"<li>third level</li>\n" +
 842			"</ul></li>\n" +
 843			"</ul></li>\n" +
 844			"</ul>\n",
 845
 846		"* List\n        extra indent, same paragraph\n",
 847		"<ul>\n<li>List\n    extra indent, same paragraph</li>\n</ul>\n",
 848
 849		"* List\n\n        code block\n",
 850		"<ul>\n<li><p>List</p>\n\n<pre><code>code block\n</code></pre></li>\n</ul>\n",
 851
 852		"* List\n\n          code block with spaces\n",
 853		"<ul>\n<li><p>List</p>\n\n<pre><code>  code block with spaces\n</code></pre></li>\n</ul>\n",
 854
 855		"* List\n\n    * sublist\n\n    normal text\n\n    * another sublist\n",
 856		"<ul>\n<li><p>List</p>\n\n<ul>\n<li>sublist</li>\n</ul>\n\n<p>normal text</p>\n\n<ul>\n<li>another sublist</li>\n</ul></li>\n</ul>\n",
 857	}
 858	doTestsBlock(t, tests, EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK)
 859}
 860
 861func TestOrderedList_EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK(t *testing.T) {
 862	var tests = []string{
 863		"1. Hello\n",
 864		"<ol>\n<li>Hello</li>\n</ol>\n",
 865
 866		"1. Yin\n2. Yang\n",
 867		"<ol>\n<li>Yin</li>\n<li>Yang</li>\n</ol>\n",
 868
 869		"1. Ting\n2. Bong\n3. Goo\n",
 870		"<ol>\n<li>Ting</li>\n<li>Bong</li>\n<li>Goo</li>\n</ol>\n",
 871
 872		"1. Yin\n\n2. Yang\n",
 873		"<ol>\n<li><p>Yin</p></li>\n\n<li><p>Yang</p></li>\n</ol>\n",
 874
 875		"1. Ting\n\n2. Bong\n3. Goo\n",
 876		"<ol>\n<li><p>Ting</p></li>\n\n<li><p>Bong</p></li>\n\n<li><p>Goo</p></li>\n</ol>\n",
 877
 878		"1 Hello\n",
 879		"<p>1 Hello</p>\n",
 880
 881		"1.Hello\n",
 882		"<p>1.Hello</p>\n",
 883
 884		"1.  Hello \n",
 885		"<ol>\n<li>Hello</li>\n</ol>\n",
 886
 887		"1.  Hello \n    Next line \n",
 888		"<ol>\n<li>Hello\nNext line</li>\n</ol>\n",
 889
 890		"Paragraph\n1. No linebreak\n",
 891		"<p>Paragraph</p>\n\n<ol>\n<li>No linebreak</li>\n</ol>\n",
 892
 893		"Paragraph\n\n1. Linebreak\n",
 894		"<p>Paragraph</p>\n\n<ol>\n<li>Linebreak</li>\n</ol>\n",
 895
 896		"1.  List\n    1. Nested list\n",
 897		"<ol>\n<li>List\n\n<ol>\n<li>Nested list</li>\n</ol></li>\n</ol>\n",
 898
 899		"1.  List\n\n    1. Nested list\n",
 900		"<ol>\n<li><p>List</p>\n\n<ol>\n<li>Nested list</li>\n</ol></li>\n</ol>\n",
 901
 902		"1.  List\n    Second line\n\n    1. Nested\n",
 903		"<ol>\n<li><p>List\nSecond line</p>\n\n<ol>\n<li>Nested</li>\n</ol></li>\n</ol>\n",
 904
 905		"1.  List\n    1. Nested\n\n    Continued\n",
 906		"<ol>\n<li><p>List</p>\n\n<ol>\n<li>Nested</li>\n</ol>\n\n<p>Continued</p></li>\n</ol>\n",
 907
 908		"1.  List\n   1. shallow indent\n",
 909		"<ol>\n<li>List\n\n<ol>\n<li>shallow indent</li>\n</ol></li>\n</ol>\n",
 910
 911		"1. List\n" +
 912			" 1. shallow indent\n" +
 913			"  2. part of second list\n" +
 914			"   3. still second\n" +
 915			"    4. almost there\n" +
 916			"     1. third level\n",
 917		"<ol>\n" +
 918			"<li>List\n\n" +
 919			"<ol>\n" +
 920			"<li>shallow indent</li>\n" +
 921			"<li>part of second list</li>\n" +
 922			"<li>still second</li>\n" +
 923			"<li>almost there\n\n" +
 924			"<ol>\n" +
 925			"<li>third level</li>\n" +
 926			"</ol></li>\n" +
 927			"</ol></li>\n" +
 928			"</ol>\n",
 929
 930		"1. List\n        extra indent, same paragraph\n",
 931		"<ol>\n<li>List\n    extra indent, same paragraph</li>\n</ol>\n",
 932
 933		"1. List\n\n        code block\n",
 934		"<ol>\n<li><p>List</p>\n\n<pre><code>code block\n</code></pre></li>\n</ol>\n",
 935
 936		"1. List\n\n          code block with spaces\n",
 937		"<ol>\n<li><p>List</p>\n\n<pre><code>  code block with spaces\n</code></pre></li>\n</ol>\n",
 938
 939		"1. List\n    * Mixted list\n",
 940		"<ol>\n<li>List\n\n<ul>\n<li>Mixted list</li>\n</ul></li>\n</ol>\n",
 941
 942		"1. List\n * Mixed list\n",
 943		"<ol>\n<li>List\n\n<ul>\n<li>Mixed list</li>\n</ul></li>\n</ol>\n",
 944
 945		"* Start with unordered\n 1. Ordered\n",
 946		"<ul>\n<li>Start with unordered\n\n<ol>\n<li>Ordered</li>\n</ol></li>\n</ul>\n",
 947
 948		"* Start with unordered\n    1. Ordered\n",
 949		"<ul>\n<li>Start with unordered\n\n<ol>\n<li>Ordered</li>\n</ol></li>\n</ul>\n",
 950
 951		"1. numbers\n1. are ignored\n",
 952		"<ol>\n<li>numbers</li>\n<li>are ignored</li>\n</ol>\n",
 953	}
 954	doTestsBlock(t, tests, EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK)
 955}
 956
 957func TestFencedCodeBlock_EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK(t *testing.T) {
 958	var tests = []string{
 959		"``` go\nfunc foo() bool {\n\treturn true;\n}\n```\n",
 960		"<pre><code class=\"go\">func foo() bool {\n    return true;\n}\n</code></pre>\n",
 961
 962		"``` c\n/* special & char < > \" escaping */\n```\n",
 963		"<pre><code class=\"c\">/* special &amp; char &lt; &gt; &quot; escaping */\n</code></pre>\n",
 964
 965		"``` c\nno *inline* processing ~~of text~~\n```\n",
 966		"<pre><code class=\"c\">no *inline* processing ~~of text~~\n</code></pre>\n",
 967
 968		"```\nNo language\n```\n",
 969		"<pre><code>No language\n</code></pre>\n",
 970
 971		"``` {ocaml}\nlanguage in braces\n```\n",
 972		"<pre><code class=\"ocaml\">language in braces\n</code></pre>\n",
 973
 974		"```    {ocaml}      \nwith extra whitespace\n```\n",
 975		"<pre><code class=\"ocaml\">with extra whitespace\n</code></pre>\n",
 976
 977		"```{   ocaml   }\nwith extra whitespace\n```\n",
 978		"<pre><code class=\"ocaml\">with extra whitespace\n</code></pre>\n",
 979
 980		"~ ~~ java\nWith whitespace\n~~~\n",
 981		"<p>~ ~~ java\nWith whitespace\n~~~</p>\n",
 982
 983		"~~\nonly two\n~~\n",
 984		"<p>~~\nonly two\n~~</p>\n",
 985
 986		"```` python\nextra\n````\n",
 987		"<pre><code class=\"python\">extra\n</code></pre>\n",
 988
 989		"~~~ perl\nthree to start, four to end\n~~~~\n",
 990		"<p>~~~ perl\nthree to start, four to end\n~~~~</p>\n",
 991
 992		"~~~~ perl\nfour to start, three to end\n~~~\n",
 993		"<p>~~~~ perl\nfour to start, three to end\n~~~</p>\n",
 994
 995		"~~~ bash\ntildes\n~~~\n",
 996		"<pre><code class=\"bash\">tildes\n</code></pre>\n",
 997
 998		"``` lisp\nno ending\n",
 999		"<p>``` lisp\nno ending</p>\n",
1000
1001		"~~~ lisp\nend with language\n~~~ lisp\n",
1002		"<p>~~~ lisp\nend with language\n~~~ lisp</p>\n",
1003
1004		"```\nmismatched begin and end\n~~~\n",
1005		"<p>```\nmismatched begin and end\n~~~</p>\n",
1006
1007		"~~~\nmismatched begin and end\n```\n",
1008		"<p>~~~\nmismatched begin and end\n```</p>\n",
1009
1010		"   ``` oz\nleading spaces\n```\n",
1011		"<pre><code class=\"oz\">leading spaces\n</code></pre>\n",
1012
1013		"  ``` oz\nleading spaces\n ```\n",
1014		"<pre><code class=\"oz\">leading spaces\n</code></pre>\n",
1015
1016		" ``` oz\nleading spaces\n  ```\n",
1017		"<pre><code class=\"oz\">leading spaces\n</code></pre>\n",
1018
1019		"``` oz\nleading spaces\n   ```\n",
1020		"<pre><code class=\"oz\">leading spaces\n</code></pre>\n",
1021
1022		"    ``` oz\nleading spaces\n    ```\n",
1023		"<pre><code>``` oz\n</code></pre>\n\n<p>leading spaces</p>\n\n<pre><code>```\n</code></pre>\n",
1024	}
1025	doTestsBlock(t, tests, EXTENSION_FENCED_CODE|EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK)
1026}