break;
case PAIR_BRACKET_FOOTNOTE:
if (scratch->extensions & EXT_NOTES) {
+ // Note-based syntax enabled
+
+ // Classify this use
+ temp_short2 = scratch->used_footnotes->size;
+ temp_short3 = scratch->inline_footnotes_to_free->size;
footnote_from_bracket(source, scratch, t, &temp_short);
- if (temp_short < scratch->used_footnotes->size) {
- // Re-using previous footnote
+ if (temp_short == -1) {
+ // This instance is not properly formed
+ print_const("[^");
+ mmd_export_token_tree_html(out, source, t->child->next, scratch);
+ print_const("]");
+ break;
+ }
+
+ if (temp_short2 == scratch->used_footnotes->size) {
+ // This is a re-use of a previously used note
+
printf("<a href=\"#fn:%d\" title=\"%s\" class=\"footnote\">[%d]</a>",
- temp_short, LC("see footnote"), temp_short);
+ temp_short, LC("see footnote"), temp_short);
} else {
- // This is a new footnote
+ // This is the first time this note was used
+
printf("<a href=\"#fn:%d\" id=\"fnref:%d\" title=\"%s\" class=\"footnote\">[%d]</a>",
- temp_short, temp_short, LC("see footnote"), temp_short);
+ temp_short, temp_short, LC("see footnote"), temp_short);
}
} else {
- // Footnotes disabled
+ // Note-based syntax disabled
mmd_export_token_tree_html(out, source, t->child, scratch);
}
break;
break;
case PAIR_BRACKET_FOOTNOTE:
if (scratch->extensions & EXT_NOTES) {
+ // Note-based syntax enabled
+
+ // Classify this use
+ temp_short2 = scratch->used_footnotes->size;
+ temp_short3 = scratch->inline_footnotes_to_free->size;
footnote_from_bracket(source, scratch, t, &temp_short);
- if (temp_short < scratch->used_footnotes->size) {
- // Re-using previous footnote
- print("\\footnote{reuse");
+ if (temp_short == -1) {
+ // This instance is not properly formed
+ print_const("[?");
+ mmd_export_token_tree_latex(out, source, t->child->next, scratch);
+ print_const("]");
+ break;
+ }
+
+ // Get instance of the note used
+ temp_note = stack_peek_index(scratch->used_footnotes, temp_short - 1);
- print("}");
+ if (temp_short2 == scratch->used_footnotes->size) {
+ // This is a re-use of a previously used note
+
+ // TODO: This would work, assuming no URL's are converted to
+ // footnotes without affecting the numbering.
+ // Could add a NULL to the used_footnotes stack??
+
+ // Additionally, re-using an old footnote would require flipping back
+ // through the document to find it...
+
+ // printf("\\footnotemark[%d]", temp_short);
+
+ print_const("\\footnote{");
+ temp_note = stack_peek_index(scratch->used_footnotes, temp_short - 1);
+
+ mmd_export_token_tree_latex(out, source, temp_note->content, scratch);
+ print_const("}");
} else {
- // This is a new footnote
- print("\\footnote{");
+ // This is the first time this note was used
+
+ print_const("\\footnote{");
temp_note = stack_peek_index(scratch->used_footnotes, temp_short - 1);
mmd_export_token_tree_latex(out, source, temp_note->content, scratch);
- print("}");
+ print_const("}");
}
} else {
- // Footnotes disabled
+ // Note-based syntax disabled
mmd_export_token_tree_latex(out, source, t->child, scratch);
}
break;
break;
case PAIR_BRACKET_FOOTNOTE:
if (scratch->extensions & EXT_NOTES) {
+ // Note-based syntax enabled
+
+ // Classify this use
+ temp_short2 = scratch->used_footnotes->size;
+ temp_short3 = scratch->inline_footnotes_to_free->size;
footnote_from_bracket(source, scratch, t, &temp_short);
- temp_short2 = scratch->odf_para_type;
+ if (temp_short == -1) {
+ // This instance is not properly formed
+ print_const("[?");
+ mmd_export_token_tree_odf(out, source, t->child->next, scratch);
+ print_const("]");
+ break;
+ }
+
+ // Get instance of the note used
+ temp_note = stack_peek_index(scratch->used_footnotes, temp_short - 1);
+
+ temp_short3 = scratch->odf_para_type;
scratch->odf_para_type = PAIR_BRACKET_FOOTNOTE;
- if (temp_short < scratch->used_footnotes->size) {
- // Re-using previous footnote
- print("\\footnote{reuse");
+ if (temp_short2 == scratch->used_footnotes->size) {
+ // This is a re-use of a previously used note
- print("}");
+ printf("<text:note text:id=\"fn%d\" text:note-class=\"footnote\"><text:note-body>", temp_short);
+ temp_note = stack_peek_index(scratch->used_footnotes, temp_short - 1);
+
+ mmd_export_token_tree_odf(out, source, temp_note->content, scratch);
+ print_const("</text:note-body></text:note>");
} else {
+ // This is the first time this note was used
+
// This is a new footnote
printf("<text:note text:id=\"fn%d\" text:note-class=\"footnote\"><text:note-body>", temp_short);
temp_note = stack_peek_index(scratch->used_footnotes, temp_short - 1);
print_const("</text:note-body></text:note>");
}
- scratch->odf_para_type = temp_short2;
+ scratch->odf_para_type = temp_short3;
} else {
- // Footnotes disabled
+ // Note-based syntax disabled
mmd_export_token_tree_odf(out, source, t->child, scratch);
}
break;
<text:list-item>
<text:p text:style-name="Footnote">bat</text:p></text:list-item>
+</text:list></text:note-body></text:note></text:p>
+
+<text:p text:style-name="Standard">foo.<text:note text:id="fn3" text:note-class="footnote"><text:note-body><text:p text:style-name="Footnote">foo</text:p>
+
+<text:p text:style-name="Footnote"><text:span text:style-name="MMD-Italic">bar</text:span></text:p>
+
+<text:list text:style-name="L1">
+<text:list-item>
+<text:p text:style-name="Footnote">bat</text:p></text:list-item>
+
</text:list></text:note-body></text:note></text:p>
</office:text>
</office:body>
<p>foo.<a href="#fn:3" id="fnref:3" title="see footnote" class="footnote">[3]</a></p>
+<p>foo.<a href="#fn:3" title="see footnote" class="footnote">[3]</a></p>
+
<div class="footnotes">
<hr />
<ol>
<p>foo.<a href="foo">^bar3</a></p>
+<p>foo.<a href="foo">^bar3</a></p>
+
<pre><code>*bar*
* bat
\end{itemize}}
+foo.\footnote{foo
+
+\emph{bar}
+
+\begin{itemize}
+\item{} bat
+
+\end{itemize}}
+
\input{mmd6-article-footer}
\end{document}
foo.[^bar3]
+foo.[^bar3]
+
[^bar]: *foo*
[^bar2]: *foo
bar*