Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions api_test/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,31 @@ static void render_latex(test_batch_runner *runner) {
"render document without wrapping");
free(latex);
cmark_node_free(doc);

// An ordered list nested inside a bullet list is still the first
// enumerate level, so its start value must go into enumi, not enumii.
static const char nested[] = "- outer\n"
"\n"
" 5. five\n"
" 6. six\n";
cmark_node *nested_doc =
cmark_parse_document(nested, sizeof(nested) - 1, CMARK_OPT_DEFAULT);
latex = cmark_render_latex(nested_doc, CMARK_OPT_DEFAULT, 0);
STR_EQ(runner, latex, "\\begin{itemize}\n"
"\\item outer\n"
"\n"
"\\begin{enumerate}\n"
"\\setcounter{enumi}{4}\n"
"\\item five\n"
"\n"
"\\item six\n"
"\n"
"\\end{enumerate}\n"
"\n"
"\\end{itemize}\n",
"enumerate counter ignores bullet list nesting");
free(latex);
cmark_node_free(nested_doc);
}

static void render_commonmark(test_batch_runner *runner) {
Expand Down
2 changes: 1 addition & 1 deletion src/latex.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ static int S_get_enumlevel(cmark_node *node) {
cmark_node *tmp = node;
while (tmp) {
if (tmp->type == CMARK_NODE_LIST &&
cmark_node_get_list_type(node) == CMARK_ORDERED_LIST) {
cmark_node_get_list_type(tmp) == CMARK_ORDERED_LIST) {
enumlevel++;
}
tmp = tmp->parent;
Expand Down
Loading