From 0b18fff8edf0d01c80af7f14dcfbc2315d7354b9 Mon Sep 17 00:00:00 2001 From: "Fletcher T. Penney" Date: Thu, 9 Feb 2017 13:48:18 -0500 Subject: [PATCH] ADDED: Support language specifier in fenced code blocks --- src/html.c | 14 + src/scanners.c | 743 +++++++++--------- src/scanners.re | 2 +- src/writer.c | 22 + src/writer.h | 2 + .../Advanced Fenced Code Blocks.html | 9 + .../Advanced Fenced Code Blocks.htmlc | 9 + .../Advanced Fenced Code Blocks.text | 12 + tests/MMD6Tests/Fenced Code Blocks.htmlc | 8 +- tests/MMD6Tests/Fenced Code Blocks.text | 8 +- 10 files changed, 450 insertions(+), 379 deletions(-) diff --git a/src/html.c b/src/html.c index c016fd9..29001e1 100644 --- a/src/html.c +++ b/src/html.c @@ -381,6 +381,20 @@ void mmd_export_token_html(DString * out, const char * source, token * t, size_t scratch->padded = 1; break; case BLOCK_CODE_FENCED: + pad(out, 2, scratch); + print("
child->child, source);
+			if (temp_char) {
+				printf(" class=\"%s\"", temp_char);
+				free(temp_char);
+			}
+
+			print(">");
+			mmd_export_token_tree_html_raw(out, source, t->child->next, t->start + offset, scratch);
+			print("
"); + scratch->padded = 0; + break; case BLOCK_CODE_INDENTED: pad(out, 2, scratch); print("
");
diff --git a/src/scanners.c b/src/scanners.c
index b32ff93..a798d1a 100644
--- a/src/scanners.c
+++ b/src/scanners.c
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.14.3 on Wed Feb  8 17:26:41 2017 */
+/* Generated by re2c 0.14.3 on Thu Feb  9 11:59:42 2017 */
 /**
 
 	MultiMarkdown 6 -- Lightweight markup processor to produce HTML, LaTeX, and more.
@@ -8297,9 +8297,9 @@ yy583:
 yy584:
 	yych = *(marker = ++c);
 	switch (yych) {
-	case ' ':	goto yy597;
+	case ' ':	goto yy598;
 	case '`':
-	case '~':	goto yy598;
+	case '~':	goto yy599;
 	default:	goto yy583;
 	}
 yy585:
@@ -8331,59 +8331,62 @@ yy589:
 	case '\r':
 	case '\'':	goto yy588;
 	case '`':	goto yy589;
-	case '~':	goto yy592;
+	case '~':	goto yy593;
 	default:	goto yy591;
 	}
 yy591:
-	yych = *++c;
+	++c;
+	yych = *c;
 	switch (yych) {
 	case 0x00:
-	case '\n':	goto yy594;
-	case '\r':	goto yy596;
-	default:	goto yy588;
+	case '\n':	goto yy595;
+	case '\r':	goto yy597;
+	case '\'':
+	case '`':	goto yy588;
+	default:	goto yy591;
 	}
-yy592:
+yy593:
 	++c;
 	yych = *c;
 	switch (yych) {
 	case 0x00:
-	case '\n':	goto yy594;
-	case '\r':	goto yy596;
+	case '\n':	goto yy595;
+	case '\r':	goto yy597;
 	case '\'':	goto yy588;
 	case '`':	goto yy589;
-	case '~':	goto yy592;
+	case '~':	goto yy593;
 	default:	goto yy591;
 	}
-yy594:
-	++c;
 yy595:
-	{ return (size_t)( c - start ); }
+	++c;
 yy596:
+	{ return (size_t)( c - start ); }
+yy597:
 	yych = *++c;
 	switch (yych) {
-	case '\n':	goto yy594;
-	default:	goto yy595;
+	case '\n':	goto yy595;
+	default:	goto yy596;
 	}
-yy597:
+yy598:
 	yych = *++c;
 	switch (yych) {
-	case ' ':	goto yy599;
+	case ' ':	goto yy600;
 	case '`':
-	case '~':	goto yy598;
+	case '~':	goto yy599;
 	default:	goto yy588;
 	}
-yy598:
+yy599:
 	yych = *++c;
 	switch (yych) {
 	case '`':
 	case '~':	goto yy587;
 	default:	goto yy588;
 	}
-yy599:
+yy600:
 	++c;
 	switch ((yych = *c)) {
 	case '`':
-	case '~':	goto yy598;
+	case '~':	goto yy599;
 	default:	goto yy588;
 	}
 }
@@ -8400,97 +8403,97 @@ size_t scan_fence_end(const char * c) {
 	char yych;
 	yych = *c;
 	switch (yych) {
-	case '\n':	goto yy602;
-	case ' ':	goto yy603;
+	case '\n':	goto yy603;
+	case ' ':	goto yy604;
 	case '`':
-	case '~':	goto yy604;
-	default:	goto yy605;
+	case '~':	goto yy605;
+	default:	goto yy606;
 	}
-yy602:
-	{ return 0; }
 yy603:
+	{ return 0; }
+yy604:
 	yych = *(marker = ++c);
 	switch (yych) {
-	case ' ':	goto yy615;
+	case ' ':	goto yy616;
 	case '`':
-	case '~':	goto yy616;
-	default:	goto yy602;
+	case '~':	goto yy617;
+	default:	goto yy603;
 	}
-yy604:
+yy605:
 	yych = *(marker = ++c);
 	switch (yych) {
 	case '`':
-	case '~':	goto yy606;
-	default:	goto yy602;
+	case '~':	goto yy607;
+	default:	goto yy603;
 	}
-yy605:
-	yych = *++c;
-	goto yy602;
 yy606:
+	yych = *++c;
+	goto yy603;
+yy607:
 	yych = *++c;
 	switch (yych) {
 	case '`':
-	case '~':	goto yy608;
-	default:	goto yy607;
+	case '~':	goto yy609;
+	default:	goto yy608;
 	}
-yy607:
-	c = marker;
-	goto yy602;
 yy608:
+	c = marker;
+	goto yy603;
+yy609:
 	++c;
 	yych = *c;
 	switch (yych) {
 	case 0x00:
-	case '\n':	goto yy612;
+	case '\n':	goto yy613;
 	case '\t':
-	case ' ':	goto yy610;
-	case '\r':	goto yy614;
+	case ' ':	goto yy611;
+	case '\r':	goto yy615;
 	case '`':
-	case '~':	goto yy608;
-	default:	goto yy607;
+	case '~':	goto yy609;
+	default:	goto yy608;
 	}
-yy610:
+yy611:
 	++c;
 	yych = *c;
 	switch (yych) {
 	case 0x00:
-	case '\n':	goto yy612;
+	case '\n':	goto yy613;
 	case '\t':
-	case ' ':	goto yy610;
-	case '\r':	goto yy614;
-	default:	goto yy607;
+	case ' ':	goto yy611;
+	case '\r':	goto yy615;
+	default:	goto yy608;
 	}
-yy612:
-	++c;
 yy613:
-	{ return (size_t)( c - start ); }
+	++c;
 yy614:
+	{ return (size_t)( c - start ); }
+yy615:
 	yych = *++c;
 	switch (yych) {
-	case '\n':	goto yy612;
-	default:	goto yy613;
+	case '\n':	goto yy613;
+	default:	goto yy614;
 	}
-yy615:
+yy616:
 	yych = *++c;
 	switch (yych) {
-	case ' ':	goto yy617;
+	case ' ':	goto yy618;
 	case '`':
-	case '~':	goto yy616;
-	default:	goto yy607;
+	case '~':	goto yy617;
+	default:	goto yy608;
 	}
-yy616:
+yy617:
 	yych = *++c;
 	switch (yych) {
 	case '`':
-	case '~':	goto yy606;
-	default:	goto yy607;
+	case '~':	goto yy607;
+	default:	goto yy608;
 	}
-yy617:
+yy618:
 	++c;
 	switch ((yych = *c)) {
 	case '`':
-	case '~':	goto yy616;
-	default:	goto yy607;
+	case '~':	goto yy617;
+	default:	goto yy608;
 	}
 }
 	
@@ -8506,7 +8509,7 @@ size_t scan_meta_line(const char * c) {
 	char yych;
 	yych = *c;
 	switch (yych) {
-	case '\n':	goto yy620;
+	case '\n':	goto yy621;
 	case '0':
 	case '1':
 	case '2':
@@ -8568,15 +8571,15 @@ size_t scan_meta_line(const char * c) {
 	case 'w':
 	case 'x':
 	case 'y':
-	case 'z':	goto yy621;
-	default:	goto yy622;
+	case 'z':	goto yy622;
+	default:	goto yy623;
 	}
-yy620:
-	{ return 0; }
 yy621:
+	{ return 0; }
+yy622:
 	yych = *(marker = ++c);
 	switch (yych) {
-	case '\t':	goto yy626;
+	case '\t':	goto yy627;
 	case ' ':
 	case '!':
 	case '"':
@@ -8654,18 +8657,18 @@ yy621:
 	case 'w':
 	case 'x':
 	case 'y':
-	case 'z':	goto yy623;
-	case ':':	goto yy628;
-	default:	goto yy620;
+	case 'z':	goto yy624;
+	case ':':	goto yy629;
+	default:	goto yy621;
 	}
-yy622:
-	yych = *++c;
-	goto yy620;
 yy623:
+	yych = *++c;
+	goto yy621;
+yy624:
 	++c;
 	yych = *c;
 	switch (yych) {
-	case '\t':	goto yy626;
+	case '\t':	goto yy627;
 	case ' ':
 	case '!':
 	case '"':
@@ -8743,48 +8746,48 @@ yy623:
 	case 'w':
 	case 'x':
 	case 'y':
-	case 'z':	goto yy623;
-	case ':':	goto yy628;
-	default:	goto yy625;
+	case 'z':	goto yy624;
+	case ':':	goto yy629;
+	default:	goto yy626;
 	}
-yy625:
-	c = marker;
-	goto yy620;
 yy626:
+	c = marker;
+	goto yy621;
+yy627:
 	++c;
 	yych = *c;
 	switch (yych) {
 	case '\t':
-	case ' ':	goto yy626;
-	case ':':	goto yy628;
-	default:	goto yy625;
+	case ' ':	goto yy627;
+	case ':':	goto yy629;
+	default:	goto yy626;
 	}
-yy628:
+yy629:
 	yych = *++c;
 	switch (yych) {
 	case 0x00:
 	case '\n':
-	case '\r':	goto yy625;
-	default:	goto yy629;
+	case '\r':	goto yy626;
+	default:	goto yy630;
 	}
-yy629:
+yy630:
 	++c;
 	yych = *c;
 	switch (yych) {
 	case 0x00:
-	case '\n':	goto yy631;
-	case '\r':	goto yy633;
-	default:	goto yy629;
+	case '\n':	goto yy632;
+	case '\r':	goto yy634;
+	default:	goto yy630;
 	}
-yy631:
-	++c;
 yy632:
-	{ return (size_t)( c - start ); }
+	++c;
 yy633:
+	{ return (size_t)( c - start ); }
+yy634:
 	++c;
 	switch ((yych = *c)) {
-	case '\n':	goto yy631;
-	default:	goto yy632;
+	case '\n':	goto yy632;
+	default:	goto yy633;
 	}
 }
 	
@@ -8800,7 +8803,7 @@ size_t scan_meta_key(const char * c) {
 	char yych;
 	yych = *c;
 	switch (yych) {
-	case '\n':	goto yy636;
+	case '\n':	goto yy637;
 	case '0':
 	case '1':
 	case '2':
@@ -8862,24 +8865,24 @@ size_t scan_meta_key(const char * c) {
 	case 'w':
 	case 'x':
 	case 'y':
-	case 'z':	goto yy637;
-	default:	goto yy639;
+	case 'z':	goto yy638;
+	default:	goto yy640;
 	}
-yy636:
-	{ return 0; }
 yy637:
+	{ return 0; }
+yy638:
 	++c;
 	yych = *c;
-	goto yy641;
-yy638:
-	{ return (size_t)( c - start ); }
+	goto yy642;
 yy639:
-	yych = *++c;
-	goto yy636;
+	{ return (size_t)( c - start ); }
 yy640:
+	yych = *++c;
+	goto yy637;
+yy641:
 	++c;
 	yych = *c;
-yy641:
+yy642:
 	switch (yych) {
 	case ' ':
 	case '!':
@@ -8958,8 +8961,8 @@ yy641:
 	case 'w':
 	case 'x':
 	case 'y':
-	case 'z':	goto yy640;
-	default:	goto yy638;
+	case 'z':	goto yy641;
+	default:	goto yy639;
 	}
 }
 	
@@ -8975,71 +8978,71 @@ size_t scan_definition(const char * c) {
 	char yych;
 	yych = *c;
 	switch (yych) {
-	case '\n':	goto yy644;
-	case ' ':	goto yy645;
-	case ':':	goto yy646;
-	default:	goto yy647;
+	case '\n':	goto yy645;
+	case ' ':	goto yy646;
+	case ':':	goto yy647;
+	default:	goto yy648;
 	}
-yy644:
-	{ return 0; }
 yy645:
+	{ return 0; }
+yy646:
 	yych = *(marker = ++c);
 	switch (yych) {
-	case ' ':	goto yy652;
-	case ':':	goto yy654;
-	default:	goto yy644;
+	case ' ':	goto yy653;
+	case ':':	goto yy655;
+	default:	goto yy645;
 	}
-yy646:
+yy647:
 	yych = *++c;
 	switch (yych) {
 	case 0x00:
 	case '\n':
-	case '\r':	goto yy644;
-	default:	goto yy649;
+	case '\r':	goto yy645;
+	default:	goto yy650;
 	}
-yy647:
-	yych = *++c;
-	goto yy644;
 yy648:
+	yych = *++c;
+	goto yy645;
+yy649:
 	++c;
 	yych = *c;
-yy649:
+yy650:
 	switch (yych) {
 	case 0x00:
 	case '\n':
-	case '\r':	goto yy650;
+	case '\r':	goto yy651;
 	case '\t':
-	case ' ':	goto yy648;
-	default:	goto yy651;
+	case ' ':	goto yy649;
+	default:	goto yy652;
 	}
-yy650:
-	{ return (size_t)( c - start ); }
 yy651:
-	yych = *++c;
-	goto yy650;
+	{ return (size_t)( c - start ); }
 yy652:
+	yych = *++c;
+	goto yy651;
+yy653:
 	yych = *++c;
 	switch (yych) {
-	case ' ':	goto yy655;
-	case ':':	goto yy654;
-	default:	goto yy653;
+	case ' ':	goto yy656;
+	case ':':	goto yy655;
+	default:	goto yy654;
 	}
-yy653:
-	c = marker;
-	goto yy644;
 yy654:
+	c = marker;
+	goto yy645;
+yy655:
 	yych = *++c;
 	switch (yych) {
 	case 0x00:
 	case '\n':
-	case '\r':	goto yy653;
-	default:	goto yy649;
+	case '\r':	goto yy654;
+	default:	goto yy650;
 	}
-yy655:
+yy656:
 	++c;
 	switch ((yych = *c)) {
-	case ':':	goto yy654;
-	default:	goto yy653;
+	case ':':	goto yy655;
+	default:	goto yy654;
 	}
 }
 	
@@ -9060,14 +9063,14 @@ size_t scan_table_separator(const char * c) {
 	case '+':
 	case '-':
 	case ':':
-	case '=':	goto yy660;
-	case '\n':	goto yy658;
-	case '|':	goto yy659;
-	default:	goto yy661;
+	case '=':	goto yy661;
+	case '\n':	goto yy659;
+	case '|':	goto yy660;
+	default:	goto yy662;
 	}
-yy658:
-	{ return 0; }
 yy659:
+	{ return 0; }
+yy660:
 	yych = *(marker = ++c);
 	switch (yych) {
 	case 0x00:
@@ -9079,10 +9082,10 @@ yy659:
 	case '-':
 	case ':':
 	case '=':
-	case '|':	goto yy671;
-	default:	goto yy658;
+	case '|':	goto yy672;
+	default:	goto yy659;
 	}
-yy660:
+yy661:
 	yych = *(marker = ++c);
 	switch (yych) {
 	case '\t':
@@ -9090,33 +9093,33 @@ yy660:
 	case '+':
 	case '-':
 	case ':':
-	case '=':	goto yy665;
-	case '|':	goto yy662;
-	default:	goto yy658;
+	case '=':	goto yy666;
+	case '|':	goto yy663;
+	default:	goto yy659;
 	}
-yy661:
-	yych = *++c;
-	goto yy658;
 yy662:
+	yych = *++c;
+	goto yy659;
+yy663:
 	++c;
 	yych = *c;
 	switch (yych) {
 	case 0x00:
-	case '\n':	goto yy667;
+	case '\n':	goto yy668;
 	case '\t':
 	case ' ':
 	case '+':
 	case '-':
 	case ':':
 	case '=':
-	case '|':	goto yy662;
-	case '\r':	goto yy669;
-	default:	goto yy664;
+	case '|':	goto yy663;
+	case '\r':	goto yy670;
+	default:	goto yy665;
 	}
-yy664:
-	c = marker;
-	goto yy658;
 yy665:
+	c = marker;
+	goto yy659;
+yy666:
 	++c;
 	yych = *c;
 	switch (yych) {
@@ -9125,36 +9128,36 @@ yy665:
 	case '+':
 	case '-':
 	case ':':
-	case '=':	goto yy665;
-	case '|':	goto yy662;
-	default:	goto yy664;
+	case '=':	goto yy666;
+	case '|':	goto yy663;
+	default:	goto yy665;
 	}
-yy667:
-	++c;
 yy668:
-	{ return (size_t)( c - start ); }
+	++c;
 yy669:
+	{ return (size_t)( c - start ); }
+yy670:
 	yych = *++c;
 	switch (yych) {
-	case '\n':	goto yy667;
-	default:	goto yy668;
+	case '\n':	goto yy668;
+	default:	goto yy669;
 	}
-yy670:
+yy671:
 	++c;
 	yych = *c;
-yy671:
+yy672:
 	switch (yych) {
 	case 0x00:
-	case '\n':	goto yy667;
+	case '\n':	goto yy668;
 	case '\t':
 	case ' ':
 	case '+':
 	case '-':
 	case ':':
 	case '=':
-	case '|':	goto yy670;
-	case '\r':	goto yy669;
-	default:	goto yy664;
+	case '|':	goto yy671;
+	case '\r':	goto yy670;
+	default:	goto yy665;
 	}
 }
 	
@@ -9170,234 +9173,234 @@ size_t scan_alignment_string(const char * c) {
 	yych = *c;
 	switch (yych) {
 	case '\t':
-	case ' ':	goto yy675;
-	case '\n':	goto yy674;
+	case ' ':	goto yy676;
+	case '\n':	goto yy675;
 	case '-':
-	case '=':	goto yy677;
-	case ':':	goto yy676;
-	default:	goto yy678;
+	case '=':	goto yy678;
+	case ':':	goto yy677;
+	default:	goto yy679;
 	}
-yy674:
-	{ return 0; }
 yy675:
+	{ return 0; }
+yy676:
 	yych = *(marker = ++c);
 	switch (yych) {
 	case '\t':
-	case ' ':	goto yy717;
+	case ' ':	goto yy718;
 	case '-':
-	case '=':	goto yy681;
-	case ':':	goto yy716;
-	default:	goto yy674;
+	case '=':	goto yy682;
+	case ':':	goto yy717;
+	default:	goto yy675;
 	}
-yy676:
+yy677:
 	yych = *(marker = ++c);
 	switch (yych) {
 	case '-':
-	case '=':	goto yy693;
-	default:	goto yy674;
+	case '=':	goto yy694;
+	default:	goto yy675;
 	}
-yy677:
+yy678:
 	yych = *(marker = ++c);
 	switch (yych) {
 	case '-':
-	case '=':	goto yy681;
-	case ':':	goto yy679;
-	default:	goto yy674;
+	case '=':	goto yy682;
+	case ':':	goto yy680;
+	default:	goto yy675;
 	}
-yy678:
-	yych = *++c;
-	goto yy674;
 yy679:
+	yych = *++c;
+	goto yy675;
+yy680:
 	yych = *++c;
 	switch (yych) {
-	case '+':	goto yy688;
-	default:	goto yy684;
+	case '+':	goto yy689;
+	default:	goto yy685;
 	}
-yy680:
-	c = marker;
-	goto yy674;
 yy681:
+	c = marker;
+	goto yy675;
+yy682:
 	++c;
 	yych = *c;
 	switch (yych) {
 	case '-':
-	case '=':	goto yy681;
-	case ':':	goto yy679;
-	default:	goto yy680;
+	case '=':	goto yy682;
+	case ':':	goto yy680;
+	default:	goto yy681;
 	}
-yy683:
+yy684:
 	++c;
 	yych = *c;
-yy684:
+yy685:
 	switch (yych) {
 	case 0x00:
 	case '\n':
-	case '|':	goto yy685;
+	case '|':	goto yy686;
 	case '\t':
-	case ' ':	goto yy683;
-	case '\r':	goto yy687;
-	default:	goto yy680;
+	case ' ':	goto yy684;
+	case '\r':	goto yy688;
+	default:	goto yy681;
 	}
-yy685:
-	++c;
 yy686:
-	{ return ALIGN_RIGHT; }
+	++c;
 yy687:
+	{ return ALIGN_RIGHT; }
+yy688:
 	yych = *++c;
 	switch (yych) {
-	case '\n':	goto yy685;
-	default:	goto yy686;
+	case '\n':	goto yy686;
+	default:	goto yy687;
 	}
-yy688:
+yy689:
 	++c;
 	yych = *c;
 	switch (yych) {
 	case 0x00:
 	case '\n':
-	case '|':	goto yy690;
+	case '|':	goto yy691;
 	case '\t':
-	case ' ':	goto yy688;
-	case '\r':	goto yy692;
-	default:	goto yy680;
+	case ' ':	goto yy689;
+	case '\r':	goto yy693;
+	default:	goto yy681;
 	}
-yy690:
-	++c;
 yy691:
-	{ return ALIGN_WRAP | ALIGN_RIGHT; }
+	++c;
 yy692:
+	{ return ALIGN_WRAP | ALIGN_RIGHT; }
+yy693:
 	yych = *++c;
 	switch (yych) {
-	case '\n':	goto yy690;
-	default:	goto yy691;
+	case '\n':	goto yy691;
+	default:	goto yy692;
 	}
-yy693:
+yy694:
 	++c;
 	yych = *c;
 	switch (yych) {
 	case 0x00:
 	case '\n':
-	case '|':	goto yy697;
+	case '|':	goto yy698;
 	case '\t':
-	case ' ':	goto yy695;
-	case '\r':	goto yy699;
-	case '+':	goto yy701;
+	case ' ':	goto yy696;
+	case '\r':	goto yy700;
+	case '+':	goto yy702;
 	case '-':
-	case '=':	goto yy693;
-	case ':':	goto yy700;
-	default:	goto yy680;
+	case '=':	goto yy694;
+	case ':':	goto yy701;
+	default:	goto yy681;
 	}
-yy695:
+yy696:
 	++c;
 	yych = *c;
 	switch (yych) {
 	case 0x00:
 	case '\n':
-	case '|':	goto yy697;
+	case '|':	goto yy698;
 	case '\t':
-	case ' ':	goto yy695;
-	case '\r':	goto yy699;
-	default:	goto yy680;
+	case ' ':	goto yy696;
+	case '\r':	goto yy700;
+	default:	goto yy681;
 	}
-yy697:
-	++c;
 yy698:
-	{ return ALIGN_LEFT; }
+	++c;
 yy699:
+	{ return ALIGN_LEFT; }
+yy700:
 	yych = *++c;
 	switch (yych) {
-	case '\n':	goto yy697;
-	default:	goto yy698;
+	case '\n':	goto yy698;
+	default:	goto yy699;
 	}
-yy700:
+yy701:
 	yych = *++c;
 	switch (yych) {
-	case '+':	goto yy706;
-	default:	goto yy709;
+	case '+':	goto yy707;
+	default:	goto yy710;
 	}
-yy701:
+yy702:
 	++c;
 	yych = *c;
 	switch (yych) {
 	case 0x00:
 	case '\n':
-	case '|':	goto yy703;
+	case '|':	goto yy704;
 	case '\t':
-	case ' ':	goto yy701;
-	case '\r':	goto yy705;
-	default:	goto yy680;
+	case ' ':	goto yy702;
+	case '\r':	goto yy706;
+	default:	goto yy681;
 	}
-yy703:
-	++c;
 yy704:
-	{ return ALIGN_WRAP | ALIGN_LEFT; }
+	++c;
 yy705:
+	{ return ALIGN_WRAP | ALIGN_LEFT; }
+yy706:
 	yych = *++c;
 	switch (yych) {
-	case '\n':	goto yy703;
-	default:	goto yy704;
+	case '\n':	goto yy704;
+	default:	goto yy705;
 	}
-yy706:
+yy707:
 	++c;
 	yych = *c;
 	switch (yych) {
 	case 0x00:
 	case '\n':
-	case '|':	goto yy713;
+	case '|':	goto yy714;
 	case '\t':
-	case ' ':	goto yy706;
-	case '\r':	goto yy715;
-	default:	goto yy680;
+	case ' ':	goto yy707;
+	case '\r':	goto yy716;
+	default:	goto yy681;
 	}
-yy708:
+yy709:
 	++c;
 	yych = *c;
-yy709:
+yy710:
 	switch (yych) {
 	case 0x00:
 	case '\n':
-	case '|':	goto yy710;
+	case '|':	goto yy711;
 	case '\t':
-	case ' ':	goto yy708;
-	case '\r':	goto yy712;
-	default:	goto yy680;
+	case ' ':	goto yy709;
+	case '\r':	goto yy713;
+	default:	goto yy681;
 	}
-yy710:
-	++c;
 yy711:
-	{ return ALIGN_CENTER; }
+	++c;
 yy712:
+	{ return ALIGN_CENTER; }
+yy713:
 	yych = *++c;
 	switch (yych) {
-	case '\n':	goto yy710;
-	default:	goto yy711;
+	case '\n':	goto yy711;
+	default:	goto yy712;
 	}
-yy713:
-	++c;
 yy714:
-	{ return ALIGN_WRAP | ALIGN_CENTER; }
+	++c;
 yy715:
+	{ return ALIGN_WRAP | ALIGN_CENTER; }
+yy716:
 	yych = *++c;
 	switch (yych) {
-	case '\n':	goto yy713;
-	default:	goto yy714;
+	case '\n':	goto yy714;
+	default:	goto yy715;
 	}
-yy716:
+yy717:
 	yych = *++c;
 	switch (yych) {
 	case '-':
-	case '=':	goto yy693;
-	default:	goto yy680;
+	case '=':	goto yy694;
+	default:	goto yy681;
 	}
-yy717:
+yy718:
 	++c;
 	yych = *c;
 	switch (yych) {
 	case '\t':
-	case ' ':	goto yy717;
+	case ' ':	goto yy718;
 	case '-':
-	case '=':	goto yy681;
-	case ':':	goto yy716;
-	default:	goto yy680;
+	case '=':	goto yy682;
+	case ':':	goto yy717;
+	default:	goto yy681;
 	}
 }
 	
@@ -9416,49 +9419,49 @@ size_t scan_destination(const char * c) {
 	case 0x00:
 	case '\t':
 	case '\r':
-	case ' ':	goto yy725;
-	case '\n':	goto yy721;
-	case '<':	goto yy722;
-	default:	goto yy724;
+	case ' ':	goto yy726;
+	case '\n':	goto yy722;
+	case '<':	goto yy723;
+	default:	goto yy725;
 	}
-yy721:
-	{ return 0; }
 yy722:
+	{ return 0; }
+yy723:
 	++c;
 	yych = *c;
-	goto yy729;
-yy723:
-	{ return (size_t)( c - start ); }
+	goto yy730;
 yy724:
-	yych = *++c;
-	goto yy727;
+	{ return (size_t)( c - start ); }
 yy725:
 	yych = *++c;
-	goto yy721;
+	goto yy728;
 yy726:
+	yych = *++c;
+	goto yy722;
+yy727:
 	++c;
 	yych = *c;
-yy727:
+yy728:
 	switch (yych) {
 	case 0x00:
 	case '\t':
 	case '\n':
 	case '\r':
-	case ' ':	goto yy723;
-	default:	goto yy726;
+	case ' ':	goto yy724;
+	default:	goto yy727;
 	}
-yy728:
+yy729:
 	++c;
 	yych = *c;
-yy729:
+yy730:
 	switch (yych) {
 	case 0x00:
 	case '\t':
 	case '\n':
 	case '\r':
-	case ' ':	goto yy723;
-	case '>':	goto yy726;
-	default:	goto yy728;
+	case ' ':	goto yy724;
+	case '>':	goto yy727;
+	default:	goto yy729;
 	}
 }
 	
@@ -9474,106 +9477,106 @@ size_t scan_setext(const char * c) {
 	char yych;
 	yych = *c;
 	switch (yych) {
-	case '\n':	goto yy732;
-	case ' ':	goto yy733;
-	case '-':	goto yy735;
-	case '=':	goto yy734;
-	default:	goto yy736;
+	case '\n':	goto yy733;
+	case ' ':	goto yy734;
+	case '-':	goto yy736;
+	case '=':	goto yy735;
+	default:	goto yy737;
 	}
-yy732:
-	{ return 0; }
 yy733:
-	yych = *(marker = ++c);
-	switch (yych) {
-	case ' ':	goto yy748;
-	case '-':	goto yy749;
-	case '=':	goto yy750;
-	default:	goto yy732;
-	}
+	{ return 0; }
 yy734:
 	yych = *(marker = ++c);
 	switch (yych) {
-	case '=':	goto yy743;
-	default:	goto yy732;
+	case ' ':	goto yy749;
+	case '-':	goto yy750;
+	case '=':	goto yy751;
+	default:	goto yy733;
 	}
 yy735:
 	yych = *(marker = ++c);
 	switch (yych) {
-	case '-':	goto yy737;
-	default:	goto yy732;
+	case '=':	goto yy744;
+	default:	goto yy733;
 	}
 yy736:
-	yych = *++c;
-	goto yy732;
+	yych = *(marker = ++c);
+	switch (yych) {
+	case '-':	goto yy738;
+	default:	goto yy733;
+	}
 yy737:
+	yych = *++c;
+	goto yy733;
+yy738:
 	++c;
 	yych = *c;
 	switch (yych) {
 	case 0x00:
-	case '\n':	goto yy740;
-	case '\r':	goto yy742;
-	case '-':	goto yy737;
-	default:	goto yy739;
+	case '\n':	goto yy741;
+	case '\r':	goto yy743;
+	case '-':	goto yy738;
+	default:	goto yy740;
 	}
-yy739:
-	c = marker;
-	goto yy732;
 yy740:
-	++c;
+	c = marker;
+	goto yy733;
 yy741:
-	{ return (size_t)( c - start ); }
+	++c;
 yy742:
+	{ return (size_t)( c - start ); }
+yy743:
 	yych = *++c;
 	switch (yych) {
-	case '\n':	goto yy740;
-	default:	goto yy741;
+	case '\n':	goto yy741;
+	default:	goto yy742;
 	}
-yy743:
+yy744:
 	++c;
 	yych = *c;
 	switch (yych) {
 	case 0x00:
-	case '\n':	goto yy745;
-	case '\r':	goto yy747;
-	case '=':	goto yy743;
-	default:	goto yy739;
+	case '\n':	goto yy746;
+	case '\r':	goto yy748;
+	case '=':	goto yy744;
+	default:	goto yy740;
 	}
-yy745:
-	++c;
 yy746:
-	{ return (size_t)( c - start ); }
+	++c;
 yy747:
-	yych = *++c;
-	switch (yych) {
-	case '\n':	goto yy745;
-	default:	goto yy746;
-	}
+	{ return (size_t)( c - start ); }
 yy748:
 	yych = *++c;
 	switch (yych) {
-	case ' ':	goto yy751;
-	case '-':	goto yy749;
-	case '=':	goto yy750;
-	default:	goto yy739;
+	case '\n':	goto yy746;
+	default:	goto yy747;
 	}
 yy749:
 	yych = *++c;
 	switch (yych) {
-	case '-':	goto yy737;
-	default:	goto yy739;
+	case ' ':	goto yy752;
+	case '-':	goto yy750;
+	case '=':	goto yy751;
+	default:	goto yy740;
 	}
 yy750:
 	yych = *++c;
 	switch (yych) {
-	case '=':	goto yy743;
-	default:	goto yy739;
+	case '-':	goto yy738;
+	default:	goto yy740;
 	}
 yy751:
+	yych = *++c;
+	switch (yych) {
+	case '=':	goto yy744;
+	default:	goto yy740;
+	}
+yy752:
 	++c;
 	switch ((yych = *c)) {
-	case '-':	goto yy749;
-	case '=':	goto yy750;
-	default:	goto yy739;
+	case '-':	goto yy750;
+	case '=':	goto yy751;
+	default:	goto yy740;
 	}
 }
 	
diff --git a/src/scanners.re b/src/scanners.re
index e89366f..0f53f2f 100644
--- a/src/scanners.re
+++ b/src/scanners.re
@@ -128,7 +128,7 @@
 
 	html_block	= '<' '/'? block_tag attributes? '/'? '>';
 
-	fence_start	= non_indent [`~]{3,} [^`'\n\r\x00] nl_eof;
+	fence_start	= non_indent [`~]{3,} [^`'\n\r\x00]+ nl_eof;
 
 	fence_end	= non_indent [`~]{3,} sp nl_eof;
 
diff --git a/src/writer.c b/src/writer.c
index b53f8b4..432ccf6 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -1597,3 +1597,25 @@ bool table_has_caption(token * t) {
 	return false;
 }
 
+
+/// Grab the first "word" after the end of the fence marker:
+/// ````perl
+/// or
+/// ```` perl 
+char * get_fence_language_specifier(token * fence, const char * source) {
+	char * result = NULL;
+	size_t start = fence->start + fence->len;
+	size_t len = 0;
+
+	while (char_is_whitespace(source[start]))
+		start++;
+
+	while (!char_is_whitespace_or_line_ending(source[start + len]))
+		len++;
+
+	if (len)
+		result = strndup(&source[start], len);
+
+	return result;
+}
+
diff --git a/src/writer.h b/src/writer.h
index b47babe..faf8d7c 100644
--- a/src/writer.h
+++ b/src/writer.h
@@ -205,5 +205,7 @@ void strip_leading_whitespace(token * chain, const char * source);
 
 bool table_has_caption(token * table);
 
+char * get_fence_language_specifier(token * fence, const char * source);
+
 #endif
 
diff --git a/tests/MMD6Tests/Advanced Fenced Code Blocks.html b/tests/MMD6Tests/Advanced Fenced Code Blocks.html
index 77c0b4f..e56368d 100644
--- a/tests/MMD6Tests/Advanced Fenced Code Blocks.html	
+++ b/tests/MMD6Tests/Advanced Fenced Code Blocks.html	
@@ -36,3 +36,12 @@ foo *5*
 

10

+ +
foo
+
+ +
foo
+
+ +
foo
+
diff --git a/tests/MMD6Tests/Advanced Fenced Code Blocks.htmlc b/tests/MMD6Tests/Advanced Fenced Code Blocks.htmlc index 550fea0..33c2489 100644 --- a/tests/MMD6Tests/Advanced Fenced Code Blocks.htmlc +++ b/tests/MMD6Tests/Advanced Fenced Code Blocks.htmlc @@ -27,3 +27,12 @@ foo *6* `````

10

+ +

perl +foo

+ +

perl +foo

+ +

perl ruby +foo

diff --git a/tests/MMD6Tests/Advanced Fenced Code Blocks.text b/tests/MMD6Tests/Advanced Fenced Code Blocks.text index d8324ab..738df26 100644 --- a/tests/MMD6Tests/Advanced Fenced Code Blocks.text +++ b/tests/MMD6Tests/Advanced Fenced Code Blocks.text @@ -45,3 +45,15 @@ foo *6* `````` 10 + +```perl +foo +``` + +```` perl +foo +```` + +``` perl ruby +foo +``` diff --git a/tests/MMD6Tests/Fenced Code Blocks.htmlc b/tests/MMD6Tests/Fenced Code Blocks.htmlc index 6586e2a..822c3fd 100644 --- a/tests/MMD6Tests/Fenced Code Blocks.htmlc +++ b/tests/MMD6Tests/Fenced Code Blocks.htmlc @@ -1,10 +1,10 @@

*foo*

-

``` +

```` foo

bar -```

+````

``` diff --git a/tests/MMD6Tests/Fenced Code Blocks.text b/tests/MMD6Tests/Fenced Code Blocks.text index 8f074ce..a1a3822 100644 --- a/tests/MMD6Tests/Fenced Code Blocks.text +++ b/tests/MMD6Tests/Fenced Code Blocks.text @@ -2,11 +2,11 @@ *foo* ``` -``` +```` *foo* bar -``` +```` @@ -19,11 +19,11 @@ bar * foo - ``` + ```` *foo* bar - ``` + ```` ``` foo -- 2.40.0