From 1f2618ea6c3460afb7cf6d7bc97b3dc638248bc8 Mon Sep 17 00:00:00 2001 From: Vladimir Schneider Date: Wed, 29 Apr 2020 16:38:19 -0400 Subject: [PATCH] fix for #407 --- VERSION-TODO.md | 8 +++ VERSION.md | 8 +++ .../test/resources/core_issues_ast_spec.md | 70 ++++++++++++++++++- .../parser/internal/InlineParserImpl.java | 2 +- 4 files changed, 86 insertions(+), 2 deletions(-) diff --git a/VERSION-TODO.md b/VERSION-TODO.md index aa20d53621..e96061d10b 100644 --- a/VERSION-TODO.md +++ b/VERSION-TODO.md @@ -7,6 +7,7 @@ - [Release 0.60.0](#release-0600) - [API Refactoring](#api-refactoring) - [Next 0.61.xx](#next-061xx) +- [0.61.22](#06122) - [0.61.20](#06120) - [0.61.18](#06118) - [0.61.16](#06116) @@ -222,6 +223,11 @@ Please give feedback on the upcoming changes if you have concerns about breaking * [ ] Fix: Html converter to not add spaces between end of inline marker and next punctuation: `.,:;` +## 0.61.22 + +* Fix: [#407, Link text inline content fails to parse image references], link and image refs in + link text would be collapsed even when they are not tentative but defined. + ## 0.61.20 * Fix: `JekyllTagExtension` handling of inline include tag. If included file contains a single @@ -2452,4 +2458,6 @@ Please give feedback on the upcoming changes if you have concerns about breaking [migrate flexmark-java 0_40_x to 0_42_0]: https://github.com/vsch/flexmark-java/blob/master/assets/migrations/migrate%20flexmark-java%200_40_x%20to%200_42_0.xml [migrate flexmark-java 0_42_x to 0_50_0.xml]: https://github.com/vsch/flexmark-java/blob/master/assets/migrations/migrate%20flexmark-java%200_42_x%20to%200_50_0.xml +[#407, Link text inline content fails to parse image references]: https://github.com/vsch/flexmark-java/issues/407 + diff --git a/VERSION.md b/VERSION.md index 413d35f2cc..1b3099fcc1 100644 --- a/VERSION.md +++ b/VERSION.md @@ -6,6 +6,7 @@ - [Release 0.60.0](#release-0600) - [API Refactoring](#api-refactoring) +- [0.61.22](#06122) - [0.61.20](#06120) - [0.61.18](#06118) - [0.61.16](#06116) @@ -166,6 +167,11 @@ Please give feedback on the upcoming changes if you have concerns about breaking * `com.vladsch.flexmark.util.ast.NodeAdaptingVisitHandler` * `com.vladsch.flexmark.util.ast.NodeAdaptingVisitor` +## 0.61.22 + +* Fix: [#407, Link text inline content fails to parse image references], link and image refs in + link text would be collapsed even when they are not tentative but defined. + ## 0.61.20 * Fix: `JekyllTagExtension` handling of inline include tag. If included file contains a single @@ -2045,3 +2051,5 @@ Please give feedback on the upcoming changes if you have concerns about breaking [#398, Autolinks get cut off if they contain \`&\` (escaped query params)]: https://github.com/vsch/flexmark-java/issues/398 + +[#407, Link text inline content fails to parse image references]: https://github.com/vsch/flexmark-java/issues/407 diff --git a/flexmark-core-test/src/test/resources/core_issues_ast_spec.md b/flexmark-core-test/src/test/resources/core_issues_ast_spec.md index 4bb818800f..0e6255a51f 100644 --- a/flexmark-core-test/src/test/resources/core_issues_ast_spec.md +++ b/flexmark-core-test/src/test/resources/core_issues_ast_spec.md @@ -1283,7 +1283,7 @@ Issue #384, Install Kurento Media server
- It should be run under same user as OM +→It should be run under same user as OM
## Specify/Install Turn server @@ -1323,6 +1323,74 @@ Document[0, 474] ```````````````````````````````` +### 407 + +Issue #487 + +Wrong syntax + +```````````````````````````````` example Core Issues Tests - 407: 1 +[![][moon]](/uri) + +[moon]: moon.jpg +. +

+. +Document[0, 35] + Paragraph[0, 18] isTrailingBlankLine + Link[0, 17] textOpen:[0, 1, "["] text:[1, 10, "![][moon]"] textClose:[10, 11, "]"] linkOpen:[11, 12, "("] url:[12, 16, "/uri"] pageRef:[12, 16, "/uri"] linkClose:[16, 17, ")"] + ImageRef[1, 10] textOpen:[1, 3, "!["] text:[3, 3] textClose:[3, 4, "]"] referenceOpen:[4, 5, "["] reference:[5, 9, "moon"] referenceClose:[9, 10, "]"] + Reference[19, 35] refOpen:[19, 20, "["] ref:[20, 24, "moon"] refClose:[24, 26, "]:"] url:[27, 35, "moon.jpg"] +```````````````````````````````` + + +```````````````````````````````` example Core Issues Tests - 407: 2 +[![moon]](/uri) + +[moon]: moon.jpg +. +

moon

+. +Document[0, 33] + Paragraph[0, 16] isTrailingBlankLine + Link[0, 15] textOpen:[0, 1, "["] text:[1, 8, "![moon]"] textClose:[8, 9, "]"] linkOpen:[9, 10, "("] url:[10, 14, "/uri"] pageRef:[10, 14, "/uri"] linkClose:[14, 15, ")"] + ImageRef[1, 8] referenceOpen:[1, 3, "!["] reference:[3, 7, "moon"] referenceClose:[7, 8, "]"] + Text[3, 7] chars:[3, 7, "moon"] + Reference[17, 33] refOpen:[17, 18, "["] ref:[18, 22, "moon"] refClose:[22, 24, "]:"] url:[25, 33, "moon.jpg"] +```````````````````````````````` + + +```````````````````````````````` example Core Issues Tests - 407: 3 +[![moon][]](/uri) + +[moon]: moon.jpg +. +

moon

+. +Document[0, 35] + Paragraph[0, 18] isTrailingBlankLine + Link[0, 17] textOpen:[0, 1, "["] text:[1, 10, "![moon][]"] textClose:[10, 11, "]"] linkOpen:[11, 12, "("] url:[12, 16, "/uri"] pageRef:[12, 16, "/uri"] linkClose:[16, 17, ")"] + ImageRef[1, 10] referenceOpen:[1, 3, "!["] reference:[3, 7, "moon"] referenceClose:[7, 8, "]"] textOpen:[8, 9, "["] textClose:[9, 10, "]"] + Text[3, 7] chars:[3, 7, "moon"] + Reference[19, 35] refOpen:[19, 20, "["] ref:[20, 24, "moon"] refClose:[24, 26, "]:"] url:[27, 35, "moon.jpg"] +```````````````````````````````` + + +```````````````````````````````` example Core Issues Tests - 407: 4 +![moon] + +[moon]: moon.jpg +. +

moon

+. +Document[0, 25] + Paragraph[0, 8] isTrailingBlankLine + ImageRef[0, 7] referenceOpen:[0, 2, "!["] reference:[2, 6, "moon"] referenceClose:[6, 7, "]"] + Text[2, 6] chars:[2, 6, "moon"] + Reference[9, 25] refOpen:[9, 10, "["] ref:[10, 14, "moon"] refClose:[14, 16, "]:"] url:[17, 25, "moon.jpg"] +```````````````````````````````` + + ## Issues xxx ### 1 diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/internal/InlineParserImpl.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/internal/InlineParserImpl.java index 79623b7cca..2e241e7537 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/internal/InlineParserImpl.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/internal/InlineParserImpl.java @@ -1083,7 +1083,7 @@ protected boolean parseCloseBracket() { // collapse any link refs contained in this link, they are duds, link takes precedence // TODO: add a test to see if all link refs should be collapsed or just undefined ones - collapseLinkRefChildren(insertNode, null, true); + collapseLinkRefChildren(insertNode, true, true); } else if (insertNode instanceof RefNode) { // have a link ref, collapse to text any tentative ones contained in it, they are duds collapseLinkRefChildren(insertNode, true, true);