From aeb3f6e224789ef99d0c01a462d9e6a75862d3e9 Mon Sep 17 00:00:00 2001 From: Miguel Lechon Date: Tue, 9 Feb 2021 18:37:50 +0100 Subject: [PATCH] Avoid misinterpreting closing symbols inside literals. --- source/md_impl.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/source/md_impl.c b/source/md_impl.c index 11e1742..25c5cc5 100644 --- a/source/md_impl.c +++ b/source/md_impl.c @@ -1440,7 +1440,7 @@ _MD_ParseOneNode(MD_ParseCtx *ctx) // NOTE(rjf): Parse the comment preceding this node. MD_String8 comment_before = {0}; { - MD_Token comment_token = {0}; + MD_Token comment_token = MD_ZeroToken(); for(;;) { MD_Token token = MD_Parse_PeekSkipSome(ctx, 0); @@ -1548,7 +1548,7 @@ _MD_ParseOneNode(MD_ParseCtx *ctx) // NOTE(rjf): Parse comments after nodes. MD_String8 comment_after = {0}; { - MD_Token comment_token = {0}; + MD_Token comment_token = MD_ZeroToken(); for(;;) { MD_Token token = MD_Parse_PeekSkipSome(ctx, 0); @@ -1649,9 +1649,10 @@ _MD_ParseSet(MD_ParseCtx *ctx, MD_Node *parent, _MD_ParseSetFlags flags, else { MD_Token peek = MD_Parse_PeekSkipSome(ctx, MD_TokenGroup_Whitespace | MD_TokenGroup_Comment); - if(MD_Parse_TokenMatch(peek, MD_S8Lit("}"), 0) || - MD_Parse_TokenMatch(peek, MD_S8Lit(")"), 0) || - MD_Parse_TokenMatch(peek, MD_S8Lit("]"), 0)) + if(peek.kind == MD_TokenKind_Symbol && + (MD_Parse_TokenMatch(peek, MD_S8Lit("}"), 0) || + MD_Parse_TokenMatch(peek, MD_S8Lit(")"), 0) || + MD_Parse_TokenMatch(peek, MD_S8Lit("]"), 0))) { goto end_parse; }