From cb66b97a56213753532a4809cbd80fe0c5a339ad Mon Sep 17 00:00:00 2001 From: "Fletcher T. Penney" Date: Mon, 3 Jul 2017 07:47:14 -0400 Subject: [PATCH] UPDATED: Update parser to track headers, even in compatibility mode --- Sources/libMultiMarkdown/parser.c | 16 ++++++++-------- Sources/libMultiMarkdown/parser.y | 16 ++++++++-------- Sources/libMultiMarkdown/update | 5 ++++- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Sources/libMultiMarkdown/parser.c b/Sources/libMultiMarkdown/parser.c index 44ef0f4..ebcf23c 100644 --- a/Sources/libMultiMarkdown/parser.c +++ b/Sources/libMultiMarkdown/parser.c @@ -1199,27 +1199,27 @@ static void yy_reduce( yymsp[0].minor.yy0 = yylhsminor.yy0; break; case 3: /* block ::= LINE_ATX_1 */ -{ yylhsminor.yy0 = token_new_parent(yymsp[0].minor.yy0, BLOCK_H1); if (!(engine->extensions & EXT_NO_LABELS)) stack_push(engine->header_stack, yylhsminor.yy0); } +{ yylhsminor.yy0 = token_new_parent(yymsp[0].minor.yy0, BLOCK_H1); stack_push(engine->header_stack, yylhsminor.yy0); } yymsp[0].minor.yy0 = yylhsminor.yy0; break; case 4: /* block ::= LINE_ATX_2 */ -{ yylhsminor.yy0 = token_new_parent(yymsp[0].minor.yy0, BLOCK_H2); if (!(engine->extensions & EXT_NO_LABELS)) stack_push(engine->header_stack, yylhsminor.yy0); } +{ yylhsminor.yy0 = token_new_parent(yymsp[0].minor.yy0, BLOCK_H2); stack_push(engine->header_stack, yylhsminor.yy0); } yymsp[0].minor.yy0 = yylhsminor.yy0; break; case 5: /* block ::= LINE_ATX_3 */ -{ yylhsminor.yy0 = token_new_parent(yymsp[0].minor.yy0, BLOCK_H3); if (!(engine->extensions & EXT_NO_LABELS)) stack_push(engine->header_stack, yylhsminor.yy0); } +{ yylhsminor.yy0 = token_new_parent(yymsp[0].minor.yy0, BLOCK_H3); stack_push(engine->header_stack, yylhsminor.yy0); } yymsp[0].minor.yy0 = yylhsminor.yy0; break; case 6: /* block ::= LINE_ATX_4 */ -{ yylhsminor.yy0 = token_new_parent(yymsp[0].minor.yy0, BLOCK_H4); if (!(engine->extensions & EXT_NO_LABELS)) stack_push(engine->header_stack, yylhsminor.yy0); } +{ yylhsminor.yy0 = token_new_parent(yymsp[0].minor.yy0, BLOCK_H4); stack_push(engine->header_stack, yylhsminor.yy0); } yymsp[0].minor.yy0 = yylhsminor.yy0; break; case 7: /* block ::= LINE_ATX_5 */ -{ yylhsminor.yy0 = token_new_parent(yymsp[0].minor.yy0, BLOCK_H5); if (!(engine->extensions & EXT_NO_LABELS)) stack_push(engine->header_stack, yylhsminor.yy0); } +{ yylhsminor.yy0 = token_new_parent(yymsp[0].minor.yy0, BLOCK_H5); stack_push(engine->header_stack, yylhsminor.yy0); } yymsp[0].minor.yy0 = yylhsminor.yy0; break; case 8: /* block ::= LINE_ATX_6 */ -{ yylhsminor.yy0 = token_new_parent(yymsp[0].minor.yy0, BLOCK_H6); if (!(engine->extensions & EXT_NO_LABELS)) stack_push(engine->header_stack, yylhsminor.yy0); } +{ yylhsminor.yy0 = token_new_parent(yymsp[0].minor.yy0, BLOCK_H6); stack_push(engine->header_stack, yylhsminor.yy0); } yymsp[0].minor.yy0 = yylhsminor.yy0; break; case 9: /* block ::= LINE_HR */ @@ -1292,11 +1292,11 @@ static void yy_reduce( yymsp[0].minor.yy0 = yylhsminor.yy0; break; case 27: /* block ::= setext_1 */ -{ yylhsminor.yy0 = token_new_parent(yymsp[0].minor.yy0, BLOCK_SETEXT_1); if (!(engine->extensions & EXT_NO_LABELS)) stack_push(engine->header_stack, yylhsminor.yy0); } +{ yylhsminor.yy0 = token_new_parent(yymsp[0].minor.yy0, BLOCK_SETEXT_1); stack_push(engine->header_stack, yylhsminor.yy0); } yymsp[0].minor.yy0 = yylhsminor.yy0; break; case 28: /* block ::= setext_2 */ -{ yylhsminor.yy0 = token_new_parent(yymsp[0].minor.yy0, BLOCK_SETEXT_2); if (!(engine->extensions & EXT_NO_LABELS)) stack_push(engine->header_stack, yylhsminor.yy0); } +{ yylhsminor.yy0 = token_new_parent(yymsp[0].minor.yy0, BLOCK_SETEXT_2); stack_push(engine->header_stack, yylhsminor.yy0); } yymsp[0].minor.yy0 = yylhsminor.yy0; break; case 29: /* block ::= table */ diff --git a/Sources/libMultiMarkdown/parser.y b/Sources/libMultiMarkdown/parser.y index 710e8e2..b152601 100644 --- a/Sources/libMultiMarkdown/parser.y +++ b/Sources/libMultiMarkdown/parser.y @@ -103,12 +103,12 @@ blocks(A) ::= block(B). // Single line blocks -block(A) ::= LINE_ATX_1(B). { A = token_new_parent(B, BLOCK_H1); if (!(engine->extensions & EXT_NO_LABELS)) stack_push(engine->header_stack, A); } -block(A) ::= LINE_ATX_2(B). { A = token_new_parent(B, BLOCK_H2); if (!(engine->extensions & EXT_NO_LABELS)) stack_push(engine->header_stack, A); } -block(A) ::= LINE_ATX_3(B). { A = token_new_parent(B, BLOCK_H3); if (!(engine->extensions & EXT_NO_LABELS)) stack_push(engine->header_stack, A); } -block(A) ::= LINE_ATX_4(B). { A = token_new_parent(B, BLOCK_H4); if (!(engine->extensions & EXT_NO_LABELS)) stack_push(engine->header_stack, A); } -block(A) ::= LINE_ATX_5(B). { A = token_new_parent(B, BLOCK_H5); if (!(engine->extensions & EXT_NO_LABELS)) stack_push(engine->header_stack, A); } -block(A) ::= LINE_ATX_6(B). { A = token_new_parent(B, BLOCK_H6); if (!(engine->extensions & EXT_NO_LABELS)) stack_push(engine->header_stack, A); } +block(A) ::= LINE_ATX_1(B). { A = token_new_parent(B, BLOCK_H1); stack_push(engine->header_stack, A); } +block(A) ::= LINE_ATX_2(B). { A = token_new_parent(B, BLOCK_H2); stack_push(engine->header_stack, A); } +block(A) ::= LINE_ATX_3(B). { A = token_new_parent(B, BLOCK_H3); stack_push(engine->header_stack, A); } +block(A) ::= LINE_ATX_4(B). { A = token_new_parent(B, BLOCK_H4); stack_push(engine->header_stack, A); } +block(A) ::= LINE_ATX_5(B). { A = token_new_parent(B, BLOCK_H5); stack_push(engine->header_stack, A); } +block(A) ::= LINE_ATX_6(B). { A = token_new_parent(B, BLOCK_H6); stack_push(engine->header_stack, A); } block(A) ::= LINE_HR(B). { A = token_new_parent(B, BLOCK_HR); } @@ -133,8 +133,8 @@ block(A) ::= list_bullet(B). { A = token_new_parent(B, BLOCK_LIST_BULLETED); block(A) ::= list_enum(B). { A = token_new_parent(B, BLOCK_LIST_ENUMERATED); is_list_loose(A); } block(A) ::= meta_block(B). { A = token_new_parent(B, BLOCK_META); } block(A) ::= para(B). { A = token_new_parent(B, BLOCK_PARA); is_para_html(engine, A); } -block(A) ::= setext_1(B). { A = token_new_parent(B, BLOCK_SETEXT_1); if (!(engine->extensions & EXT_NO_LABELS)) stack_push(engine->header_stack, A); } -block(A) ::= setext_2(B). { A = token_new_parent(B, BLOCK_SETEXT_2); if (!(engine->extensions & EXT_NO_LABELS)) stack_push(engine->header_stack, A); } +block(A) ::= setext_1(B). { A = token_new_parent(B, BLOCK_SETEXT_1); stack_push(engine->header_stack, A); } +block(A) ::= setext_2(B). { A = token_new_parent(B, BLOCK_SETEXT_2); stack_push(engine->header_stack, A); } block(A) ::= table(B). { A = token_new_parent(B, BLOCK_TABLE); stack_push(engine->table_stack, A); } diff --git a/Sources/libMultiMarkdown/update b/Sources/libMultiMarkdown/update index 335108f..65a0d98 100755 --- a/Sources/libMultiMarkdown/update +++ b/Sources/libMultiMarkdown/update @@ -8,4 +8,7 @@ re2c -i -8 lexer.re > lexer.c re2c -i -8 scanners.re > scanners.c -lemon -l parser.y +# It seems that some other versions of lemon don't create valid +# parsers?? Using the version included here works +# lemon -l parser.y +../../lemon/build/lemon -l parser.y -- 2.40.0