diff --git a/markdown.awk b/markdown.awk index 260987b..0dad743 100644 --- a/markdown.awk +++ b/markdown.awk @@ -171,6 +171,25 @@ function escape_char(char) { return char; } +function extract_html_tag(str, i, sstr) { + sstr=substr(str, i, length(str) - i + 1); + + if (match(sstr, /^<\/[a-zA-Z][a-zA-Z0-9]*>/)) + return substr(str, i, RLENGTH) ; + + if (match(sstr, /^<[a-zA-Z][a-zA-Z0-9]*( *[a-zA-Z][a-zA-Z0-9]* *= *"[^"]*")* *>/)) + return substr(str, i, RLENGTH); + + return ""; +} + +function is_html_tag(str, i, sstr) { + if (extract_html_tag(str, i) == "") + return 0; + + return 1; +} + function parse_line(str, result, end, i) { #print "block '" str "'" result = "" @@ -204,6 +223,11 @@ function parse_line(str, result, end, i) { end = find(str, "`", i+1); } + else if (is_html_tag(str, i)) { + tag = extract_html_tag(str, i); + result = result tag; + i = i + length(tag) - 1; + } else { if (substr(str, i, 1) == "\n") { if (length(result) > 0) diff --git a/test.sh b/test.sh index ff45b32..97701ca 100755 --- a/test.sh +++ b/test.sh @@ -301,5 +301,11 @@ foo&bar

2 > 1

EOF +check <<-"EOF" +foo bar +--- +

foo bar

+EOF + echo echo "All tests passed"