First pass at fenced code blocks (delimited with ~~~'s, not

necessarily the same number at start and finish)
This commit is contained in:
david parsons
2011-07-20 17:59:47 -07:00
parent a6835ff673
commit 65035be7b7
+33
View File
@@ -635,6 +635,34 @@ codeblock(Paragraph *p)
}
static int
iscodefence(Line *r)
{
if ( !(r->flags & CHECKED) )
checkline(r);
return (r->kind == chk_tilde) && (r->count > 2);
}
static Line *
fencedcodeblock(Paragraph *p)
{
Line *r, *b=0, *ret;
for (r = p->text; r && !iscodefence(r); b = r, r = r->next )
;
ret = r ? r->next : 0;
if ( r ) ___mkd_freeLine(r);
if ( b ) b->next = 0;
else p->text = 0;
return ret;
}
static int
centered(Line *first, Line *last)
{
@@ -1180,6 +1208,11 @@ compile(Line *ptr, int toplevel, MMIOT *f)
ptr = codeblock(p);
}
else if ( iscodefence(ptr) ) {
p = Pp(&d, ptr->next, CODE);
___mkd_freeLine(ptr);
ptr = fencedcodeblock(p);
}
else if ( ishr(ptr) ) {
p = Pp(&d, 0, HR);
r = ptr;