]> git.plutz.net Git - cgilite/blobdiff - markdown.awk
bugfix: do not accidentally strip white spaces from code spans
[cgilite] / markdown.awk
index 7d7e0a5f56d5e70b7e0be4d1d104164a5718b13b..3fa248d25f2877fdc0e6f7eab9a5642635407d75 100755 (executable)
@@ -93,6 +93,7 @@ function URL ( text ) {
   gsub( /&/,  "%26",  text );
   gsub( /"/,  "%22", text );
   gsub( /'/,  "%27", text );
+  gsub( /`/,  "%60", text );
   gsub( /\?/,  "%3F", text );
   gsub( /#/,  "%23", text );
   gsub( /\[/,  "%5B", text );
@@ -115,8 +116,8 @@ function inline( line, LOCAL, len, code, href, guard ) {
     return "";
 
   # omit processing of escaped characters
-  } else if ( line ~ /^\\[]\\`\*_\{\}\(\)#\+-\.![]/) {
-    return substr(line, 2, 1) inline( substr(line, 3) );
+  } else if ( line ~ /^\\./) {
+    return HTML(substr(line, 2, 1)) inline( substr(line, 3) );
 
   # hard brakes
   } else if ( match(line, /^  \n/) ) {
@@ -130,7 +131,7 @@ function inline( line, LOCAL, len, code, href, guard ) {
       code = substr( line, len + 1, match( substr(line, len + 1), guard ) - 1)
       len = 2 * length(guard) + length(code)
       #  strip single surrounding white spaces
-      code = gensub( / (.*) /, "\\1", "1" , code)
+      code = gensub( /^ | $/, "", "g" , code)
       #  escape HTML within code span
       gsub( /&/, "\\&amp;", code ); gsub( /</, "\\&lt;", code ); gsub( />/, "\\&gt;", code );
       return "<code>" code "</code>" inline( substr( line, len + 1 ) )