X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=markdown.awk;h=af3d7224657418caa809b5fa6223ce3cc1411224;hb=d61539cdd435eb812053104ab5a12700607732be;hp=33c12bdc9a5be4bcccd3e5bf1b504182291b0c36;hpb=d45e2c8bfc3c107cffc6771eae97988e11b2ceb5;p=cgilite diff --git a/markdown.awk b/markdown.awk index 33c12bd..af3d722 100755 --- a/markdown.awk +++ b/markdown.awk @@ -115,8 +115,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/) ) { @@ -399,22 +399,25 @@ function _block( block, LOCAL, st, len, hlvl, htxt, guard, code, indent, attrib "(\\|([^\n]+\\|)+\n)+" \ "(\\+(:?=+:?\\+)+)\n" \ "((\\|([^\n]+\\|)+\n)+" \ - "\\+(-+\\+)+(\n|$))+", \ - tread \ + "\\+(-+\\+)+(\n|$))+" \ ) || \ match( block, "^()()()" \ "(\\+(:?-+:?\\+)+)\n" \ "((\\|([^\n]+\\|)+\n)+" \ - "\\+(-+\\+)+(\n|$))+", \ - tread \ + "\\+(-+\\+)+(\n|$))+" \ ) ) { len = RLENGTH; st = RSTART; #initialize empty arrays - split("", talign); split("", tarray); # split("", tread); + split("", talign); split("", tarray); split("", tread); cols = 0; cnt=0; ttext = ""; + # Column Count + cols = split( gensub( "^(\\+(:?-+:?\\+)+)(\n.*)*$", "\\1", 1, block), tread, /\+/) - 2; + # debug(" Cols: " gensub( "^(\\+(:?-+:?\\+)+)(\n.*)*$", "\\1", 1, block )); + # table alignment - cols = split( gensub( /(^\+|\+$)/, "", "g", tread[4] ), talign, /\+/ ); + split( gensub( "^(.*\n)?\\+((:?=+:?\\+|(:-+|-+:|:-+:)\\+)+)(\n.*)$", "\\2", "g", block ), talign, /\+/ ); + # debug("Align: " gensub( "^(.*\n)?\\+((:?=+:?\\+|(:-+|-+:|:-+:)\\+)+)(\n.*)$", "\\2", "g", block )); for (cnt = 1; cnt <= cols; cnt++) { if (match(talign[cnt], /:(-+|=+):/)) talign[cnt]="center"; @@ -432,9 +435,9 @@ function _block( block, LOCAL, st, len, hlvl, htxt, guard, code, indent, attrib # table header block = substr(block, match(block, /(\n|$)/) + 1 ); while ( match(block, "^\\|([^\n]+\\|)+\n") ) { - cols = split( gensub( /(^\||\|$)/, "", "g", \ - gensub( /(^|[^\\])\\\|/, "\\1\\|", "g", \ - substr(block, 1, match(block, /(\n|$)/)) \ + split( gensub( /(^\||\|$)/, "", "g", \ + gensub( /(^|[^\\])\\\|/, "\\1\\|", "g", \ + substr(block, 1, match(block, /(\n|$)/)) \ )), tread, /\|/); block = substr(block, match(block, /(\n|$)/) + 1 ); for (cnt = 1; cnt <= cols; cnt++)