# - ? Simple table (pandoc)
# - ? Multiline table (pandoc)
# - [x] Grid table (pandoc)
-# - [x] Pipe table (php md pandoc)
+# - [x] Headerless
+# - [x] Pipe table (php md, pandoc)
# - [x] Line blocks (pandoc)
# - [x] Task lists (pandoc, custom)
# - [ ] Definition lists (php md, pandoc)
# - [x] ^Superscript^ ~Subscript~ (pandoc)
# - [-] Bracketed spans (pandoc)
# - [-] Inline attributes (pandoc)
-# - [x] Image attributes (custom, pandoc inspired, inline only)
+# - [x] Image attributes (custom, pandoc inspired, not for reference style)
# - [x] Wiki style links [[PageName]] / [[PageName|Link Text]]
# - [-] TEX-Math (pandoc)
# - ? Footnotes (php md)
return "<table>" ttext "</tbody></table>\n" _block(block);
# Grid Tables (pandoc)
- } else if ( match(block, "^\\+(-+\\+)+\n" \
- "(\\|([^\n]+\\|)+\n)+" \
- "\\+(:?=+:?\\+)+\n" \
- "((\\|([^\n]+\\|)+\n)+" \
- "\\+(-+\\+)+(\n|$))+" \
- ) ) {
+ # (with, and without header)
+ } else if ( match( block, "^\\+(-+\\+)+\n" \
+ "(\\|([^\n]+\\|)+\n)+" \
+ "(\\+(:?=+:?\\+)+)\n" \
+ "((\\|([^\n]+\\|)+\n)+" \
+ "\\+(-+\\+)+(\n|$))+", \
+ tread \
+ ) || \
+ match( block, "^()()()" \
+ "(\\+(:?-+:?\\+)+)\n" \
+ "((\\|([^\n]+\\|)+\n)+" \
+ "\\+(-+\\+)+(\n|$))+", \
+ tread \
+ ) ) {
len = RLENGTH; st = RSTART;
#initialize empty arrays
- split("", talign); split("", tarray); split("", tread);
+ split("", talign); split("", tarray); # split("", tread);
cols = 0; cnt=0; ttext = "";
- # table header and alignment
- 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|$)/)) \
- )), tread, /\|/);
- block = substr(block, match(block, /(\n|$)/) + 1 );
- for (cnt = 1; cnt < cols; cnt++)
- tarray[cnt] = tarray[cnt] "\n" tread[cnt];
+ # table alignment
+ cols = split( gensub( /(^\+|\+$)/, "", "g", tread[4] ), talign, /\+/ );
+
+ for (cnt = 1; cnt <= cols; cnt++) {
+ if (match(talign[cnt], /:(-+|=+):/)) talign[cnt]="center";
+ else if (match(talign[cnt], /(-+|=+):/)) talign[cnt]="right";
+ else if (match(talign[cnt], /:(-+|=+)/ )) talign[cnt]="left";
+ else talign[cnt]="";
}
- cols = split( \
- gensub( /(^\+|\+$)/, "", "g", \
- substr(block, 1, match(block, /(\n|$)/)) \
- ), talign, /\+/);
- block = substr(block, match(block, /(\n|$)/) + 1 );
+ if ( match(block, "^\\+(-+\\+)+\n" \
+ "(\\|([^\n]+\\|)+\n)+" \
+ "\\+(:?=+:?\\+)+\n" \
+ "((\\|([^\n]+\\|)+\n)+" \
+ "\\+(-+\\+)+(\n|$))+" \
+ ) ) {
+ # 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|$)/)) \
+ )), tread, /\|/);
+ block = substr(block, match(block, /(\n|$)/) + 1 );
+ for (cnt = 1; cnt <= cols; cnt++)
+ tarray[cnt] = tarray[cnt] "\n" tread[cnt];
+ }
- for (cnt = 1; cnt < cols; cnt++) {
- if (match(talign[cnt], /:=+:/)) talign[cnt]="center";
- else if (match(talign[cnt], /=+:/)) talign[cnt]="right";
- else if (match(talign[cnt], /:=+/ )) talign[cnt]="left";
- else talign[cnt]="";
+ ttext = "<thead>\n<tr>"
+ for (cnt = 1; cnt <= cols; cnt++)
+ ttext = ttext "<th align=\"" talign[cnt] "\">" _block(tarray[cnt]) "</th>"
+ ttext = ttext "</tr>\n</thead>"
}
- ttext = "<thead>\n<tr>"
- for (cnt = 1; cnt < cols; cnt++)
- ttext = ttext "<th align=\"" talign[cnt] "\">" _block(tarray[cnt]) "</th>"
- ttext = ttext "</tr>\n</thead><tbody>\n"
+ # table body
+ block = substr(block, match(block, /(\n|$)/) + 1 );
+ ttext = ttext "<tbody>\n"
while ( match(block, /^((\|([^\n]+\|)+\n)+\+(-+\+)+(\n|$))+/ ) ){
split("", tarray);
substr(block, 1, match(block, /(\n|$)/)) \
)), tread, /\|/);
block = substr(block, match(block, /(\n|$)/) + 1 );
- for (cnt = 1; cnt < cols; cnt++)
+ for (cnt = 1; cnt <= cols; cnt++)
tarray[cnt] = tarray[cnt] "\n" tread[cnt];
}
block = substr(block, match(block, /(\n|$)/) + 1 );
ttext = ttext "<tr>"
- for (cnt = 1; cnt < cols; cnt++)
+ for (cnt = 1; cnt <= cols; cnt++)
ttext = ttext "<td align=\"" talign[cnt] "\">" _block(tarray[cnt]) "</td>"
ttext = ttext "</tr>\n"
}