}
-void mmd_export_link_html(DString * out, const char * source, token * text, link * link, size_t offset, scratch_pad * scratch) {
+void mmd_export_link_html(DString * out, const char * source, token * text, link * link, scratch_pad * scratch) {
attr * a = link->attributes;
if (link->url) {
text->child->next->len++;
}
- mmd_export_token_tree_html(out, source, text->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, text->child, scratch);
print_const("</a>");
}
-void mmd_export_image_html(DString * out, const char * source, token * text, link * link, size_t offset, scratch_pad * scratch, bool is_figure) {
+void mmd_export_image_html(DString * out, const char * source, token * text, link * link, scratch_pad * scratch, bool is_figure) {
attr * a = link->attributes;
// Compatibility mode doesn't allow figures
if (is_figure) {
if (text) {
print_const("\n<figcaption>");
- mmd_export_token_tree_html(out, source, text->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, text->child, scratch);
print_const("</figcaption>");
}
print_const("\n</figure>");
// This entry is a direct descendant of the parent
temp_char = label_from_header(source, entry);
printf("<li><a href=\"#%s\">", temp_char);
- mmd_export_token_tree_html(out, source, entry->child, 0, scratch);
+ mmd_export_token_tree_html(out, source, entry->child, scratch);
print_const("</a>");
if (*counter < scratch->header_stack->size - 1) {
}
-void mmd_export_token_html(DString * out, const char * source, token * t, size_t offset, scratch_pad * scratch) {
+void mmd_export_token_html(DString * out, const char * source, token * t, scratch_pad * scratch) {
if (t == NULL)
return;
pad(out, 2, scratch);
print_const("<blockquote>\n");
scratch->padded = 2;
- mmd_export_token_tree_html(out, source, t->child, t->start + offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
pad(out, 1, scratch);
print_const("</blockquote>");
scratch->padded = 0;
if (!(t->child->next && (t->child->next->type == BLOCK_EMPTY) && t->child->next->next))
scratch->list_is_tight = true;
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
print_const("</dd>");
scratch->padded = 0;
scratch->padded = 2;
- mmd_export_token_tree_html(out, source, t->child, t->start + offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
pad(out, 1, scratch);
if (!(t->next && (t->next->type == BLOCK_DEFLIST)))
}
print_const(">");
- mmd_export_token_tree_html_raw(out, source, t->child->next, t->start + offset, scratch);
+ mmd_export_token_tree_html_raw(out, source, t->child->next, scratch);
print_const("</code></pre>");
scratch->padded = 0;
break;
case BLOCK_CODE_INDENTED:
pad(out, 2, scratch);
print_const("<pre><code>");
- mmd_export_token_tree_html_raw(out, source, t->child, t->start + offset, scratch);
+ mmd_export_token_tree_html_raw(out, source, t->child, scratch);
print_const("</code></pre>");
scratch->padded = 0;
break;
printf("<h%1d id=\"%s\">", temp_short + scratch->base_header_level - 1, temp_char);
free(temp_char);
}
- mmd_export_token_tree_html(out, source, t->child, t->start + offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
printf("</h%1d>", temp_short + scratch->base_header_level - 1);
scratch->padded = 0;
break;
pad(out, 2, scratch);
print_const("<ul>");
scratch->padded = 0;
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
pad(out, 1, scratch);
print_const("</ul>");
scratch->padded = 0;
pad(out, 2, scratch);
print_const("<ol>");
scratch->padded = 0;
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
pad(out, 1, scratch);
print_const("</ol>");
scratch->padded = 0;
pad(out, 1, scratch);
print_const("<li>");
scratch->padded = 2;
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
print_const("</li>");
scratch->padded = 0;
break;
print_const("<p>");
scratch->padded = 2;
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
if (scratch->close_para) {
if (!scratch->list_is_tight)
if (!scratch->list_is_tight)
print_const("<p>");
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
if (scratch->citation_being_printed) {
scratch->footnote_para_counter--;
printf("<h%1d id=\"%s\">", temp_short + scratch->base_header_level - 1, temp_char);
free(temp_char);
}
- mmd_export_token_tree_html(out, source, t->child, t->start + offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
printf("</h%1d>", temp_short + scratch->base_header_level - 1);
scratch->padded = 0;
break;
printf("<h%1d id=\"%s\">", temp_short + scratch->base_header_level - 1, temp_char);
free(temp_char);
}
- mmd_export_token_tree_html(out, source, t->child, t->start + offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
printf("</h%1d>", temp_short + scratch->base_header_level - 1);
scratch->padded = 0;
break;
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);
+ mmd_export_token_tree_html(out, source, t->next->child->child, scratch);
print_const("</caption>\n");
temp_short = 1;
} else {
print_const("</colgroup>\n");
scratch->padded = 1;
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
pad(out, 1, scratch);
print_const("</table>");
scratch->padded = 0;
pad(out, 2, scratch);
print_const("<thead>\n");
scratch->in_table_header = 1;
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
scratch->in_table_header = 0;
print_const("</thead>\n");
scratch->padded = 1;
pad(out, 2, scratch);
print_const("<tbody>\n");
scratch->padded = 2;
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
print_const("</tbody>");
scratch->padded = 0;
break;
case BLOCK_TERM:
pad(out, 2, scratch);
print_const("<dt>");
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
print_const("</dt>\n");
scratch->padded = 2;
break;
temp_char = label_from_header(source, temp_token);
printf("<li><a href=\"#%s\">", temp_char);
- mmd_export_token_tree_html(out, source, temp_token->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, temp_token->child, scratch);
print_const("</a>");
free(temp_char);
}
}
break;
case DOC_START_TOKEN:
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
break;
case ELLIPSIS:
if (!(scratch->extensions & EXT_SMART)) {
break;
case LINE_LIST_BULLETED:
case LINE_LIST_ENUMERATED:
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
break;
case MARKER_BLOCKQUOTE:
case MARKER_H1:
t->child->type = TEXT_EMPTY;
t->child->mate->type = TEXT_EMPTY;
print_const("<code>");
- mmd_export_token_tree_html_raw(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html_raw(out, source, t->child, scratch);
print_const("</code>");
break;
case PAIR_ANGLE:
} else if (scan_html(&source[t->start])) {
print_token(t);
} else {
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
}
free(temp_char);
break;
case PAIR_BRACES:
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
break;
case PAIR_BRACKET:
if ((scratch->extensions & EXT_NOTES) &&
if (temp_link) {
if (t->type == PAIR_BRACKET) {
// Link
- mmd_export_link_html(out, source, t, temp_link, offset, scratch);
+ mmd_export_link_html(out, source, t, temp_link, scratch);
} else {
// Image -- should it be a figure (e.g. image is only thing in paragraph)?
temp_token = t->next;
temp_token = temp_token->next;
if (t->prev || temp_token) {
- mmd_export_image_html(out, source, t, temp_link, offset, scratch, false);
+ mmd_export_image_html(out, source, t, temp_link, scratch, false);
} else {
- mmd_export_image_html(out, source, t, temp_link, offset, scratch, true);
+ mmd_export_image_html(out, source, t, temp_link, scratch, true);
}
}
}
// No links exist, so treat as normal
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
break;
case PAIR_BRACKET_CITATION:
parse_citation:
}
} else {
// Footnotes disabled
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
}
free(temp_char);
}
} else {
// Footnotes disabled
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
}
break;
case PAIR_BRACKET_GLOSSARY:
if (temp_short == -1) {
print_const("[?");
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
print_const("]");
break;
}
}
} else {
// Footnotes disabled
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
}
break;
case PAIR_BRACKET_VARIABLE:
if (temp_char2)
mmd_print_string_html(out, temp_char2, false);
else
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
// Don't free temp_char2 (it belongs to meta *)
free(temp_char);
t->child->type = TEXT_EMPTY;
t->child->mate->type = TEXT_EMPTY;
if (scratch->extensions & EXT_CRITIC_ACCEPT) {
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
} else {
print_const("<ins>");
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
print_const("</ins>");
}
} else {
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
}
break;
case PAIR_CRITIC_DEL:
t->child->type = TEXT_EMPTY;
t->child->mate->type = TEXT_EMPTY;
if (scratch->extensions & EXT_CRITIC_REJECT) {
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
} else {
print_const("<del>");
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
print_const("</del>");
}
} else {
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
}
break;
case PAIR_CRITIC_COM:
t->child->type = TEXT_EMPTY;
t->child->mate->type = TEXT_EMPTY;
print_const("<span class=\"critic comment\">");
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
print_const("</span>");
} else {
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
}
break;
case PAIR_CRITIC_HI:
t->child->type = TEXT_EMPTY;
t->child->mate->type = TEXT_EMPTY;
print_const("<mark>");
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
print_const("</mark>");
} else {
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
}
break;
case CRITIC_SUB_DIV_A:
if (scratch->extensions & EXT_CRITIC_ACCEPT) {
} else if (scratch->extensions & EXT_CRITIC_REJECT) {
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
} else {
print_const("<del>");
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
print_const("</del>");
}
} else {
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
}
break;
case PAIR_CRITIC_SUB_ADD:
if (scratch->extensions & EXT_CRITIC_REJECT) {
} else if (scratch->extensions & EXT_CRITIC_ACCEPT) {
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
} else {
print_const("<ins>");
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
print_const("</ins>");
}
} else {
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
}
break;
case PAIR_MATH:
case PAIR_QUOTE_SINGLE:
case PAIR_STAR:
case PAIR_UL:
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
break;
case PAREN_LEFT:
print_char('(');
(t->start < t->mate->start) ? (print_const("<sub>")) : (print_const("</sub>"));
} else if (t->len != 1) {
print_const("<sub>");
- mmd_export_token_html(out, source, t->child, offset, scratch);
+ mmd_export_token_html(out, source, t->child, scratch);
print_const("</sub>");
} else {
print_const("~");
(t->start < t->mate->start) ? (print_const("<sup>")) : (print_const("</sup>"));
} else if (t->len != 1) {
print_const("<sup>");
- mmd_export_token_html(out, source, t->child, offset, scratch);
+ mmd_export_token_html(out, source, t->child, scratch);
print_const("</sup>");
} else {
print_const("^");
}
}
print_const(">");
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
if (scratch->in_table_header) {
print_const("</th>\n");
} else {
case TABLE_ROW:
print_const("<tr>\n");
scratch->table_cell_count = 0;
- mmd_export_token_tree_html(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html(out, source, t->child, scratch);
print_const("</tr>\n");
break;
case TEXT_LINEBREAK:
}
-void mmd_export_token_tree_html(DString * out, const char * source, token * t, size_t offset, scratch_pad * scratch) {
+void mmd_export_token_tree_html(DString * out, const char * source, token * t, scratch_pad * scratch) {
// Prevent stack overflow with "dangerous" input causing extreme recursion
if (scratch->recurse_depth == kMaxExportRecursiveDepth) {
if (scratch->skip_token) {
scratch->skip_token--;
} else {
- mmd_export_token_html(out, source, t, offset, scratch);
+ mmd_export_token_html(out, source, t, scratch);
}
t = t->next;
}
-void mmd_export_token_html_raw(DString * out, const char * source, token * t, size_t offset, scratch_pad * scratch) {
+void mmd_export_token_html_raw(DString * out, const char * source, token * t, scratch_pad * scratch) {
if (t == NULL)
return;
break;
default:
if (t->child)
- mmd_export_token_tree_html_raw(out, source, t->child, offset, scratch);
+ mmd_export_token_tree_html_raw(out, source, t->child, scratch);
else
print_token(t);
break;
}
-void mmd_export_token_tree_html_raw(DString * out, const char * source, token * t, size_t offset, scratch_pad * scratch) {
+void mmd_export_token_tree_html_raw(DString * out, const char * source, token * t, scratch_pad * scratch) {
while (t != NULL) {
if (scratch->skip_token) {
scratch->skip_token--;
} else {
- mmd_export_token_html_raw(out, source, t, offset, scratch);
+ mmd_export_token_html_raw(out, source, t, scratch);
}
t = t->next;
content = note->content;
scratch->footnote_being_printed = i + 1;
- mmd_export_token_tree_html(out, source, content, 0, scratch);
+ mmd_export_token_tree_html(out, source, content, scratch);
pad(out, 1, scratch);
printf("</li>");
content = note->content;
scratch->glossary_being_printed = i + 1;
- mmd_export_token_tree_html(out, source, content, 0, scratch);
+ mmd_export_token_tree_html(out, source, content, scratch);
pad(out, 1, scratch);
printf("</li>");
content = note->content;
scratch->citation_being_printed = i + 1;
- mmd_export_token_tree_html(out, source, content, 0, scratch);
+ mmd_export_token_tree_html(out, source, content, scratch);
pad(out, 1, scratch);
printf("</li>");