]> granicus.if.org Git - multimarkdown/commitdiff
FIXED: Properly add id attribute to new instances of citation only
authorFletcher T. Penney <fletcher@fletcherpenney.net>
Tue, 14 Feb 2017 06:23:45 +0000 (01:23 -0500)
committerFletcher T. Penney <fletcher@fletcherpenney.net>
Tue, 14 Feb 2017 06:23:45 +0000 (01:23 -0500)
src/html.c

index c17aa9feea0293481a7ebffb108e6f51f287ef17..4e89911d9aafa1f327f6331b761c5f48fb68d02b 100644 (file)
@@ -1039,13 +1039,20 @@ void mmd_export_token_html(DString * out, const char * source, token * t, size_t
                        }
 
                        if (scratch->extensions & EXT_NOTES) {
+                               temp_short2 = scratch->used_citations->size;
+
                                citation_from_bracket(source, scratch, t, &temp_short);
 
                                if (temp_bool) {
-                    // This is a new citation
-                    temp_short = scratch->used_citations->size;
-                    printf("<a href=\"#cn:%d\" id=\"cnref:%d\" title=\"%s\" class=\"citation\">[%s%s%d]</a>",
-                            temp_short, temp_short, LC("see citation"), temp_char, temp_char2, temp_short);
+                                       if (temp_short2 == scratch->used_citations->size) {
+                                               // Repeat of earlier citation
+                                               printf("<a href=\"#cn:%d\" title=\"%s\" class=\"citation\">[%s%s%d]</a>",
+                                                               temp_short, LC("see citation"), temp_char, temp_char2, temp_short);
+                                       } else {
+                                               // New citation
+                                               printf("<a href=\"#cn:%d\" id=\"cnref:%d\" title=\"%s\" class=\"citation\">[%s%s%d]</a>",
+                                                               temp_short, temp_short, LC("see citation"), temp_char, temp_char2, temp_short);
+                                       }
                                }
 
                                if (t->prev && (t->prev->type == PAIR_BRACKET)) {
@@ -1300,11 +1307,11 @@ void mmd_export_token_html(DString * out, const char * source, token * t, size_t
                        } else {
                                print("</td>\n");
                        }
-            if (t->next)
-                scratch->table_cell_count += t->next->len;
-            else
-                scratch->table_cell_count++;
-            
+                       if (t->next)
+                               scratch->table_cell_count += t->next->len;
+                       else
+                               scratch->table_cell_count++;
+                       
                        break;
                case TABLE_DIVIDER:
                        break;