all repos — grayfriday @ 857a1a0260be14ca4a45c4236e6f712e4c2256ae

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]: %s\n", candidate, err)
  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		"# Header 1 # {#someid}\n",
 219		"<h1 id=\"someid\">Header 1</h1>\n",
 220
 221		"## Header 2 ## {#someid}\n",
 222		"<h2 id=\"someid\">Header 2</h2>\n",
 223
 224		"Hello\n# Header 1\nGoodbye\n",
 225		"<p>Hello</p>\n\n<h1>Header 1</h1>\n\n<p>Goodbye</p>\n",
 226
 227		"* List\n# Header {#someid}\n* List\n",
 228		"<ul>\n<li><p>List</p>\n\n<h1 id=\"someid\">Header</h1></li>\n\n<li><p>List</p></li>\n</ul>\n",
 229
 230		"* List\n#Header {#someid}\n* List\n",
 231		"<ul>\n<li><p>List</p>\n\n<h1 id=\"someid\">Header</h1></li>\n\n<li><p>List</p></li>\n</ul>\n",
 232
 233		"*   List\n    * Nested list\n    # Nested header {#someid}\n",
 234		"<ul>\n<li><p>List</p>\n\n<ul>\n<li><p>Nested list</p>\n\n" +
 235			"<h1 id=\"someid\">Nested header</h1></li>\n</ul></li>\n</ul>\n",
 236	}
 237	doTestsBlock(t, tests, EXTENSION_HEADER_IDS)
 238}
 239
 240func TestPrefixAutoHeaderIdExtension(t *testing.T) {
 241	var tests = []string{
 242		"# Header 1\n",
 243		"<h1 id=\"header-1\">Header 1</h1>\n",
 244
 245		"# Header 1   \n",
 246		"<h1 id=\"header-1\">Header 1</h1>\n",
 247
 248		"## Header 2\n",
 249		"<h2 id=\"header-2\">Header 2</h2>\n",
 250
 251		"### Header 3\n",
 252		"<h3 id=\"header-3\">Header 3</h3>\n",
 253
 254		"#### Header 4\n",
 255		"<h4 id=\"header-4\">Header 4</h4>\n",
 256
 257		"##### Header 5\n",
 258		"<h5 id=\"header-5\">Header 5</h5>\n",
 259
 260		"###### Header 6\n",
 261		"<h6 id=\"header-6\">Header 6</h6>\n",
 262
 263		"####### Header 7\n",
 264		"<h6 id=\"-header-7\"># Header 7</h6>\n",
 265
 266		"Hello\n# Header 1\nGoodbye\n",
 267		"<p>Hello</p>\n\n<h1 id=\"header-1\">Header 1</h1>\n\n<p>Goodbye</p>\n",
 268
 269		"* List\n# Header\n* List\n",
 270		"<ul>\n<li><p>List</p>\n\n<h1 id=\"header\">Header</h1></li>\n\n<li><p>List</p></li>\n</ul>\n",
 271
 272		"* List\n#Header\n* List\n",
 273		"<ul>\n<li><p>List</p>\n\n<h1 id=\"header\">Header</h1></li>\n\n<li><p>List</p></li>\n</ul>\n",
 274
 275		"*   List\n    * Nested list\n    # Nested header\n",
 276		"<ul>\n<li><p>List</p>\n\n<ul>\n<li><p>Nested list</p>\n\n" +
 277			"<h1 id=\"nested-header\">Nested header</h1></li>\n</ul></li>\n</ul>\n",
 278	}
 279	doTestsBlock(t, tests, EXTENSION_AUTO_HEADER_IDS)
 280}
 281
 282func TestUnderlineHeaders(t *testing.T) {
 283	var tests = []string{
 284		"Header 1\n========\n",
 285		"<h1>Header 1</h1>\n",
 286
 287		"Header 2\n--------\n",
 288		"<h2>Header 2</h2>\n",
 289
 290		"A\n=\n",
 291		"<h1>A</h1>\n",
 292
 293		"B\n-\n",
 294		"<h2>B</h2>\n",
 295
 296		"Paragraph\nHeader\n=\n",
 297		"<p>Paragraph</p>\n\n<h1>Header</h1>\n",
 298
 299		"Header\n===\nParagraph\n",
 300		"<h1>Header</h1>\n\n<p>Paragraph</p>\n",
 301
 302		"Header\n===\nAnother header\n---\n",
 303		"<h1>Header</h1>\n\n<h2>Another header</h2>\n",
 304
 305		"   Header\n======\n",
 306		"<h1>Header</h1>\n",
 307
 308		"    Code\n========\n",
 309		"<pre><code>Code\n</code></pre>\n\n<p>========</p>\n",
 310
 311		"Header with *inline*\n=====\n",
 312		"<h1>Header with <em>inline</em></h1>\n",
 313
 314		"*   List\n    * Sublist\n    Not a header\n    ------\n",
 315		"<ul>\n<li>List\n\n<ul>\n<li>Sublist\nNot a header\n------</li>\n</ul></li>\n</ul>\n",
 316
 317		"Paragraph\n\n\n\n\nHeader\n===\n",
 318		"<p>Paragraph</p>\n\n<h1>Header</h1>\n",
 319
 320		"Trailing space \n====        \n\n",
 321		"<h1>Trailing space</h1>\n",
 322
 323		"Trailing spaces\n====        \n\n",
 324		"<h1>Trailing spaces</h1>\n",
 325
 326		"Double underline\n=====\n=====\n",
 327		"<h1>Double underline</h1>\n\n<p>=====</p>\n",
 328	}
 329	doTestsBlock(t, tests, 0)
 330}
 331
 332func TestUnderlineHeadersAutoIDs(t *testing.T) {
 333	var tests = []string{
 334		"Header 1\n========\n",
 335		"<h1 id=\"header-1\">Header 1</h1>\n",
 336
 337		"Header 2\n--------\n",
 338		"<h2 id=\"header-2\">Header 2</h2>\n",
 339
 340		"A\n=\n",
 341		"<h1 id=\"a\">A</h1>\n",
 342
 343		"B\n-\n",
 344		"<h2 id=\"b\">B</h2>\n",
 345
 346		"Paragraph\nHeader\n=\n",
 347		"<p>Paragraph</p>\n\n<h1 id=\"header\">Header</h1>\n",
 348
 349		"Header\n===\nParagraph\n",
 350		"<h1 id=\"header\">Header</h1>\n\n<p>Paragraph</p>\n",
 351
 352		"Header\n===\nAnother header\n---\n",
 353		"<h1 id=\"header\">Header</h1>\n\n<h2 id=\"another-header\">Another header</h2>\n",
 354
 355		"   Header\n======\n",
 356		"<h1 id=\"header\">Header</h1>\n",
 357
 358		"Header with *inline*\n=====\n",
 359		"<h1 id=\"header-with-inline\">Header with <em>inline</em></h1>\n",
 360
 361		"Paragraph\n\n\n\n\nHeader\n===\n",
 362		"<p>Paragraph</p>\n\n<h1 id=\"header\">Header</h1>\n",
 363
 364		"Trailing space \n====        \n\n",
 365		"<h1 id=\"trailing-space\">Trailing space</h1>\n",
 366
 367		"Trailing spaces\n====        \n\n",
 368		"<h1 id=\"trailing-spaces\">Trailing spaces</h1>\n",
 369
 370		"Double underline\n=====\n=====\n",
 371		"<h1 id=\"double-underline\">Double underline</h1>\n\n<p>=====</p>\n",
 372	}
 373	doTestsBlock(t, tests, EXTENSION_AUTO_HEADER_IDS)
 374}
 375
 376func TestHorizontalRule(t *testing.T) {
 377	var tests = []string{
 378		"-\n",
 379		"<p>-</p>\n",
 380
 381		"--\n",
 382		"<p>--</p>\n",
 383
 384		"---\n",
 385		"<hr />\n",
 386
 387		"----\n",
 388		"<hr />\n",
 389
 390		"*\n",
 391		"<p>*</p>\n",
 392
 393		"**\n",
 394		"<p>**</p>\n",
 395
 396		"***\n",
 397		"<hr />\n",
 398
 399		"****\n",
 400		"<hr />\n",
 401
 402		"_\n",
 403		"<p>_</p>\n",
 404
 405		"__\n",
 406		"<p>__</p>\n",
 407
 408		"___\n",
 409		"<hr />\n",
 410
 411		"____\n",
 412		"<hr />\n",
 413
 414		"-*-\n",
 415		"<p>-*-</p>\n",
 416
 417		"- - -\n",
 418		"<hr />\n",
 419
 420		"* * *\n",
 421		"<hr />\n",
 422
 423		"_ _ _\n",
 424		"<hr />\n",
 425
 426		"-----*\n",
 427		"<p>-----*</p>\n",
 428
 429		"   ------   \n",
 430		"<hr />\n",
 431
 432		"Hello\n***\n",
 433		"<p>Hello</p>\n\n<hr />\n",
 434
 435		"---\n***\n___\n",
 436		"<hr />\n\n<hr />\n\n<hr />\n",
 437	}
 438	doTestsBlock(t, tests, 0)
 439}
 440
 441func TestUnorderedList(t *testing.T) {
 442	var tests = []string{
 443		"* Hello\n",
 444		"<ul>\n<li>Hello</li>\n</ul>\n",
 445
 446		"* Yin\n* Yang\n",
 447		"<ul>\n<li>Yin</li>\n<li>Yang</li>\n</ul>\n",
 448
 449		"* Ting\n* Bong\n* Goo\n",
 450		"<ul>\n<li>Ting</li>\n<li>Bong</li>\n<li>Goo</li>\n</ul>\n",
 451
 452		"* Yin\n\n* Yang\n",
 453		"<ul>\n<li><p>Yin</p></li>\n\n<li><p>Yang</p></li>\n</ul>\n",
 454
 455		"* Ting\n\n* Bong\n* Goo\n",
 456		"<ul>\n<li><p>Ting</p></li>\n\n<li><p>Bong</p></li>\n\n<li><p>Goo</p></li>\n</ul>\n",
 457
 458		"+ Hello\n",
 459		"<ul>\n<li>Hello</li>\n</ul>\n",
 460
 461		"+ Yin\n+ Yang\n",
 462		"<ul>\n<li>Yin</li>\n<li>Yang</li>\n</ul>\n",
 463
 464		"+ Ting\n+ Bong\n+ Goo\n",
 465		"<ul>\n<li>Ting</li>\n<li>Bong</li>\n<li>Goo</li>\n</ul>\n",
 466
 467		"+ Yin\n\n+ Yang\n",
 468		"<ul>\n<li><p>Yin</p></li>\n\n<li><p>Yang</p></li>\n</ul>\n",
 469
 470		"+ Ting\n\n+ Bong\n+ Goo\n",
 471		"<ul>\n<li><p>Ting</p></li>\n\n<li><p>Bong</p></li>\n\n<li><p>Goo</p></li>\n</ul>\n",
 472
 473		"- Hello\n",
 474		"<ul>\n<li>Hello</li>\n</ul>\n",
 475
 476		"- Yin\n- Yang\n",
 477		"<ul>\n<li>Yin</li>\n<li>Yang</li>\n</ul>\n",
 478
 479		"- Ting\n- Bong\n- Goo\n",
 480		"<ul>\n<li>Ting</li>\n<li>Bong</li>\n<li>Goo</li>\n</ul>\n",
 481
 482		"- Yin\n\n- Yang\n",
 483		"<ul>\n<li><p>Yin</p></li>\n\n<li><p>Yang</p></li>\n</ul>\n",
 484
 485		"- Ting\n\n- Bong\n- Goo\n",
 486		"<ul>\n<li><p>Ting</p></li>\n\n<li><p>Bong</p></li>\n\n<li><p>Goo</p></li>\n</ul>\n",
 487
 488		"*Hello\n",
 489		"<p>*Hello</p>\n",
 490
 491		"*   Hello \n",
 492		"<ul>\n<li>Hello</li>\n</ul>\n",
 493
 494		"*   Hello \n    Next line \n",
 495		"<ul>\n<li>Hello\nNext line</li>\n</ul>\n",
 496
 497		"Paragraph\n* No linebreak\n",
 498		"<p>Paragraph\n* No linebreak</p>\n",
 499
 500		"Paragraph\n\n* Linebreak\n",
 501		"<p>Paragraph</p>\n\n<ul>\n<li>Linebreak</li>\n</ul>\n",
 502
 503		"*   List\n    * Nested list\n",
 504		"<ul>\n<li>List\n\n<ul>\n<li>Nested list</li>\n</ul></li>\n</ul>\n",
 505
 506		"*   List\n\n    * Nested list\n",
 507		"<ul>\n<li><p>List</p>\n\n<ul>\n<li>Nested list</li>\n</ul></li>\n</ul>\n",
 508
 509		"*   List\n    Second line\n\n    + Nested\n",
 510		"<ul>\n<li><p>List\nSecond line</p>\n\n<ul>\n<li>Nested</li>\n</ul></li>\n</ul>\n",
 511
 512		"*   List\n    + Nested\n\n    Continued\n",
 513		"<ul>\n<li><p>List</p>\n\n<ul>\n<li>Nested</li>\n</ul>\n\n<p>Continued</p></li>\n</ul>\n",
 514
 515		"*   List\n   * shallow indent\n",
 516		"<ul>\n<li>List\n\n<ul>\n<li>shallow indent</li>\n</ul></li>\n</ul>\n",
 517
 518		"* List\n" +
 519			" * shallow indent\n" +
 520			"  * part of second list\n" +
 521			"   * still second\n" +
 522			"    * almost there\n" +
 523			"     * third level\n",
 524		"<ul>\n" +
 525			"<li>List\n\n" +
 526			"<ul>\n" +
 527			"<li>shallow indent</li>\n" +
 528			"<li>part of second list</li>\n" +
 529			"<li>still second</li>\n" +
 530			"<li>almost there\n\n" +
 531			"<ul>\n" +
 532			"<li>third level</li>\n" +
 533			"</ul></li>\n" +
 534			"</ul></li>\n" +
 535			"</ul>\n",
 536
 537		"* List\n        extra indent, same paragraph\n",
 538		"<ul>\n<li>List\n    extra indent, same paragraph</li>\n</ul>\n",
 539
 540		"* List\n\n        code block\n",
 541		"<ul>\n<li><p>List</p>\n\n<pre><code>code block\n</code></pre></li>\n</ul>\n",
 542
 543		"* List\n\n          code block with spaces\n",
 544		"<ul>\n<li><p>List</p>\n\n<pre><code>  code block with spaces\n</code></pre></li>\n</ul>\n",
 545
 546		"* List\n\n    * sublist\n\n    normal text\n\n    * another sublist\n",
 547		"<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",
 548	}
 549	doTestsBlock(t, tests, 0)
 550}
 551
 552func TestOrderedList(t *testing.T) {
 553	var tests = []string{
 554		"1. Hello\n",
 555		"<ol>\n<li>Hello</li>\n</ol>\n",
 556
 557		"1. Yin\n2. Yang\n",
 558		"<ol>\n<li>Yin</li>\n<li>Yang</li>\n</ol>\n",
 559
 560		"1. Ting\n2. Bong\n3. Goo\n",
 561		"<ol>\n<li>Ting</li>\n<li>Bong</li>\n<li>Goo</li>\n</ol>\n",
 562
 563		"1. Yin\n\n2. Yang\n",
 564		"<ol>\n<li><p>Yin</p></li>\n\n<li><p>Yang</p></li>\n</ol>\n",
 565
 566		"1. Ting\n\n2. Bong\n3. Goo\n",
 567		"<ol>\n<li><p>Ting</p></li>\n\n<li><p>Bong</p></li>\n\n<li><p>Goo</p></li>\n</ol>\n",
 568
 569		"1 Hello\n",
 570		"<p>1 Hello</p>\n",
 571
 572		"1.Hello\n",
 573		"<p>1.Hello</p>\n",
 574
 575		"1.  Hello \n",
 576		"<ol>\n<li>Hello</li>\n</ol>\n",
 577
 578		"1.  Hello \n    Next line \n",
 579		"<ol>\n<li>Hello\nNext line</li>\n</ol>\n",
 580
 581		"Paragraph\n1. No linebreak\n",
 582		"<p>Paragraph\n1. No linebreak</p>\n",
 583
 584		"Paragraph\n\n1. Linebreak\n",
 585		"<p>Paragraph</p>\n\n<ol>\n<li>Linebreak</li>\n</ol>\n",
 586
 587		"1.  List\n    1. Nested list\n",
 588		"<ol>\n<li>List\n\n<ol>\n<li>Nested list</li>\n</ol></li>\n</ol>\n",
 589
 590		"1.  List\n\n    1. Nested list\n",
 591		"<ol>\n<li><p>List</p>\n\n<ol>\n<li>Nested list</li>\n</ol></li>\n</ol>\n",
 592
 593		"1.  List\n    Second line\n\n    1. Nested\n",
 594		"<ol>\n<li><p>List\nSecond line</p>\n\n<ol>\n<li>Nested</li>\n</ol></li>\n</ol>\n",
 595
 596		"1.  List\n    1. Nested\n\n    Continued\n",
 597		"<ol>\n<li><p>List</p>\n\n<ol>\n<li>Nested</li>\n</ol>\n\n<p>Continued</p></li>\n</ol>\n",
 598
 599		"1.  List\n   1. shallow indent\n",
 600		"<ol>\n<li>List\n\n<ol>\n<li>shallow indent</li>\n</ol></li>\n</ol>\n",
 601
 602		"1. List\n" +
 603			" 1. shallow indent\n" +
 604			"  2. part of second list\n" +
 605			"   3. still second\n" +
 606			"    4. almost there\n" +
 607			"     1. third level\n",
 608		"<ol>\n" +
 609			"<li>List\n\n" +
 610			"<ol>\n" +
 611			"<li>shallow indent</li>\n" +
 612			"<li>part of second list</li>\n" +
 613			"<li>still second</li>\n" +
 614			"<li>almost there\n\n" +
 615			"<ol>\n" +
 616			"<li>third level</li>\n" +
 617			"</ol></li>\n" +
 618			"</ol></li>\n" +
 619			"</ol>\n",
 620
 621		"1. List\n        extra indent, same paragraph\n",
 622		"<ol>\n<li>List\n    extra indent, same paragraph</li>\n</ol>\n",
 623
 624		"1. List\n\n        code block\n",
 625		"<ol>\n<li><p>List</p>\n\n<pre><code>code block\n</code></pre></li>\n</ol>\n",
 626
 627		"1. List\n\n          code block with spaces\n",
 628		"<ol>\n<li><p>List</p>\n\n<pre><code>  code block with spaces\n</code></pre></li>\n</ol>\n",
 629
 630		"1. List\n    * Mixted list\n",
 631		"<ol>\n<li>List\n\n<ul>\n<li>Mixted list</li>\n</ul></li>\n</ol>\n",
 632
 633		"1. List\n * Mixed list\n",
 634		"<ol>\n<li>List\n\n<ul>\n<li>Mixed list</li>\n</ul></li>\n</ol>\n",
 635
 636		"* Start with unordered\n 1. Ordered\n",
 637		"<ul>\n<li>Start with unordered\n\n<ol>\n<li>Ordered</li>\n</ol></li>\n</ul>\n",
 638
 639		"* Start with unordered\n    1. Ordered\n",
 640		"<ul>\n<li>Start with unordered\n\n<ol>\n<li>Ordered</li>\n</ol></li>\n</ul>\n",
 641
 642		"1. numbers\n1. are ignored\n",
 643		"<ol>\n<li>numbers</li>\n<li>are ignored</li>\n</ol>\n",
 644	}
 645	doTestsBlock(t, tests, 0)
 646}
 647
 648func TestPreformattedHtml(t *testing.T) {
 649	var tests = []string{
 650		"<div></div>\n",
 651		"<div></div>\n",
 652
 653		"<div>\n</div>\n",
 654		"<div>\n</div>\n",
 655
 656		"<div>\n</div>\nParagraph\n",
 657		"<p><div>\n</div>\nParagraph</p>\n",
 658
 659		"<div class=\"foo\">\n</div>\n",
 660		"<div class=\"foo\">\n</div>\n",
 661
 662		"<div>\nAnything here\n</div>\n",
 663		"<div>\nAnything here\n</div>\n",
 664
 665		"<div>\n  Anything here\n</div>\n",
 666		"<div>\n  Anything here\n</div>\n",
 667
 668		"<div>\nAnything here\n  </div>\n",
 669		"<div>\nAnything here\n  </div>\n",
 670
 671		"<div>\nThis is *not* &proceessed\n</div>\n",
 672		"<div>\nThis is *not* &proceessed\n</div>\n",
 673
 674		"<faketag>\n  Something\n</faketag>\n",
 675		"<p><faketag>\n  Something\n</faketag></p>\n",
 676
 677		"<div>\n  Something here\n</divv>\n",
 678		"<p><div>\n  Something here\n</divv></p>\n",
 679
 680		"Paragraph\n<div>\nHere? >&<\n</div>\n",
 681		"<p>Paragraph\n<div>\nHere? &gt;&amp;&lt;\n</div></p>\n",
 682
 683		"Paragraph\n\n<div>\nHow about here? >&<\n</div>\n",
 684		"<p>Paragraph</p>\n\n<div>\nHow about here? >&<\n</div>\n",
 685
 686		"Paragraph\n<div>\nHere? >&<\n</div>\nAnd here?\n",
 687		"<p>Paragraph\n<div>\nHere? &gt;&amp;&lt;\n</div>\nAnd here?</p>\n",
 688
 689		"Paragraph\n\n<div>\nHow about here? >&<\n</div>\nAnd here?\n",
 690		"<p>Paragraph</p>\n\n<p><div>\nHow about here? &gt;&amp;&lt;\n</div>\nAnd here?</p>\n",
 691
 692		"Paragraph\n<div>\nHere? >&<\n</div>\n\nAnd here?\n",
 693		"<p>Paragraph\n<div>\nHere? &gt;&amp;&lt;\n</div></p>\n\n<p>And here?</p>\n",
 694
 695		"Paragraph\n\n<div>\nHow about here? >&<\n</div>\n\nAnd here?\n",
 696		"<p>Paragraph</p>\n\n<div>\nHow about here? >&<\n</div>\n\n<p>And here?</p>\n",
 697	}
 698	doTestsBlock(t, tests, 0)
 699}
 700
 701func TestPreformattedHtmlLax(t *testing.T) {
 702	var tests = []string{
 703		"Paragraph\n<div>\nHere? >&<\n</div>\n",
 704		"<p>Paragraph</p>\n\n<div>\nHere? >&<\n</div>\n",
 705
 706		"Paragraph\n\n<div>\nHow about here? >&<\n</div>\n",
 707		"<p>Paragraph</p>\n\n<div>\nHow about here? >&<\n</div>\n",
 708
 709		"Paragraph\n<div>\nHere? >&<\n</div>\nAnd here?\n",
 710		"<p>Paragraph</p>\n\n<div>\nHere? >&<\n</div>\n\n<p>And here?</p>\n",
 711
 712		"Paragraph\n\n<div>\nHow about here? >&<\n</div>\nAnd here?\n",
 713		"<p>Paragraph</p>\n\n<div>\nHow about here? >&<\n</div>\n\n<p>And here?</p>\n",
 714
 715		"Paragraph\n<div>\nHere? >&<\n</div>\n\nAnd here?\n",
 716		"<p>Paragraph</p>\n\n<div>\nHere? >&<\n</div>\n\n<p>And here?</p>\n",
 717
 718		"Paragraph\n\n<div>\nHow about here? >&<\n</div>\n\nAnd here?\n",
 719		"<p>Paragraph</p>\n\n<div>\nHow about here? >&<\n</div>\n\n<p>And here?</p>\n",
 720	}
 721	doTestsBlock(t, tests, EXTENSION_LAX_HTML_BLOCKS)
 722}
 723
 724func TestFencedCodeBlock(t *testing.T) {
 725	var tests = []string{
 726		"``` go\nfunc foo() bool {\n\treturn true;\n}\n```\n",
 727		"<pre><code class=\"language-go\">func foo() bool {\n\treturn true;\n}\n</code></pre>\n",
 728
 729		"``` c\n/* special & char < > \" escaping */\n```\n",
 730		"<pre><code class=\"language-c\">/* special &amp; char &lt; &gt; &quot; escaping */\n</code></pre>\n",
 731
 732		"``` c\nno *inline* processing ~~of text~~\n```\n",
 733		"<pre><code class=\"language-c\">no *inline* processing ~~of text~~\n</code></pre>\n",
 734
 735		"```\nNo language\n```\n",
 736		"<pre><code>No language\n</code></pre>\n",
 737
 738		"``` {ocaml}\nlanguage in braces\n```\n",
 739		"<pre><code class=\"language-ocaml\">language in braces\n</code></pre>\n",
 740
 741		"```    {ocaml}      \nwith extra whitespace\n```\n",
 742		"<pre><code class=\"language-ocaml\">with extra whitespace\n</code></pre>\n",
 743
 744		"```{   ocaml   }\nwith extra whitespace\n```\n",
 745		"<pre><code class=\"language-ocaml\">with extra whitespace\n</code></pre>\n",
 746
 747		"~ ~~ java\nWith whitespace\n~~~\n",
 748		"<p>~ ~~ java\nWith whitespace\n~~~</p>\n",
 749
 750		"~~\nonly two\n~~\n",
 751		"<p>~~\nonly two\n~~</p>\n",
 752
 753		"```` python\nextra\n````\n",
 754		"<pre><code class=\"language-python\">extra\n</code></pre>\n",
 755
 756		"~~~ perl\nthree to start, four to end\n~~~~\n",
 757		"<p>~~~ perl\nthree to start, four to end\n~~~~</p>\n",
 758
 759		"~~~~ perl\nfour to start, three to end\n~~~\n",
 760		"<p>~~~~ perl\nfour to start, three to end\n~~~</p>\n",
 761
 762		"~~~ bash\ntildes\n~~~\n",
 763		"<pre><code class=\"language-bash\">tildes\n</code></pre>\n",
 764
 765		"``` lisp\nno ending\n",
 766		"<p>``` lisp\nno ending</p>\n",
 767
 768		"~~~ lisp\nend with language\n~~~ lisp\n",
 769		"<p>~~~ lisp\nend with language\n~~~ lisp</p>\n",
 770
 771		"```\nmismatched begin and end\n~~~\n",
 772		"<p>```\nmismatched begin and end\n~~~</p>\n",
 773
 774		"~~~\nmismatched begin and end\n```\n",
 775		"<p>~~~\nmismatched begin and end\n```</p>\n",
 776
 777		"   ``` oz\nleading spaces\n```\n",
 778		"<pre><code class=\"language-oz\">leading spaces\n</code></pre>\n",
 779
 780		"  ``` oz\nleading spaces\n ```\n",
 781		"<pre><code class=\"language-oz\">leading spaces\n</code></pre>\n",
 782
 783		" ``` oz\nleading spaces\n  ```\n",
 784		"<pre><code class=\"language-oz\">leading spaces\n</code></pre>\n",
 785
 786		"``` oz\nleading spaces\n   ```\n",
 787		"<pre><code class=\"language-oz\">leading spaces\n</code></pre>\n",
 788
 789		"    ``` oz\nleading spaces\n    ```\n",
 790		"<pre><code>``` oz\n</code></pre>\n\n<p>leading spaces\n    ```</p>\n",
 791
 792		"Bla bla\n\n``` oz\ncode blocks breakup paragraphs\n```\n\nBla Bla\n",
 793		"<p>Bla bla</p>\n\n<pre><code class=\"language-oz\">code blocks breakup paragraphs\n</code></pre>\n\n<p>Bla Bla</p>\n",
 794
 795		"Some text before a fenced code block\n``` oz\ncode blocks breakup paragraphs\n```\nAnd some text after a fenced code block",
 796		"<p>Some text before a fenced code block</p>\n\n<pre><code class=\"language-oz\">code blocks breakup paragraphs\n</code></pre>\n\n<p>And some text after a fenced code block</p>\n",
 797
 798		"`",
 799		"<p>`</p>\n",
 800
 801		"Bla bla\n\n``` oz\ncode blocks breakup paragraphs\n```\n\nBla Bla\n\n``` oz\nmultiple code blocks work okay\n```\n\nBla Bla\n",
 802		"<p>Bla bla</p>\n\n<pre><code class=\"language-oz\">code blocks breakup paragraphs\n</code></pre>\n\n<p>Bla Bla</p>\n\n<pre><code class=\"language-oz\">multiple code blocks work okay\n</code></pre>\n\n<p>Bla Bla</p>\n",
 803
 804		"Some text before a fenced code block\n``` oz\ncode blocks breakup paragraphs\n```\nSome text in between\n``` oz\nmultiple code blocks work okay\n```\nAnd some text after a fenced code block",
 805		"<p>Some text before a fenced code block</p>\n\n<pre><code class=\"language-oz\">code blocks breakup paragraphs\n</code></pre>\n\n<p>Some text in between</p>\n\n<pre><code class=\"language-oz\">multiple code blocks work okay\n</code></pre>\n\n<p>And some text after a fenced code block</p>\n",
 806	}
 807	doTestsBlock(t, tests, EXTENSION_FENCED_CODE)
 808}
 809
 810func TestTable(t *testing.T) {
 811	var tests = []string{
 812		"a | b\n---|---\nc | d\n",
 813		"<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n</tr>\n</thead>\n\n" +
 814			"<tbody>\n<tr>\n<td>c</td>\n<td>d</td>\n</tr>\n</tbody>\n</table>\n",
 815
 816		"a | b\n---|--\nc | d\n",
 817		"<p>a | b\n---|--\nc | d</p>\n",
 818
 819		"|a|b|c|d|\n|----|----|----|---|\n|e|f|g|h|\n",
 820		"<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" +
 821			"<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",
 822
 823		"*a*|__b__|[c](C)|d\n---|---|---|---\ne|f|g|h\n",
 824		"<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" +
 825			"<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",
 826
 827		"a|b|c\n---|---|---\nd|e|f\ng|h\ni|j|k|l|m\nn|o|p\n",
 828		"<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n<th>c</th>\n</tr>\n</thead>\n\n" +
 829			"<tbody>\n<tr>\n<td>d</td>\n<td>e</td>\n<td>f</td>\n</tr>\n\n" +
 830			"<tr>\n<td>g</td>\n<td>h</td>\n<td></td>\n</tr>\n\n" +
 831			"<tr>\n<td>i</td>\n<td>j</td>\n<td>k</td>\n</tr>\n\n" +
 832			"<tr>\n<td>n</td>\n<td>o</td>\n<td>p</td>\n</tr>\n</tbody>\n</table>\n",
 833
 834		"a|b|c\n---|---|---\n*d*|__e__|f\n",
 835		"<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n<th>c</th>\n</tr>\n</thead>\n\n" +
 836			"<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",
 837
 838		"a|b|c|d\n:--|--:|:-:|---\ne|f|g|h\n",
 839		"<table>\n<thead>\n<tr>\n<th align=\"left\">a</th>\n<th align=\"right\">b</th>\n" +
 840			"<th align=\"center\">c</th>\n<th>d</th>\n</tr>\n</thead>\n\n" +
 841			"<tbody>\n<tr>\n<td align=\"left\">e</td>\n<td align=\"right\">f</td>\n" +
 842			"<td align=\"center\">g</td>\n<td>h</td>\n</tr>\n</tbody>\n</table>\n",
 843
 844		"a|b|c\n---|---|---\n",
 845		"<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",
 846
 847		"a| b|c | d | e\n---|---|---|---|---\nf| g|h | i |j\n",
 848		"<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" +
 849			"<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",
 850
 851		"a|b\\|c|d\n---|---|---\nf|g\\|h|i\n",
 852		"<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",
 853	}
 854	doTestsBlock(t, tests, EXTENSION_TABLES)
 855}
 856
 857func TestUnorderedListWith_EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK(t *testing.T) {
 858	var tests = []string{
 859		"* Hello\n",
 860		"<ul>\n<li>Hello</li>\n</ul>\n",
 861
 862		"* Yin\n* Yang\n",
 863		"<ul>\n<li>Yin</li>\n<li>Yang</li>\n</ul>\n",
 864
 865		"* Ting\n* Bong\n* Goo\n",
 866		"<ul>\n<li>Ting</li>\n<li>Bong</li>\n<li>Goo</li>\n</ul>\n",
 867
 868		"* Yin\n\n* Yang\n",
 869		"<ul>\n<li><p>Yin</p></li>\n\n<li><p>Yang</p></li>\n</ul>\n",
 870
 871		"* Ting\n\n* Bong\n* Goo\n",
 872		"<ul>\n<li><p>Ting</p></li>\n\n<li><p>Bong</p></li>\n\n<li><p>Goo</p></li>\n</ul>\n",
 873
 874		"+ Hello\n",
 875		"<ul>\n<li>Hello</li>\n</ul>\n",
 876
 877		"+ Yin\n+ Yang\n",
 878		"<ul>\n<li>Yin</li>\n<li>Yang</li>\n</ul>\n",
 879
 880		"+ Ting\n+ Bong\n+ Goo\n",
 881		"<ul>\n<li>Ting</li>\n<li>Bong</li>\n<li>Goo</li>\n</ul>\n",
 882
 883		"+ Yin\n\n+ Yang\n",
 884		"<ul>\n<li><p>Yin</p></li>\n\n<li><p>Yang</p></li>\n</ul>\n",
 885
 886		"+ Ting\n\n+ Bong\n+ Goo\n",
 887		"<ul>\n<li><p>Ting</p></li>\n\n<li><p>Bong</p></li>\n\n<li><p>Goo</p></li>\n</ul>\n",
 888
 889		"- Hello\n",
 890		"<ul>\n<li>Hello</li>\n</ul>\n",
 891
 892		"- Yin\n- Yang\n",
 893		"<ul>\n<li>Yin</li>\n<li>Yang</li>\n</ul>\n",
 894
 895		"- Ting\n- Bong\n- Goo\n",
 896		"<ul>\n<li>Ting</li>\n<li>Bong</li>\n<li>Goo</li>\n</ul>\n",
 897
 898		"- Yin\n\n- Yang\n",
 899		"<ul>\n<li><p>Yin</p></li>\n\n<li><p>Yang</p></li>\n</ul>\n",
 900
 901		"- Ting\n\n- Bong\n- Goo\n",
 902		"<ul>\n<li><p>Ting</p></li>\n\n<li><p>Bong</p></li>\n\n<li><p>Goo</p></li>\n</ul>\n",
 903
 904		"*Hello\n",
 905		"<p>*Hello</p>\n",
 906
 907		"*   Hello \n",
 908		"<ul>\n<li>Hello</li>\n</ul>\n",
 909
 910		"*   Hello \n    Next line \n",
 911		"<ul>\n<li>Hello\nNext line</li>\n</ul>\n",
 912
 913		"Paragraph\n* No linebreak\n",
 914		"<p>Paragraph</p>\n\n<ul>\n<li>No linebreak</li>\n</ul>\n",
 915
 916		"Paragraph\n\n* Linebreak\n",
 917		"<p>Paragraph</p>\n\n<ul>\n<li>Linebreak</li>\n</ul>\n",
 918
 919		"*   List\n    * Nested list\n",
 920		"<ul>\n<li>List\n\n<ul>\n<li>Nested list</li>\n</ul></li>\n</ul>\n",
 921
 922		"*   List\n\n    * Nested list\n",
 923		"<ul>\n<li><p>List</p>\n\n<ul>\n<li>Nested list</li>\n</ul></li>\n</ul>\n",
 924
 925		"*   List\n    Second line\n\n    + Nested\n",
 926		"<ul>\n<li><p>List\nSecond line</p>\n\n<ul>\n<li>Nested</li>\n</ul></li>\n</ul>\n",
 927
 928		"*   List\n    + Nested\n\n    Continued\n",
 929		"<ul>\n<li><p>List</p>\n\n<ul>\n<li>Nested</li>\n</ul>\n\n<p>Continued</p></li>\n</ul>\n",
 930
 931		"*   List\n   * shallow indent\n",
 932		"<ul>\n<li>List\n\n<ul>\n<li>shallow indent</li>\n</ul></li>\n</ul>\n",
 933
 934		"* List\n" +
 935			" * shallow indent\n" +
 936			"  * part of second list\n" +
 937			"   * still second\n" +
 938			"    * almost there\n" +
 939			"     * third level\n",
 940		"<ul>\n" +
 941			"<li>List\n\n" +
 942			"<ul>\n" +
 943			"<li>shallow indent</li>\n" +
 944			"<li>part of second list</li>\n" +
 945			"<li>still second</li>\n" +
 946			"<li>almost there\n\n" +
 947			"<ul>\n" +
 948			"<li>third level</li>\n" +
 949			"</ul></li>\n" +
 950			"</ul></li>\n" +
 951			"</ul>\n",
 952
 953		"* List\n        extra indent, same paragraph\n",
 954		"<ul>\n<li>List\n    extra indent, same paragraph</li>\n</ul>\n",
 955
 956		"* List\n\n        code block\n",
 957		"<ul>\n<li><p>List</p>\n\n<pre><code>code block\n</code></pre></li>\n</ul>\n",
 958
 959		"* List\n\n          code block with spaces\n",
 960		"<ul>\n<li><p>List</p>\n\n<pre><code>  code block with spaces\n</code></pre></li>\n</ul>\n",
 961
 962		"* List\n\n    * sublist\n\n    normal text\n\n    * another sublist\n",
 963		"<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",
 964	}
 965	doTestsBlock(t, tests, EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK)
 966}
 967
 968func TestOrderedList_EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK(t *testing.T) {
 969	var tests = []string{
 970		"1. Hello\n",
 971		"<ol>\n<li>Hello</li>\n</ol>\n",
 972
 973		"1. Yin\n2. Yang\n",
 974		"<ol>\n<li>Yin</li>\n<li>Yang</li>\n</ol>\n",
 975
 976		"1. Ting\n2. Bong\n3. Goo\n",
 977		"<ol>\n<li>Ting</li>\n<li>Bong</li>\n<li>Goo</li>\n</ol>\n",
 978
 979		"1. Yin\n\n2. Yang\n",
 980		"<ol>\n<li><p>Yin</p></li>\n\n<li><p>Yang</p></li>\n</ol>\n",
 981
 982		"1. Ting\n\n2. Bong\n3. Goo\n",
 983		"<ol>\n<li><p>Ting</p></li>\n\n<li><p>Bong</p></li>\n\n<li><p>Goo</p></li>\n</ol>\n",
 984
 985		"1 Hello\n",
 986		"<p>1 Hello</p>\n",
 987
 988		"1.Hello\n",
 989		"<p>1.Hello</p>\n",
 990
 991		"1.  Hello \n",
 992		"<ol>\n<li>Hello</li>\n</ol>\n",
 993
 994		"1.  Hello \n    Next line \n",
 995		"<ol>\n<li>Hello\nNext line</li>\n</ol>\n",
 996
 997		"Paragraph\n1. No linebreak\n",
 998		"<p>Paragraph</p>\n\n<ol>\n<li>No linebreak</li>\n</ol>\n",
 999
1000		"Paragraph\n\n1. Linebreak\n",
1001		"<p>Paragraph</p>\n\n<ol>\n<li>Linebreak</li>\n</ol>\n",
1002
1003		"1.  List\n    1. Nested list\n",
1004		"<ol>\n<li>List\n\n<ol>\n<li>Nested list</li>\n</ol></li>\n</ol>\n",
1005
1006		"1.  List\n\n    1. Nested list\n",
1007		"<ol>\n<li><p>List</p>\n\n<ol>\n<li>Nested list</li>\n</ol></li>\n</ol>\n",
1008
1009		"1.  List\n    Second line\n\n    1. Nested\n",
1010		"<ol>\n<li><p>List\nSecond line</p>\n\n<ol>\n<li>Nested</li>\n</ol></li>\n</ol>\n",
1011
1012		"1.  List\n    1. Nested\n\n    Continued\n",
1013		"<ol>\n<li><p>List</p>\n\n<ol>\n<li>Nested</li>\n</ol>\n\n<p>Continued</p></li>\n</ol>\n",
1014
1015		"1.  List\n   1. shallow indent\n",
1016		"<ol>\n<li>List\n\n<ol>\n<li>shallow indent</li>\n</ol></li>\n</ol>\n",
1017
1018		"1. List\n" +
1019			" 1. shallow indent\n" +
1020			"  2. part of second list\n" +
1021			"   3. still second\n" +
1022			"    4. almost there\n" +
1023			"     1. third level\n",
1024		"<ol>\n" +
1025			"<li>List\n\n" +
1026			"<ol>\n" +
1027			"<li>shallow indent</li>\n" +
1028			"<li>part of second list</li>\n" +
1029			"<li>still second</li>\n" +
1030			"<li>almost there\n\n" +
1031			"<ol>\n" +
1032			"<li>third level</li>\n" +
1033			"</ol></li>\n" +
1034			"</ol></li>\n" +
1035			"</ol>\n",
1036
1037		"1. List\n        extra indent, same paragraph\n",
1038		"<ol>\n<li>List\n    extra indent, same paragraph</li>\n</ol>\n",
1039
1040		"1. List\n\n        code block\n",
1041		"<ol>\n<li><p>List</p>\n\n<pre><code>code block\n</code></pre></li>\n</ol>\n",
1042
1043		"1. List\n\n          code block with spaces\n",
1044		"<ol>\n<li><p>List</p>\n\n<pre><code>  code block with spaces\n</code></pre></li>\n</ol>\n",
1045
1046		"1. List\n    * Mixted list\n",
1047		"<ol>\n<li>List\n\n<ul>\n<li>Mixted list</li>\n</ul></li>\n</ol>\n",
1048
1049		"1. List\n * Mixed list\n",
1050		"<ol>\n<li>List\n\n<ul>\n<li>Mixed list</li>\n</ul></li>\n</ol>\n",
1051
1052		"* Start with unordered\n 1. Ordered\n",
1053		"<ul>\n<li>Start with unordered\n\n<ol>\n<li>Ordered</li>\n</ol></li>\n</ul>\n",
1054
1055		"* Start with unordered\n    1. Ordered\n",
1056		"<ul>\n<li>Start with unordered\n\n<ol>\n<li>Ordered</li>\n</ol></li>\n</ul>\n",
1057
1058		"1. numbers\n1. are ignored\n",
1059		"<ol>\n<li>numbers</li>\n<li>are ignored</li>\n</ol>\n",
1060	}
1061	doTestsBlock(t, tests, EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK)
1062}
1063
1064func TestFencedCodeBlock_EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK(t *testing.T) {
1065	var tests = []string{
1066		"``` go\nfunc foo() bool {\n\treturn true;\n}\n```\n",
1067		"<pre><code class=\"language-go\">func foo() bool {\n\treturn true;\n}\n</code></pre>\n",
1068
1069		"``` c\n/* special & char < > \" escaping */\n```\n",
1070		"<pre><code class=\"language-c\">/* special &amp; char &lt; &gt; &quot; escaping */\n</code></pre>\n",
1071
1072		"``` c\nno *inline* processing ~~of text~~\n```\n",
1073		"<pre><code class=\"language-c\">no *inline* processing ~~of text~~\n</code></pre>\n",
1074
1075		"```\nNo language\n```\n",
1076		"<pre><code>No language\n</code></pre>\n",
1077
1078		"``` {ocaml}\nlanguage in braces\n```\n",
1079		"<pre><code class=\"language-ocaml\">language in braces\n</code></pre>\n",
1080
1081		"```    {ocaml}      \nwith extra whitespace\n```\n",
1082		"<pre><code class=\"language-ocaml\">with extra whitespace\n</code></pre>\n",
1083
1084		"```{   ocaml   }\nwith extra whitespace\n```\n",
1085		"<pre><code class=\"language-ocaml\">with extra whitespace\n</code></pre>\n",
1086
1087		"~ ~~ java\nWith whitespace\n~~~\n",
1088		"<p>~ ~~ java\nWith whitespace\n~~~</p>\n",
1089
1090		"~~\nonly two\n~~\n",
1091		"<p>~~\nonly two\n~~</p>\n",
1092
1093		"```` python\nextra\n````\n",
1094		"<pre><code class=\"language-python\">extra\n</code></pre>\n",
1095
1096		"~~~ perl\nthree to start, four to end\n~~~~\n",
1097		"<p>~~~ perl\nthree to start, four to end\n~~~~</p>\n",
1098
1099		"~~~~ perl\nfour to start, three to end\n~~~\n",
1100		"<p>~~~~ perl\nfour to start, three to end\n~~~</p>\n",
1101
1102		"~~~ bash\ntildes\n~~~\n",
1103		"<pre><code class=\"language-bash\">tildes\n</code></pre>\n",
1104
1105		"``` lisp\nno ending\n",
1106		"<p>``` lisp\nno ending</p>\n",
1107
1108		"~~~ lisp\nend with language\n~~~ lisp\n",
1109		"<p>~~~ lisp\nend with language\n~~~ lisp</p>\n",
1110
1111		"```\nmismatched begin and end\n~~~\n",
1112		"<p>```\nmismatched begin and end\n~~~</p>\n",
1113
1114		"~~~\nmismatched begin and end\n```\n",
1115		"<p>~~~\nmismatched begin and end\n```</p>\n",
1116
1117		"   ``` oz\nleading spaces\n```\n",
1118		"<pre><code class=\"language-oz\">leading spaces\n</code></pre>\n",
1119
1120		"  ``` oz\nleading spaces\n ```\n",
1121		"<pre><code class=\"language-oz\">leading spaces\n</code></pre>\n",
1122
1123		" ``` oz\nleading spaces\n  ```\n",
1124		"<pre><code class=\"language-oz\">leading spaces\n</code></pre>\n",
1125
1126		"``` oz\nleading spaces\n   ```\n",
1127		"<pre><code class=\"language-oz\">leading spaces\n</code></pre>\n",
1128
1129		"    ``` oz\nleading spaces\n    ```\n",
1130		"<pre><code>``` oz\n</code></pre>\n\n<p>leading spaces</p>\n\n<pre><code>```\n</code></pre>\n",
1131	}
1132	doTestsBlock(t, tests, EXTENSION_FENCED_CODE|EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK)
1133}
1134
1135func TestTitleBlock_EXTENSION_TITLEBLOCK(t *testing.T) {
1136	var tests = []string{
1137		"% Some title\n" +
1138			"% Another title line\n" +
1139			"% Yep, more here too\n",
1140		"<h1 class=\"title\">" +
1141			"Some title\n" +
1142			"Another title line\n" +
1143			"Yep, more here too\n" +
1144			"</h1>",
1145	}
1146
1147	doTestsBlock(t, tests, EXTENSION_TITLEBLOCK)
1148
1149}