Showing with 16 additions and 12 deletions.
  1. +16 −12 src/watt/text/markdown.volt
@@ -454,7 +454,7 @@ private struct Block {
string classTag;
}

private void parseBlocks(ref Block root, ref Line[] lines, IndentType[] base_indent, scope MarkdownSettings settings, size_t listSpaces=0)
private void parseBlocks(ref Block root, ref Line[] lines, IndentType[] base_indent, scope MarkdownSettings settings, bool list=false)
{
if( base_indent.length == 0 ) root.type = BlockType.Text;
else if( base_indent[$-1] == IndentType.Quote ) root.type = BlockType.Quote;
@@ -493,7 +493,11 @@ private void parseBlocks(ref Block root, ref Line[] lines, IndentType[] base_ind
}
skipEmptyBlockQuote = false;

if( ln.text.isCode(listSpaces) ) {
size_t l = base_indent.length >= 4 ? base_indent.length : cast(size_t)0;
if (list) {
l += 4;
}
if( ln.text.isCode(l) ) {
Block cblock;
Block qblock;
bool isQuote;
@@ -504,22 +508,22 @@ private void parseBlocks(ref Block root, ref Line[] lines, IndentType[] base_ind
cblock.type = BlockType.Code;
Line[] blanklines;
bool reContinue;
while( lines.length > 0 && (lines[0].text.isCode(listSpaces) || lines[0].type == LineType.Blank )) {
if (lines[0].indent.hasQuote() && lines[0].text.length >= listSpaces + 2) {
lines[0].text = lines[0].text[listSpaces + 2 .. $];
while( lines.length > 0 && (lines[0].text.isCode(l) || lines[0].type == LineType.Blank )) {
if (lines[0].indent.hasQuote() && lines[0].text.length >= l + 2) {
lines[0].text = lines[0].text[l + 2 .. $];
}
if (lines[0].type == LineType.Blank) {
blanklines ~= lines[0];
lines = lines[1 .. $];
continue;
}
foreach (bline; blanklines) {
cblock.text ~= bline.text.codeUnindent(listSpaces);
cblock.text ~= bline.text.codeUnindent(l);
}
blanklines = [];
cblock.text ~= lines[0].text.codeUnindent(listSpaces);
cblock.text ~= lines[0].text.codeUnindent(l);
lines = lines[1 .. $];
if (lines.length > 0 && (!lines[0].text.isCode(listSpaces) && lines[0].type != LineType.Blank)) {
if (lines.length > 0 && (!lines[0].text.isCode(l) && lines[0].type != LineType.Blank)) {
break;
}
if (lines.length > 0 && isQuote && !lines[0].text.startsWith("> ")) {
@@ -547,12 +551,12 @@ private void parseBlocks(ref Block root, ref Line[] lines, IndentType[] base_ind
return;

auto cindent = base_indent ~ [IndentType.White, IndentType.White, IndentType.White, IndentType.White];
if( ln.indent != cindent){
if( ln.indent != cindent || list){
Block subblock;
parseBlocks(ref subblock, ref lines, ln.indent[0 .. base_indent.length+1], settings, listSpaces);
parseBlocks(ref subblock, ref lines, ln.indent[0 .. base_indent.length+1], settings, list);
root.blocks ~= subblock;
continue;
} else if (!isCode(ln.text, listSpaces) ) {
} else if (!isCode(ln.text, base_indent.length) ) {
continue;
}
}
@@ -644,7 +648,7 @@ private void parseBlocks(ref Block root, ref Line[] lines, IndentType[] base_ind
}

size_t oldLength = itm.blocks.length;
parseBlocks(ref itm, ref lines, itemindent, settings, 4);
parseBlocks(ref itm, ref lines, itemindent, settings, true);
size_t newLength = itm.blocks.length;
if (newLength > oldLength) {
Block para;