]> granicus.if.org Git - multimarkdown/commitdiff
CHANGED: Preserve closing Heading markers
authorFletcher T. Penney <fletcher@fletcherpenney.net>
Thu, 4 May 2017 19:27:00 +0000 (15:27 -0400)
committerFletcher T. Penney <fletcher@fletcherpenney.net>
Thu, 4 May 2017 19:27:00 +0000 (15:27 -0400)
Sources/libMultiMarkdown/mmd.c
Sources/libMultiMarkdown/writer.c

index e6f370497def4c6faf91273951463e997b56d895..6c16ddfb8e8c7997e2ab6313e4313e58de8962c6 100644 (file)
@@ -444,13 +444,16 @@ void mmd_assign_line_type(mmd_engine * e, token * line) {
                                // Strip trailing '#' sequence if present
                                if (line->child->tail->type == TEXT_NL) {
                                        if ((line->child->tail->prev->type >= HASH1) &&
-                                               (line->child->tail->prev->type <= HASH6))
-                                               line->child->tail->prev->type = TEXT_EMPTY;
+                                               (line->child->tail->prev->type <= HASH6)) {
+                                               line->child->tail->prev->type -= HASH1;
+                                               line->child->tail->prev->type += MARKER_H1;
+                                       }
                                } else {
-//                                     token_describe(line->child->tail, NULL);
                                        if ((line->child->tail->type >= HASH1) &&
-                                               (line->child->tail->type <= HASH6))
-                                               line->child->tail->type = TEXT_EMPTY;
+                                               (line->child->tail->type <= HASH6)) {
+                                               line->child->tail->type -= TEXT_EMPTY;
+                                               line->child->tail->type += MARKER_H1;
+                                       }
                                }
                        } else {
                                line->type = LINE_PLAIN;
index 7eac17b2508e90a31103072822127585da3a5ddb..f112d388bc510f7d6d03face177d5eded489a854 100644 (file)
@@ -1370,6 +1370,12 @@ token * manual_label_from_header(token * h, const char * source) {
                        case TEXT_NL:
                        case TEXT_LINEBREAK:
                        case TEXT_EMPTY:
+                       case MARKER_H1:
+                       case MARKER_H2:
+                       case MARKER_H3:
+                       case MARKER_H4:
+                       case MARKER_H5:
+                       case MARKER_H6:
                                walker = walker->prev;
                                break;
                        case TEXT_PLAIN: