From: Fletcher T. Penney Date: Thu, 4 May 2017 19:27:00 +0000 (-0400) Subject: CHANGED: Preserve closing Heading markers X-Git-Tag: 6.0.6^2~15 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8b274587e1ed5f33c6a3ec8d94cf3323b1e7ead6;p=multimarkdown CHANGED: Preserve closing Heading markers --- 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: