]> git.plutz.net Git - cgilite/blobdiff - markdown.awk
bugfix: do not accidentally strip white spaces from code spans
[cgilite] / markdown.awk
index af3d7224657418caa809b5fa6223ce3cc1411224..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 );
@@ -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 ) )