"(\\|([^\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";
# 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++)