From: Fletcher T. Penney [foo][bar]
+| foo | bar |
+| — | — |
+| foo | bar |\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("
");
scratch->padded = 0;
+
+ scratch->skip_token = temp_short;
+
break;
case BLOCK_TABLE_HEADER:
pad(out, 2, scratch);
diff --git a/src/writer.c b/src/writer.c
index 5a0ebe3..a66bd88 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -1526,3 +1526,30 @@ void strip_leading_whitespace(token * chain, const char * source) {
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;
+}
+
diff --git a/src/writer.h b/src/writer.h
index bc35c2c..b47babe 100644
--- a/src/writer.h
+++ b/src/writer.h
@@ -203,5 +203,7 @@ void read_table_column_alignments(const char * source, token * table, scratch_pa
void strip_leading_whitespace(token * chain, const char * source);
+bool table_has_caption(token * table);
+
#endif
diff --git a/templates/README.md.in b/templates/README.md.in
index 345cd8b..d4365ee 100644
--- a/templates/README.md.in
+++ b/templates/README.md.in
@@ -407,6 +407,9 @@ For example, `Reference Footnotes.text` is parsed differently in compatibility
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? ##
@@ -454,7 +457,6 @@ Things yet to be completed:
* Abbreviations
* Glossaries
* File Transclusion
-* Table Captions
### Accuracy ###
diff --git a/tests/MMD6Tests/Tables.html b/tests/MMD6Tests/Tables.html
index 32a2936..15d4fd8 100644
--- a/tests/MMD6Tests/Tables.html
+++ b/tests/MMD6Tests/Tables.html
@@ -131,3 +131,52 @@
+
+
+
+
+
+
+
+
+
+ foo
+ bar
+
+
+
+ foo
+ bar
+
+
+
+
+
+
+
+
+ foo
+ bar
+
+
+
+ foo
+ bar
+
| foo | bar | +| --- | --- | +| foo | bar | +[foo][bar]
+ +| foo | bar | +| --- | --- | +| foo | bar | +[foo]
+ +[foo][bar] +| foo | bar | +| --- | --- | +| foo | bar |
diff --git a/tests/MMD6Tests/Tables.text b/tests/MMD6Tests/Tables.text index 696e78f..4b5dcf2 100644 --- a/tests/MMD6Tests/Tables.text +++ b/tests/MMD6Tests/Tables.text @@ -34,4 +34,20 @@ | 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 |