From 8b274587e1ed5f33c6a3ec8d94cf3323b1e7ead6 Mon Sep 17 00:00:00 2001 From: "Fletcher T. Penney" Date: Thu, 4 May 2017 15:27:00 -0400 Subject: [PATCH] CHANGED: Preserve closing Heading markers --- Sources/libMultiMarkdown/mmd.c | 13 ++++++++----- Sources/libMultiMarkdown/writer.c | 6 ++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Sources/libMultiMarkdown/mmd.c b/Sources/libMultiMarkdown/mmd.c index e6f3704..6c16ddf 100644 --- a/Sources/libMultiMarkdown/mmd.c +++ b/Sources/libMultiMarkdown/mmd.c @@ -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; diff --git a/Sources/libMultiMarkdown/writer.c b/Sources/libMultiMarkdown/writer.c index 7eac17b..f112d38 100644 --- a/Sources/libMultiMarkdown/writer.c +++ b/Sources/libMultiMarkdown/writer.c @@ -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: -- 2.40.0