mode than MMD-5. This started as a side-effect of the parsing algorithm, but
I actually think it makes sense. This may or may not change in the future.
+6. Table captions in MMD-6 must come immediately *after* the table, not
+before it.
+
## Where Does MultiMarkdown 6 Stand? ##
* Abbreviations
* Glossaries
* File Transclusion
-* Table Captions
### Accuracy ###
case BLOCK_TABLE:
pad(out, 2, scratch);
print("<table>\n");
+
+ // Are we followed by a caption?
+ if (table_has_caption(t)) {
+ temp_token = t->next->child;
+
+ if (temp_token->next &&
+ temp_token->next->type == PAIR_BRACKET) {
+ temp_token = temp_token->next;
+ }
+
+ temp_char = label_from_token(source, temp_token);
+ printf("<caption id=\"%s\">", temp_char);
+ free(temp_char);
+
+ t->next->child->child->type = TEXT_EMPTY;
+ t->next->child->child->mate->type = TEXT_EMPTY;
+ mmd_export_token_tree_html(out, source, t->next->child->child, offset, scratch);
+ print("</caption>\n");
+ temp_short = 1;
+ } else {
+ temp_short = 0;
+ }
+
scratch->padded = 2;
read_table_column_alignments(source, t, scratch);
pad(out, 1, scratch);
print("</table>");
scratch->padded = 0;
+
+ scratch->skip_token = temp_short;
+
break;
case BLOCK_TABLE_HEADER:
pad(out, 2, scratch);
chain = chain->next;
}
}
+
+
+bool table_has_caption(token * t) {
+
+ if (t->next && t->next->type == BLOCK_PARA) {
+ t = t->next->child;
+
+ if (t->type == PAIR_BRACKET) {
+ t = t->next;
+
+ if (t && t->next &&
+ t->next->type == PAIR_BRACKET)
+ t = t->next;
+
+ if (t && t->next &&
+ ((t->next->type == TEXT_NL) ||
+ (t->next->type == TEXT_LINEBREAK)))
+ t = t->next;
+
+ if (t->next == NULL)
+ return true;
+ }
+ }
+
+ return false;
+}
+
void strip_leading_whitespace(token * chain, const char * source);
+bool table_has_caption(token * table);
+
#endif
mode than MMD-5. This started as a side-effect of the parsing algorithm, but
I actually think it makes sense. This may or may not change in the future.
+6. Table captions in MMD-6 must come immediately *after* the table, not
+before it.
+
## Where Does MultiMarkdown 6 Stand? ##
* Abbreviations
* Glossaries
* File Transclusion
-* Table Captions
### Accuracy ###
</tr>
</tbody>
</table>
+
+<table>
+<caption id="bar"><em>foo</em></caption>
+<colgroup>
+<col />
+<col />
+</colgroup>
+
+<thead>
+<tr>
+ <th> foo </th>
+ <th> bar </th>
+</tr>
+</thead>
+
+<tbody>
+<tr>
+ <td> foo </td>
+ <td> bar </td>
+</tr>
+</tbody>
+</table>
+
+<table>
+<caption id="foo"><em>foo</em></caption>
+<colgroup>
+<col />
+<col />
+</colgroup>
+
+<thead>
+<tr>
+ <th> foo </th>
+ <th> bar </th>
+</tr>
+</thead>
+
+<tbody>
+<tr>
+ <td> foo </td>
+ <td> bar </td>
+</tr>
+</tbody>
+</table>
+
+<p>[<em>foo</em>][bar]
+| foo | bar |
+| — | — |
+| foo | bar |</p>
| :---- | ----: |
<em>foo</em> | <em>bar</em> |
| <strong>foo bar</strong> ||</p>
+
+<p>| foo | bar |
+| --- | --- |
+| foo | bar |
+[<em>foo</em>][bar]</p>
+
+<p>| foo | bar |
+| --- | --- |
+| foo | bar |
+[<em>foo</em>]</p>
+
+<p>[<em>foo</em>][bar]
+| foo | bar |
+| --- | --- |
+| foo | bar |</p>
| foo6 | bar6 |
| :---- | ----: |
*foo* | *bar* |
-| **foo bar** ||
\ No newline at end of file
+| **foo bar** ||
+
+
+| foo | bar |
+| --- | --- |
+| foo | bar |
+[*foo*][bar]
+
+| foo | bar |
+| --- | --- |
+| foo | bar |
+[*foo*]
+
+[*foo*][bar]
+| foo | bar |
+| --- | --- |
+| foo | bar |