+function _list (block, mark, p, LOCAL, len, st, text, indent, task) {
+ if ( match(block, "^([ \t]*\n)*$")) return;
+
+ match(block, "^" mark "[ \t]"); indent = RLENGTH;
+ sub("^" mark "[ \t]", "", block);
+
+ if (match(block, /\n[ \t]*\n/)) p = 1;
+
+ match( block, "\n" mark "[ \t][^\n]+(\n|$)" );
+ st = (RLENGTH == -1) ? length(block) + 1 : RSTART;
+ text = substr(block, 1, st); block = substr(block, st + 1);
+
+ gsub("\n {0," indent "}", "\n", text);
+
+ task = match( text, /^\[ \]/ ) ? "<li class=\"task pending\"><input type=checkbox disabled>" : \
+ match( text, /^\[-\]/ ) ? "<li class=\"task negative\"><input type=checkbox disabled>" : \
+ match( text, /^\[\/\]/ ) ? "<li class=\"task partial\"><input type=checkbox disabled>" : \
+ match( text, /^\[\?\]/ ) ? "<li class=\"task unsure\"><input type=checkbox disabled>" : \
+ match( text, /^\[[xX]\]/) ? "<li class=\"task done\"><input type=checkbox disabled checked>" : "<li>";
+ sub(/^\[[-? \/xX]\]/, "", text);
+
+ text = _nblock( text );
+ if ( ! p && match( text, "^<p>(</p[^>]|</[^p]|<[^/]|[^<])*</p>\n$" ))
+ gsub( "(^<p>|</p>\n$)", "", text);
+
+ return task text "</li>\n" _list(block, mark, p);
+}
+
+function _dlist (block, LOCAL, len, st, text, indent, p) {
+ if (match( block, "^([ \t]*\n)*[^:\n \t][^\n]+\n" )) {
+ len = RLENGTH; text = substr(block, 1, len);
+ gsub( "(^\n*|\n*$)", "", text );
+ return "<dt>" inline( text ) "</dt>\n" _dlist( substr(block, len + 1) );
+ } else if (match( block, "^([ \t]*\n)* ? ? ?:[ \t][^\n]+(\n|$)" \
+ "([^:\n \t][^\n]+(\n|$)" \
+ "|( ? ? ?\t| +)[^\n]+(\n|$)" \
+ "|([ \t]*\n)+( ? ? ?\t| +)[^\n]+(\n|$))*" \
+ )) {
+ len = RLENGTH; text = substr(block, 1, len);
+ sub( "^([ \t]*\n)*", "", text);
+ match(text, "^ ? ? ?:(\t| +)"); indent = RLENGTH;
+ sub( "^ ? ? ?:(\t| +)", "", text);
+ gsub( "(^|\n) {0," indent "}", "\n", text );
+
+ text = _nblock(text);
+ if (match( text, "^<p>(</p[^>]|</[^p]|<[^/]|[^<])*</p>\n$" ))
+ gsub( "(^<p>|</p>\n$)", "", text);
+
+ return "<dd>" text "</dd>\n" _dlist( substr(block, len + 1) );