ret = ret headline(2, text, 0) ; block = substr( block, len + 1);
continue;
- # Nth Order Heading H1 H2 H3 H4 H5 H6 + Attrib
- } else if ( match( block, /^(##?#?#?#?#?)[ \t]*(([^ \t\n]+|[ \t]+[^ \t\n#]|[ \t]+#+[ \t]*[^ \t\n#])+)[ \t]*#*([ \t]*\{([a-zA-Z \t-]*)\})(\n|$)/ ) ) {
+ # # Nth Order Heading H1 H2 H3 H4 H5 H6 + Attrib
+ # } else if ( match( block, /^(##?#?#?#?#?)[ \t]*(([^ \t\n]+|[ \t]+[^ \t\n#]|[ \t]+#+[ \t]*[^ \t\n#])+)[ \t]*#*[ \t]*\{[a-zA-Z \t-]*\}(\n|$)/ ) ) {
+ } else if ( match( block, /^##?#?#?#?#?[^#\n]([^\n#]|#[^\t\n# ]|#[\t ]+[^\t\n ])+#*[\t ]*\{[\ta-zA-Z -]*\}(\n|$)/ ) ) {
len = RLENGTH; text = attrib = substr(block, 1, len);
match(block, /^##?#?#?#?#?[^#]/); n = RLENGTH - 1;
-
# sub(/^(##?#?#?#?#?)[ \t]*/, "", text); # not working in mawk
text = substr(text, n + 1); sub(/^[ \t]*/, "", text);
sub(/[ \t]*#*([ \t]*\{([a-zA-Z \t-]*)\})(\n.*)?$/, "", text);
- sub(/^(##?#?#?#?#?)[ \t]*(([^ \t\n]+|[ \t]+[^ \t\n#]|[ \t]+#+[ \t]*[^ \t\n#])+)[ \t]*#*[ \t]*\{/, "", attrib);
+
+ sub(/^##?#?#?#?#?[^#\n]([^\n#]|#[^\t\n# ]|#[\t ]+[^\t\n ])+#*[\t ]*\{/, "", attrib);
sub(/\}(\n.*)?$/, "", attrib);
gsub(/[^a-zA-Z0-9_-]+/, " ", attrib); gsub(/(^ | $)/, "", attrib);
- ret = ret headline( n, text, attrib ) ; block = substr( block, len + 1);
+ ret = ret headline( n, text, attrib ); block = substr( block, len + 1);
continue;
# Nth Order Heading H1 H2 H3 H4 H5 H6
- } else if ( match( block, /^(##?#?#?#?#?)[ \t]*(([^ \t\n]+|[ \t]+[^ \t\n#]|[ \t]+#+[ \t]*[^ \t\n#])+)[ \t]*#*(\n|$)/ ) ) {
+ # } else if ( match( block, /^(##?#?#?#?#?)[ \t]*(([^ \t\n]+|[ \t]+[^ \t\n#]|[ \t]+#+[ \t]*[^ \t\n#])+)[ \t]*#*(\n|$)/ ) ) {
+ } else if ( match( block, /^##?#?#?#?#?[^#\n]([^\n#]|#[^\t\n# ]|#[\t ]+[^\t\n ])+#*(\n|$)/ ) ) {
len = RLENGTH; text = substr(block, 1, len);
match(block, /^##?#?#?#?#?[^#]/); n = RLENGTH - 1;
# sub(/^(##?#?#?#?#?)[ \t]+/, "", text); # not working in mawk
"|[^\n \t][^\n]+(\n|$))*" ) ) {
st = RSTART; len = RLENGTH; list = substr( block, st, len);
- sub("^\n", "", list); match(list, "^ ? ? ?"); indent = RLENGTH;
- it = ""; while ( indent > 0 ) { it = it " ?"; indent--; }
+ sub("^\n", "", list); match(list, "^( | | |)"); indent = RLENGTH;
# gsub( "(^|\n) {0," indent "}", "\n", list); sub("^\n", "", list);
- gsub( "(^|\n)" it, "\n", list); sub("^\n", "", list);
+ # emulate greedy range matcher for mawk
+ it = "("; while ( indent > 0 ) { for (k = indent; k > 0; k--) { it = it " "; } it = it "|"; indent--; }
+ sub(/\|$/, ")?", it); sub(/^\($/, "", it);
+ gsub( "(^|\n)" it, "\n", list ); sub("^\n", "", list);
text = substr(block, 1, st - 1); block = substr(block, st + len);
if (match(text, /\n[[:space:]]*\n/)) return 0;
if ( match(block, "^([ \t]*\n)*$")) return;
match(block, "^" mark "[ \t]"); indent = RLENGTH;
- it = ""; while ( indent > 0 ) { it = it " ?"; indent--; }
sub("^" mark "[ \t]", "", block);
text = substr(block, 1, st); block = substr(block, st + 1);
# gsub("\n {0," indent "}", "\n", text);
+ # emulate greedy range matcher for mawk
+ it = "("; while ( indent > 0 ) { for (k = indent; k > 0; k--) { it = it " "; } it = it "|"; indent--; }
+ sub(/\|$/, ")?", it); sub(/^\($/, "", it);
gsub("\n" it, "\n", text);
task = match( text, /^\[ \]/ ) ? "<li class=\"task pending\"><input type=checkbox disabled>" : \
len = RLENGTH; text = substr(block, 1, len);
sub( "^([ \t]*\n)*", "", text);
match(text, "^ ? ? ?:(\t| +)"); indent = RLENGTH;
- it = ""; while ( indent > 0 ) { it = it " ?"; indent--; }
sub( "^ ? ? ?:(\t| +)", "", text);
# gsub( "(^|\n) {0," indent "}", "\n", text );
+ # emulate greedy range matcher for mawk
+ it = "("; while ( indent > 0 ) { for (k = indent; k > 0; k--) { it = it " "; } it = it "|"; indent--; }
+ sub(/\|$/, ")?", it); sub(/^\($/, "", it);
gsub( "(^|\n)" it, "\n", text );
text = _nblock(text);