return s;
}
- if (a->node[s].child[query[0]] == 0) {
+ if (a->node[s].child[(int)query[0]] == 0) {
// Failed to match
return -1;
}
// Partial match, keep going
- return trie_node_search(a, a->node[s].child[query[0]], query + 1);
+ return trie_node_search(a, a->node[s].child[(int)query[0]], query + 1);
}
char * suffix = buffer;
- // No suffix for first level matches
- unsigned short last_match_depth = a->node[last_match_state].len;
-
- if (depth == 1) {
- last_match_depth = 1;
- }
-
// Longest match seen so far??
suffix += 1;
size_t temp_state;
// Character being compared
- char test_value;
+ int test_value;
size_t counter = 0;
while ((counter < len) && (source[counter] != '\0')) {
// Read next character
- test_value = source[counter++];
+ test_value = (int)source[counter++];
// Check for path that allows us to match next character
while (state != 0 && a->node[state].child[test_value] == 0) {
text->child->next->start--;
text->child->next->len++;
}
-
- mmd_export_token_tree_html(out, source, text->child, scratch);
+
+ if (text->child)
+ mmd_export_token_tree_html(out, source, text->child, scratch);
print_const("</a>");
}
void mmd_export_toc_html(DString * out, const char * source, scratch_pad * scratch) {
- token * entry;
size_t counter = 0;
mmd_export_toc_entry_html(out, source, scratch, &counter, 0);
scratch->padded = 2;
break;
case BLOCK_TOC:
- temp_short = 0;
- temp_short2 = 0;
pad(out, 2, scratch);
print_const("<div class=\"TOC\">\n");
print_const("</div>");
scratch->padded = 0;
break;
- for (int i = 0; i < scratch->header_stack->size; ++i)
- {
- temp_token = stack_peek_index(scratch->header_stack, i);
-
- if (temp_token->type == temp_short2) {
- // Same level -- close list item
- print_const("</li>\n");
- }
-
- if (temp_short == 0) {
- // First item
- print_const("\n<ul>\n");
- temp_short = temp_token->type;
- temp_short2 = temp_short;
- }
-
- // Indent?
- if (temp_token->type == temp_short2) {
- // Same level -- NTD
- } else if (temp_token->type == temp_short2 + 1) {
- // Indent
- print_const("\n\n<ul>\n");
- temp_short2++;
- } else if (temp_token->type < temp_short2) {
- // Outdent
- print_const("</li>\n");
- while (temp_short2 > temp_token->type) {
- if (temp_short2 > temp_short)
- print_const("</ul></li>\n");
- else
- temp_short = temp_short2 - 1;
-
- temp_short2--;
- }
- } else {
- // Skipped more than one level -- ignore
- continue;
- }
-
- 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, scratch);
- print_const("</a>");
- free(temp_char);
- }
-
- while (temp_short2 > (temp_short)) {
- print_const("</ul>\n");
- temp_short2--;
- }
-
- if (temp_short)
- print_const("</li>\n</ul>\n");
-
- print_const("</div>");
- scratch->padded = 0;
- break;
case BRACE_DOUBLE_LEFT:
print_const("{{");
break;
// Classify this use
temp_short2 = scratch->used_citations->size;
- temp_short3 = scratch->inline_citations_to_free->size;
citation_from_bracket(source, scratch, t, &temp_short);
if (temp_short == -1) {
break;
}
- // Get instance of the note used
- temp_note = stack_peek_index(scratch->used_citations, temp_short - 1);
-
if (temp_bool) {
// This is a regular citation
// 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 == -1) {
// Classify this use
temp_short2 = scratch->used_glossaries->size;
- temp_short3 = scratch->inline_glossaries_to_free->size;
glossary_from_bracket(source, scratch, t, &temp_short);
if (temp_short == -1) {
void mmd_export_toc_latex(DString * out, const char * source, scratch_pad * scratch) {
- token * entry;
size_t counter = 0;
mmd_export_toc_entry_latex(out, source, scratch, &counter, 0);
scratch->padded = 0;
break;
case BLOCK_TOC:
- temp_short = 0;
- temp_short2 = 0;
pad(out, 2, scratch);
print_const("\\tableofcontents");
scratch->padded = 0;
// Note-based syntax enabled
// Classify this use
- temp_short2 = scratch->used_abbreviations->size;
temp_short3 = scratch->inline_abbreviations_to_free->size;
abbreviation_from_bracket(source, scratch, t, &temp_short);
}
// Classify this use
- temp_short2 = scratch->used_citations->size;
- temp_short3 = scratch->inline_citations_to_free->size;
citation_from_bracket(source, scratch, t, &temp_short);
if (temp_short == -1) {
// 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 == -1) {
break;
}
- // Get instance of the note used
- temp_note = stack_peek_index(scratch->used_footnotes, temp_short - 1);
-
if (temp_short2 == scratch->used_footnotes->size) {
// This is a re-use of a previously used note
void mmd_export_link_odf(DString * out, const char * source, token * text, link * link, scratch_pad * scratch) {
- attr * a = link->attributes;
-
if (link->url) {
print_const("<text:a xlink:type=\"simple\" xlink:href=\"");
mmd_print_string_odf(out, link->url);
}
void mmd_export_toc_odf(DString * out, const char * source, scratch_pad * scratch) {
- token * entry;
size_t counter = 0;
// TODO: Could use LC to internationalize this
scratch->padded = 0;
break;
case BLOCK_TOC:
- temp_short = 0;
- temp_short2 = 0;
pad(out, 2, scratch);
mmd_export_toc_odf(out, source, scratch);
// Classify this use
temp_short2 = scratch->used_citations->size;
- temp_short3 = scratch->inline_citations_to_free->size;
citation_from_bracket(source, scratch, t, &temp_short);
if (temp_short == -1) {
break;
}
- // Get instance of the note used
- temp_note = stack_peek_index(scratch->used_citations, temp_short - 1);
temp_short3 = scratch->odf_para_type;
scratch->odf_para_type = PAIR_BRACKET_FOOTNOTE;
// 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 == -1) {
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;
// Classify this use
temp_short2 = scratch->used_glossaries->size;
- temp_short3 = scratch->inline_glossaries_to_free->size;
glossary_from_bracket(source, scratch, t, &temp_short);
if (temp_short == -1) {
// Counter
size_t start_counter = s->size;
- size_t i = start_counter; // We're sharing one stack, so any opener earlier than this belongs to a parent
+ size_t i; // We're sharing one stack, so any opener earlier than this belongs to a parent
token * peek;
unsigned short pair_type;