diff --git a/markdown.awk b/markdown.awk index 293002f..73769ce 100755 --- a/markdown.awk +++ b/markdown.awk @@ -100,10 +100,10 @@ function parse_list(str, buf, result, i, ind, line, lines, indent, is_bullet) result = ""; buf = ""; - split(str, lines, "\n"); + num_lines = split(str, lines, "\n"); str = "" - for (i=1; i<=length(lines); i++) { + for (i=1; i<=num_lines; i++) { line = lines[i]; if (match(line, /^[[:space:]]*[-+*][[:space:]]/) || @@ -113,7 +113,7 @@ function parse_list(str, buf, result, i, ind, line, lines, indent, is_bullet) str = join_lines(rstrip(str), lstrip(line), " "); } - split(str, lines, "\n") + num_lines = split(str, lines, "\n") indent = match(str, /[^ ]/); is_bullet = match(str, /^[[:space:]]*[-+*][[:space:]]/) @@ -123,7 +123,7 @@ function parse_list(str, buf, result, i, ind, line, lines, indent, is_bullet) else result = "
    \n" - for (i=1; i<=length(lines); i++) { + for (i=1; i<=num_lines; i++) { line = lines[i]; if (match(line, "[^ ]") > indent) { @@ -367,10 +367,10 @@ function parse_line(str, result, end, i, c) { } function parse_blockquote(str, i, lines, line, buf, result) { - split(str, lines, "\n"); + num_lines = split(str, lines, "\n"); str = "" - for (i=1; i<=length(lines); i++) { + for (i=1; i<=num_lines; i++) { line = lines[i]; if (match(line, /^>/)) @@ -379,11 +379,11 @@ function parse_blockquote(str, i, lines, line, buf, result) { str = join_lines(rstrip(str), lstrip(line), " "); } - split(str, lines, "\n"); + num_lines = split(str, lines, "\n"); result = "
    "; buf = ""; - for (i=1; i<=length(lines); i++) { + for (i=1; i<=num_lines; i++) { line = lines[i]; gsub(/^> ?/, "", line); @@ -409,9 +409,9 @@ function parse_code(str, i, lines, result) { } if (match(str, /^ /)) { result = ""; - split(str, lines, "\n"); + num_lines = split(str, lines, "\n"); - for (i=1; i<=length(lines); i++) { + for (i=1; i<=num_lines; i++) { line = lines[i]; gsub(/^ /, "", line); result = result "\n" line; @@ -424,8 +424,8 @@ function parse_code(str, i, lines, result) { } function is_metadata(str, i, lines, line) { - split(str, lines, "\n"); - for (i=1; i<=length(lines); i++) { + num_lines = split(str, lines, "\n"); + for (i=1; i<=num_lines; i++) { line = lines[i]; if (! match(line, /^[^ ]+: .+$/)) @@ -444,13 +444,13 @@ function col_count(str, i, count) { } function is_table(str, i, lines, line) { - split(str, lines, "\n"); + num_lines = split(str, lines, "\n"); num_cols = col_count(lines[1]); if (!match(lines[2], /^([[:space:]]*\|[[:space:]]*-{3,}[[:space:]])*\|[[:space:]]*/)) { return 0; } - for (i=2; i<=length(lines); i++) { + for (i=2; i<=num_lines; i++) { line = lines[i]; if (col_count(line) != num_cols) @@ -461,7 +461,7 @@ function is_table(str, i, lines, line) { } function parse_table(str, num_cols, lines, line, cols, i, j) { - split(str, lines, "\n"); + num_lines = split(str, lines, "\n"); num_cols = col_count(lines[1]); split(lines[1], cols, "|"); @@ -471,7 +471,7 @@ function parse_table(str, num_cols, lines, line, cols, i, j) { } res = res "\n" - for (i=3; i<=length(lines); i++) { + for (i=3; i<=num_lines; i++) { line = lines[i]; split(line, cols, "|"); res=res "\n"; @@ -515,11 +515,11 @@ function parse_block(str) { } function parse_body(str, body, line, lines, result, i) { - split(str, lines, "\n"); + num_lines = split(str, lines, "\n"); result = ""; body = ""; - for (i=1; i<=length(lines); i++) { + for (i=1; i<=num_lines; i++) { line = lines[i]; if (line_continues(body, line)) { if (body != "")