Add simple handling of html tags
This commit is contained in:
parent
ebd74283ee
commit
a2a7d97cb1
2 changed files with 30 additions and 0 deletions
24
markdown.awk
24
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)
|
||||
|
|
6
test.sh
6
test.sh
|
@ -301,5 +301,11 @@ foo&bar
|
|||
<p>2 > 1</p>
|
||||
EOF
|
||||
|
||||
check <<-"EOF"
|
||||
foo <a href="" ></a> bar
|
||||
---
|
||||
<p>foo <a href="" ></a> bar</p>
|
||||
EOF
|
||||
|
||||
echo
|
||||
echo "All tests passed"
|
||||
|
|
Loading…
Reference in a new issue