X-Git-Url: https://git.plutz.net/?p=cgilite;a=blobdiff_plain;f=markdown.awk;h=361e6005c3fc42fa5e1f81859d69ec59d0c0a138;hp=7e29c572213e553df07563099cf52683ed11b960;hb=HEAD;hpb=fb015c84c44feea2ba863c89a6d4fc0f387144fd diff --git a/markdown.awk b/markdown.awk index 7e29c57..34879d2 100755 --- a/markdown.awk +++ b/markdown.awk @@ -158,18 +158,18 @@ function inline( line, LOCAL, len, text, code, href, guard ) { href = gensub(/^\[\[([^]|]+)(\|([^]]+))?\]\]/, "\\1", 1, substr(line, 1, len) ); text = gensub(/^\[\[([^]|]+)(\|([^]]+))?\]\]/, "\\3", 1, substr(line, 1, len) ); if ( ! text ) text = href; - return "" HTML(text) "" inline( substr( line, len + 1) ); + return "" HTML(text) "" inline( substr( line, len + 1) ); # quick links ("automatic links" in md doc) } else if ( match( line, /^<[a-zA-Z]+:\/\/([-\.[:alnum:]]+)(:[0-9]*)?(\/[^>]*)?>/ ) ) { len = RLENGTH; - href = URL( substr( line, 2, len - 2) ); + href = HTML( substr( line, 2, len - 2) ); return "" href "" inline( substr( line, len + 1) ); # quick link email } else if ( match( line, /^<[a-zA-Z0-9.!#$%&'\''*+\/=?^_`{|}~-]+@[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*>/ ) ) { len = RLENGTH; - href = URL( substr( line, 2, len - 2) ); + href = HTML( substr( line, 2, len - 2) ); return "" href "" inline( substr( line, len + 1) ); # Verbatim inline HTML @@ -192,7 +192,7 @@ function inline( line, LOCAL, len, text, code, href, guard ) { gsub(/\\/, "", href); gsub(/\\/, "", title); gsub(/[\n\t]+/, " ", title); - return "" \ + return "" \ inline( text ) "" inline( substr( line, len + 1) ); # reference style links @@ -202,9 +202,9 @@ function inline( line, LOCAL, len, text, code, href, guard ) { id = gensub(/^\[([^\n]+)\] ?\[([^\n]*)\].*/, "\\2", 1, substr(line, 1, len) ); if ( ! id ) id = text; if ( rl_href[id] && rl_title[id] ) { - return "" inline(text) "" inline( substr( line, len + 1) ); + return "" inline(text) "" inline( substr( line, len + 1) ); } else if ( rl_href[id] ) { - return "" inline(text) "" inline( substr( line, len + 1) ); + return "" inline(text) "" inline( substr( line, len + 1) ); } else { return "" HTML(substr(line, 1, len)) inline( substr(line, len + 1) ); } @@ -234,7 +234,7 @@ function inline( line, LOCAL, len, text, code, href, guard ) { gsub(/^[\t ]+$/, "", text); gsub(/\\/, "", href); gsub(/\\/, "", title); gsub(/[\n\t]+/, " ", title); - return "\""" inline( substr( line, len + 1) ); @@ -245,10 +245,10 @@ function inline( line, LOCAL, len, text, code, href, guard ) { id = gensub(/^!\[([^\n]*)\] ?\[([^\n]*)\].*/, "\\2", 1, substr(line, 1, len) ); if ( ! id ) id = text; if ( rl_href[id] && rl_title[id] ) { - return "\""" \ + return "\""" \ inline( substr( line, len + 1) ); } else if ( rl_href[id] ) { - return "\""" \ + return "\""" \ inline( substr( line, len + 1) ); } else { return "" HTML(substr(line, 1, len)) inline( substr(line, len + 1) ); @@ -391,7 +391,7 @@ function _block( block, LOCAL, st, len, text, title, attrib, href, guard, code, # Metadata (custom, block starting with %something) # Metadata is ignored but can be interpreted externally - } else if ( match(block, /^%[a-zA-Z]+([[:space:]][^\n]*)?(\n|$)(%[a-zA-Z]+([[:space:]][^\n]*)?(\n|$)|%([[:space:]][^\n]*)?(\n|$)|[ \t]+[^\n[:space:]][^\n]*(\n|$))*/) ) { + } else if ( match(block, /^%[a-zA-Z-]+([[:space:]][^\n]*)?(\n|$)(%[a-zA-Z-]+([[:space:]][^\n]*)?(\n|$)|%([[:space:]][^\n]*)?(\n|$)|[ \t]+[^\n[:space:]][^\n]*(\n|$))*/) ) { len = RLENGTH; st = RSTART; return _block( substr( block, len + 1) ); @@ -663,8 +663,8 @@ function _block( block, LOCAL, st, len, text, title, attrib, href, guard, code, gsub(/^[\t ]+$/, "", text); gsub(/\\/, "", href); - return "
" \ - "\""" \ + "\""" \ (title?"
" inline(title) "
":"") \ "
\n\n" \ @@ -677,14 +677,14 @@ function _block( block, LOCAL, st, len, text, title, attrib, href, guard, code, id = gensub(/^!\[([^\n]*)\] ?\[([^\n]*)\](\n.*)?$/, "\\2", 1, block); if ( ! id ) id = text; if ( rl_href[id] && rl_title[id] ) { - return "
" \ - "\""" \ + return "
" \ + "\""" \ "
" inline(rl_title[id]) "
" \ "
\n\n" \ _block( substr( block, len + 1) ); } else if ( rl_href[id] ) { - return "
" \ - "\""" \ + return "
" \ + "\""" \ "
\n\n" \ _block( substr( block, len + 1) ); } else {