Skip to content

Commit

Permalink
Don't merge multiple HTML blocks together.
Browse files Browse the repository at this point in the history
Fixes #202.
  • Loading branch information
mity committed Jan 8, 2024
1 parent 6ef3be6 commit 319631f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/md4c.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,9 @@ typedef enum MD_LINETYPE_tag MD_LINETYPE;

typedef struct MD_LINE_ANALYSIS_tag MD_LINE_ANALYSIS;
struct MD_LINE_ANALYSIS_tag {
MD_LINETYPE type : 16;
unsigned data : 16;
MD_LINETYPE type;
unsigned data;
int enforce_new_block;
OFF beg;
OFF end;
unsigned indent; /* Indentation level. */
Expand Down Expand Up @@ -5746,7 +5747,7 @@ md_line_indentation(MD_CTX* ctx, unsigned total_indent, OFF beg, OFF* p_end)
return indent - total_indent;
}

static const MD_LINE_ANALYSIS md_dummy_blank_line = { MD_LINE_BLANK, 0, 0, 0, 0 };
static const MD_LINE_ANALYSIS md_dummy_blank_line = { MD_LINE_BLANK, 0, 0, 0, 0, 0 };

/* Analyze type of the line and find some its properties. This serves as a
* main input for determining type and boundaries of a block. */
Expand All @@ -5767,6 +5768,7 @@ md_analyze_line(MD_CTX* ctx, OFF beg, OFF* p_end,
line->indent = md_line_indentation(ctx, total_indent, off, &off);
total_indent += line->indent;
line->beg = off;
line->enforce_new_block = FALSE;

/* Given the indentation and block quote marks '>', determine how many of
* the current containers are our parents. */
Expand Down Expand Up @@ -6068,6 +6070,7 @@ md_analyze_line(MD_CTX* ctx, OFF beg, OFF* p_end,
if(md_is_opening_code_fence(ctx, off, &off)) {
line->type = MD_LINE_FENCEDCODE;
line->data = 1;
line->enforce_new_block = TRUE;
break;
}
}
Expand All @@ -6089,6 +6092,7 @@ md_analyze_line(MD_CTX* ctx, OFF beg, OFF* p_end,
ctx->html_block_type = 0;
}

line->enforce_new_block = TRUE;
line->type = MD_LINE_HTML;
break;
}
Expand Down Expand Up @@ -6249,6 +6253,9 @@ md_process_line(MD_CTX* ctx, const MD_LINE_ANALYSIS** p_pivot_line, MD_LINE_ANAL
return 0;
}

if(line->enforce_new_block)
MD_CHECK(md_end_current_block(ctx));

/* Some line types form block on their own. */
if(line->type == MD_LINE_HR || line->type == MD_LINE_ATXHEADER) {
MD_CHECK(md_end_current_block(ctx));
Expand Down

0 comments on commit 319631f

Please sign in to comment.