summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/latex.c23
-rw-r--r--src/render.c2
-rw-r--r--src/render.h1
3 files changed, 17 insertions, 9 deletions
diff --git a/src/latex.c b/src/latex.c
index 70aa920..e7a74d7 100644
--- a/src/latex.c
+++ b/src/latex.c
@@ -243,6 +243,21 @@ get_link_type(cmark_node *node)
}
static int
+S_get_enumlevel(cmark_node *node)
+{
+ int enumlevel = 0;
+ cmark_node *tmp = node;
+ while (tmp) {
+ if (tmp->type == CMARK_NODE_LIST &&
+ cmark_node_get_list_type(node) == CMARK_ORDERED_LIST) {
+ enumlevel++;
+ }
+ tmp = tmp->parent;
+ }
+ return enumlevel;
+}
+
+static int
S_render_node(cmark_node *node, cmark_event_type ev_type,
cmark_renderer *renderer)
{
@@ -271,9 +286,6 @@ S_render_node(cmark_node *node, cmark_event_type ev_type,
case CMARK_NODE_LIST:
list_type = cmark_node_get_list_type(node);
if (entering) {
- if (list_type == CMARK_ORDERED_LIST) {
- renderer->enumlevel++;
- }
LIT("\\begin{");
LIT(list_type == CMARK_ORDERED_LIST ?
"enumerate" : "itemize");
@@ -284,16 +296,13 @@ S_render_node(cmark_node *node, cmark_event_type ev_type,
sprintf(list_number_string,
"%d", list_number);
LIT("\\setcounter{enum");
- LIT((char *)roman_numerals[renderer->enumlevel]);
+ LIT((char *)roman_numerals[S_get_enumlevel(node)]);
LIT("}{");
OUT(list_number_string, false, NORMAL);
LIT("}");
CR();
}
} else {
- if (list_type == CMARK_ORDERED_LIST) {
- renderer->enumlevel--;
- }
LIT("\\end{");
LIT(list_type == CMARK_ORDERED_LIST ?
"enumerate" : "itemize");
diff --git a/src/render.c b/src/render.c
index f60835f..3b4976d 100644
--- a/src/render.c
+++ b/src/render.c
@@ -141,7 +141,7 @@ cmark_render(cmark_node *root,
}
cmark_renderer renderer = { options, &buf, &pref, 0, width,
- 0, 0, 0, true, false, false,
+ 0, 0, true, false, false,
outc, S_cr, S_blankline, S_out };
while ((ev_type = cmark_iter_next(iter)) != CMARK_EVENT_DONE) {
diff --git a/src/render.h b/src/render.h
index cf5b078..5f2a9ca 100644
--- a/src/render.h
+++ b/src/render.h
@@ -24,7 +24,6 @@ struct cmark_renderer {
int width;
int need_cr;
bufsize_t last_breakable;
- int enumlevel;
bool begin_line;
bool no_wrap;
bool in_tight_list_item;