Skip to content

Commit d8a76e5

Browse files
committed
fix to not wrap multiline URL images
1 parent c36ff2b commit d8a76e5

File tree

17 files changed

+659
-126
lines changed

17 files changed

+659
-126
lines changed

VERSION-TODO.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,17 @@ Please give feedback on the upcoming changes if you have concerns about breaking
221221

222222
* Fix: add more information to `MarkdownParagraph.resolveTrackedOffsetsEdit` assert failures to
223223
allow better diagnostics in reported stack traces.
224+
* Fix: disable wrapping of multiline URL image links
225+
* Fix: `Paragraph` content node to preserve leading spaces on lines. Otherwise, multiline URL
226+
image content would loose indents since these were stripped from paragraph content during
227+
parsing.
228+
* Fix: `TablesExtension` to accept non-indenting leading spaces on all table rows. This
229+
results in previously non-table text as valid table texts:
230+
231+
```markdown
232+
Abc|Def
233+
|---|---
234+
```
224235

225236
## 0.61.4
226237

flexmark-core-test/src/main/java/com/vladsch/flexmark/core/test/util/FormatterTranslationSpecTestBase.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public abstract class FormatterTranslationSpecTestBase extends ComboSpecTestCase
4646
optionsMap.put("delete-space", new MutableDataSet().set(EDIT_OP, -1).set(EDIT_OP_CHAR, ' '));
4747
// optionsMap.put("indent-edit", new MutableDataSet().set(EDIT_INDENT, true));
4848
optionsMap.put("restore-tracked-spaces", new MutableDataSet().set(Formatter.RESTORE_TRACKED_SPACES, true));
49+
optionsMap.put("multi-line-image-url", new MutableDataSet().set(Parser.PARSE_MULTI_LINE_IMAGE_URLS, true));
4950

5051
optionsMap.put("format-fixed-indent", new MutableDataSet().set(Formatter.FORMATTER_EMULATION_PROFILE, ParserEmulationProfile.FIXED_INDENT));
5152
optionsMap.put("format-content-after-prefix", new MutableDataSet().set(Formatter.LISTS_ITEM_CONTENT_AFTER_SUFFIX, true));

flexmark-core-test/src/test/resources/ast_spec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12815,7 +12815,7 @@ Document[0, 14]
1281512815
Paragraph[0, 14]
1281612816
Text[0, 3] chars:[0, 3, "foo"]
1281712817
HardLineBreak[3, 5]
12818-
Text[10, 13] chars:[10, 13, "bar"]
12818+
Text[10, 13] chars:[10, 13, " bar"]
1281912819
````````````````````````````````
1282012820

1282112821

flexmark-core-test/src/test/resources/core_extra_ast_spec.md

Lines changed: 67 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4159,7 +4159,64 @@ Document[0, 59]
41594159
````````````````````````````````
41604160

41614161

4162-
```````````````````````````````` example(Multi-Line Image URL: 11) options(unmatched-fence)
4162+
encoding of embedded EOL
4163+
4164+
```````````````````````````````` example(Multi-Line Image URL: 11) options(multi-line-image-url)
4165+
![ref](/url1?
4166+
one = 1 & line
4167+
line two
4168+
) trailing text
4169+
.
4170+
<p><img src="/url1?one%20=%201%20&amp;%20line%0Aline%20two%0A" alt="ref" /> trailing text</p>
4171+
.
4172+
Document[0, 53]
4173+
Paragraph[0, 53]
4174+
Image[0, 39] textOpen:[0, 2, "!["] text:[2, 5, "ref"] textClose:[5, 6, "]"] linkOpen:[6, 7, "("] url:[7, 13, "/url1?"] pageRef:[7, 13, "/url1?"] urlContent:[14, 38, "one = 1 & line\nline two\n"] linkClose:[38, 39, ")"]
4175+
Text[2, 5] chars:[2, 5, "ref"]
4176+
Text[39, 53] chars:[39, 53, " trai … text"]
4177+
````````````````````````````````
4178+
4179+
4180+
preserve content indent
4181+
4182+
```````````````````````````````` example(Multi-Line Image URL: 12) options(multi-line-image-url)
4183+
![ref](/url1?
4184+
one = 1 & line
4185+
line two
4186+
) trailing text
4187+
.
4188+
<p><img src="/url1?%20%20%20%20one%20=%201%20&amp;%20line%0A%20%20%20%20line%20two%0A" alt="ref" /> trailing text</p>
4189+
.
4190+
Document[0, 61]
4191+
Paragraph[0, 61]
4192+
Image[0, 47] textOpen:[0, 2, "!["] text:[2, 5, "ref"] textClose:[5, 6, "]"] linkOpen:[6, 7, "("] url:[7, 13, "/url1?"] pageRef:[7, 13, "/url1?"] urlContent:[18, 46, " one = 1 & line\n line two\n"] linkClose:[46, 47, ")"]
4193+
Text[2, 5] chars:[2, 5, "ref"]
4194+
Text[47, 61] chars:[47, 61, " trai … text"]
4195+
````````````````````````````````
4196+
4197+
4198+
```````````````````````````````` example(Multi-Line Image URL: 13) options(multi-line-image-url)
4199+
> ![ref](/url1?
4200+
> one = 1 & line
4201+
> line two
4202+
> ) trailing text
4203+
.
4204+
<blockquote>
4205+
<p><img src="/url1?%20%20%20%20one%20=%201%20&amp;%20line%0A%20%20%20%20line%20two%0A" alt="ref" /> trailing text</p>
4206+
</blockquote>
4207+
.
4208+
Document[0, 69]
4209+
BlockQuote[0, 69] marker:[0, 1, ">"]
4210+
Paragraph[2, 69]
4211+
Image[2, 55] textOpen:[2, 4, "!["] text:[4, 7, "ref"] textClose:[7, 8, "]"] linkOpen:[8, 9, "("] url:[9, 15, "/url1?"] pageRef:[9, 15, "/url1?"] urlContent:[22, 52, " one = 1 & line\n line two\n"] linkClose:[54, 55, ")"]
4212+
Text[4, 7] chars:[4, 7, "ref"]
4213+
Text[55, 69] chars:[55, 69, " trai … text"]
4214+
````````````````````````````````
4215+
4216+
4217+
## Fenced Code
4218+
4219+
```````````````````````````````` example(Fenced Code: 1) options(unmatched-fence)
41634220
~~~
41644221
proper unmatched fenced code
41654222
```
@@ -4175,7 +4232,7 @@ Document[0, 36]
41754232

41764233
non empty, info, blank line follows, unmatched
41774234

4178-
```````````````````````````````` example(Multi-Line Image URL: 12) options(unmatched-fence)
4235+
```````````````````````````````` example(Fenced Code: 2) options(unmatched-fence)
41794236
```info
41804237
some text
41814238
~~~
@@ -5399,10 +5456,10 @@ lines*
53995456
Document[0, 131]
54005457
Paragraph[0, 131]
54015458
Text[0, 10] chars:[0, 10, "paragraph "]
5402-
Code[10, 23] textOpen:[10, 11, "`"] text:[11, 22, "test \nwith"] textClose:[22, 23, "`"]
5459+
Code[10, 23] textOpen:[10, 11, "`"] text:[11, 22, "test … \n with"] textClose:[22, 23, "`"]
54035460
Text[11, 16] chars:[11, 16, "test "]
54045461
SoftLineBreak[16, 17]
5405-
Text[18, 22] chars:[18, 22, "with"]
5462+
Text[18, 22] chars:[18, 22, " with"]
54065463
Text[23, 45] chars:[23, 45, " mult … lines"]
54075464
SoftLineBreak[45, 46]
54085465
Text[46, 56] chars:[46, 56, "paragraph "]
@@ -5411,7 +5468,7 @@ Document[0, 131]
54115468
SoftLineBreak[61, 62]
54125469
Text[62, 66] chars:[62, 66, "with"]
54135470
Text[67, 82] chars:[67, 82, " mult … lazy "]
5414-
StrongEmphasis[82, 97] textOpen:[82, 84, "**"] text:[84, 95, "lines\nall"] textClose:[95, 97, "**"]
5471+
StrongEmphasis[82, 97] textOpen:[82, 84, "**"] text:[84, 95, "lines\n all"] textClose:[95, 97, "**"]
54155472
Text[84, 89] chars:[84, 89, "lines"]
54165473
SoftLineBreak[89, 90]
54175474
Text[92, 95] chars:[92, 95, "all"]
@@ -5439,10 +5496,10 @@ lines*
54395496
Document[0, 131]
54405497
Paragraph[0, 131]
54415498
Text[0, 10] chars:[0, 10, "paragraph "]
5442-
Code[10, 23] textOpen:[10, 11, "`"] text:[11, 22, "test \nwith"] textClose:[22, 23, "`"]
5499+
Code[10, 23] textOpen:[10, 11, "`"] text:[11, 22, "test … \n with"] textClose:[22, 23, "`"]
54435500
Text[11, 16] chars:[11, 16, "test "]
54445501
SoftLineBreak[16, 17]
5445-
Text[18, 22] chars:[18, 22, "with"]
5502+
Text[18, 22] chars:[18, 22, " with"]
54465503
Text[23, 45] chars:[23, 45, " mult … lines"]
54475504
SoftLineBreak[45, 46]
54485505
Text[46, 56] chars:[46, 56, "paragraph "]
@@ -5451,7 +5508,7 @@ Document[0, 131]
54515508
SoftLineBreak[61, 62]
54525509
Text[62, 66] chars:[62, 66, "with"]
54535510
Text[67, 82] chars:[67, 82, " mult … lazy "]
5454-
StrongEmphasis[82, 97] textOpen:[82, 84, "**"] text:[84, 95, "lines\nall"] textClose:[95, 97, "**"]
5511+
StrongEmphasis[82, 97] textOpen:[82, 84, "**"] text:[84, 95, "lines\n all"] textClose:[95, 97, "**"]
54555512
Text[84, 89] chars:[84, 89, "lines"]
54565513
SoftLineBreak[89, 90]
54575514
Text[92, 95] chars:[92, 95, "all"]
@@ -6830,9 +6887,9 @@ Document[0, 20]
68306887
.
68316888
Document[0, 31]
68326889
Paragraph[0, 31]
6833-
Link[0, 31] textOpen:[0, 1, "["] text:[1, 23, "hello **bold\nworld**"] textClose:[23, 24, "]"] linkOpen:[24, 25, "("] url:[25, 30, "#test"] pageRef:[25, 25] anchorMarker:[25, 26, "#"] anchorRef:[26, 30, "test"] linkClose:[30, 31, ")"]
6890+
Link[0, 31] textOpen:[0, 1, "["] text:[1, 23, "hello **bold\n world**"] textClose:[23, 24, "]"] linkOpen:[24, 25, "("] url:[25, 30, "#test"] pageRef:[25, 25] anchorMarker:[25, 26, "#"] anchorRef:[26, 30, "test"] linkClose:[30, 31, ")"]
68346891
Text[1, 7] chars:[1, 7, "hello "]
6835-
StrongEmphasis[7, 23] textOpen:[7, 9, "**"] text:[9, 21, "bold\nworld"] textClose:[21, 23, "**"]
6892+
StrongEmphasis[7, 23] textOpen:[7, 9, "**"] text:[9, 21, "bold\n world"] textClose:[21, 23, "**"]
68366893
Text[9, 13] chars:[9, 13, "bold"]
68376894
SoftLineBreak[13, 14]
68386895
Text[16, 21] chars:[16, 21, "world"]

flexmark-core-test/src/test/resources/core_wrapping_spec.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,124 @@ BasedSegmentBuilder{[0, 133), s=4:6, u=9:11, t=9:11, l=138, sz=22, na=17: [0, 27
365365
````````````````````````````````
366366

367367

368+
### Images
369+
370+
371+
```````````````````````````````` example(Wrap - Images: 1) options(margin[72], multi-line-image-url, show-ranges)
372+
![alt](http://g.gravizo.com/g?
373+
digraph G {
374+
aize ="4,4";
375+
main [shape=box];
376+
main -> parse [weight=8];
377+
parse -> execute;
378+
main -> init [style=dotted];
379+
main -> testing [style=dashed];
380+
testing -> make_string;
381+
main -> cleanupMore;
382+
execute -> { make_string; printf }
383+
init -> make_string;
384+
edge [color=red];
385+
main -> printf [style=bold,label="100 times"];
386+
make_string [label="make a string"];
387+
node [shape=box,style=fill≤ed,color=".7 .3 1.0"];
388+
execute -> compares;
389+
}
390+
"title works three!!!")
391+
.
392+
![alt](http://g.gravizo.com/g?
393+
digraph G {
394+
aize ="4,4";
395+
main [shape=box];
396+
main -> parse [weight=8];
397+
parse -> execute;
398+
main -> init [style=dotted];
399+
main -> testing [style=dashed];
400+
testing -> make_string;
401+
main -> cleanupMore;
402+
execute -> { make_string; printf }
403+
init -> make_string;
404+
edge [color=red];
405+
main -> printf [style=bold,label="100 times"];
406+
make_string [label="make a string"];
407+
node [shape=box,style=fill≤ed,color=".7 .3 1.0"];
408+
execute -> compares;
409+
}
410+
"title works three!!!")
411+
---- Ranges ------------------------------------------------------------
412+
⟦![alt](http://g.gravizo.com/g?
413+
digraph G {
414+
aize ="4,4";
415+
main [shape=box];
416+
main -> parse [weight=8];
417+
parse -> execute;
418+
main -> init [style=dotted];
419+
main -> testing [style=dashed];
420+
testing -> make_string;
421+
main -> cleanupMore;
422+
execute -> { make_string; printf }
423+
init -> make_string;
424+
edge [color=red];
425+
main -> printf [style=bold,label="100 times"];
426+
make_string [label="make a string"];
427+
node [shape=box,style=fill≤ed,color=".7 .3 1.0"];
428+
execute -> compares;
429+
}
430+
"title works three!!!")⟧
431+
⟦⟧
432+
---- Segments ----------------------------------------------------------
433+
BasedSegmentBuilder{[0, 538), s=0:0, u=1:1, t=1:1, l=539, sz=3, na=2: [0, 538), a:'\n', [538) }
434+
.
435+
Document[0, 538]
436+
Paragraph[0, 538]
437+
Image[0, 538] textOpen:[0, 2, "!["] text:[2, 5, "alt"] textClose:[5, 6, "]"] linkOpen:[6, 7, "("] url:[7, 30, "http://g.gravizo.com/g?"] pageRef:[7, 30, "http://g.gravizo.com/g?"] urlContent:[31, 515, "digraph G {\n aize =\"4,4\";\n main [shape=box];\n main -> parse [weight=8];\n parse -> execute;\n main -> init [style=dotted];\n main -> testing [style=dashed];\n testing -> make_string;\n main -> cleanupMore;\n execute -> { make_string; printf }\n init -> make_string;\n edge [color=red];\n main -> printf [style=bold,label=\"100 times\"];\n make_string [label=\"make a string\"];\n node [shape=box,style=fill≤ed,color=\".7 .3 1.0\"];\n execute -> compares;\n}\n"] titleOpen:[515, 516, "\""] title:[516, 536, "title works three!!!"] titleClose:[536, 537, "\""] linkClose:[537, 538, ")"]
438+
Text[2, 5] chars:[2, 5, "alt"]
439+
````````````````````````````````
440+
441+
442+
```````````````````````````````` example(Wrap - Images: 2) options(margin[72], multi-line-image-url)
443+
> ![alt](http://g.gravizo.com/g?
444+
> digraph G {
445+
> aize ="4,4";
446+
> main [shape=box];
447+
> main -> parse [weight=8];
448+
> parse -> execute;
449+
> main -> init [style=dotted];
450+
> main -> testing [style=dashed];
451+
> testing -> make_string;
452+
> main -> cleanupMore;
453+
> execute -> { make_string; printf }
454+
> init -> make_string;
455+
> edge [color=red];
456+
> main -> printf [style=bold,label="100 times"];
457+
> make_string [label="make a string"];
458+
> node [shape=box,style=fill≤ed,color=".7 .3 1.0"];
459+
> execute -> compares;
460+
> }
461+
> "title works three!!!")
462+
.
463+
> ![alt](http://g.gravizo.com/g?
464+
> digraph G {
465+
> aize ="4,4";
466+
> main [shape=box];
467+
> main -> parse [weight=8];
468+
> parse -> execute;
469+
> main -> init [style=dotted];
470+
> main -> testing [style=dashed];
471+
> testing -> make_string;
472+
> main -> cleanupMore;
473+
> execute -> { make_string; printf }
474+
> init -> make_string;
475+
> edge [color=red];
476+
> main -> printf [style=bold,label="100 times"];
477+
> make_string [label="make a string"];
478+
> node [shape=box,style=fill≤ed,color=".7 .3 1.0"];
479+
> execute -> compares;
480+
> }
481+
> "title works three!!!")
482+
483+
````````````````````````````````
484+
485+
368486
### Delete Indent
369487

370488
delete space to previous non-blank

flexmark-ext-footnotes/flexmark-ext-footnotes.iml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@
2626
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
2727
<orderEntry type="module" module-name="flexmark-core-test" scope="TEST" />
2828
<orderEntry type="library" name="org.jetbrains:annotations" level="project" />
29+
<orderEntry type="module" module-name="flexmark-ext-tables" scope="TEST" />
2930
</component>
30-
</module>
31+
</module>

flexmark-ext-footnotes/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
<artifactId>flexmark-test-util</artifactId>
2626
<scope>test</scope>
2727
</dependency>
28+
<dependency>
29+
<groupId>com.vladsch.flexmark</groupId>
30+
<artifactId>flexmark-ext-tables</artifactId>
31+
<scope>test</scope>
32+
</dependency>
2833
<dependency>
2934
<groupId>com.vladsch.flexmark</groupId>
3035
<artifactId>flexmark-core-test</artifactId>

flexmark-ext-footnotes/src/test/java/com/vladsch/flexmark/ext/footnotes/ComboFootnotesSpecTest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.vladsch.flexmark.ext.footnotes;
22

33
import com.vladsch.flexmark.core.test.util.RendererSpecTest;
4+
import com.vladsch.flexmark.ext.tables.TablesExtension;
45
import com.vladsch.flexmark.parser.Parser;
56
import com.vladsch.flexmark.test.util.spec.ResourceLocation;
67
import com.vladsch.flexmark.test.util.spec.SpecExample;
@@ -9,16 +10,13 @@
910
import org.jetbrains.annotations.NotNull;
1011
import org.junit.runners.Parameterized;
1112

12-
import java.util.Collections;
13-
import java.util.HashMap;
14-
import java.util.List;
15-
import java.util.Map;
13+
import java.util.*;
1614

1715
public class ComboFootnotesSpecTest extends RendererSpecTest {
1816
static final String SPEC_RESOURCE = "/ext_footnotes_ast_spec.md";
1917
final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE);
2018
final private static DataHolder OPTIONS = new MutableDataSet()
21-
.set(Parser.EXTENSIONS, Collections.singleton(FootnoteExtension.create()))
19+
.set(Parser.EXTENSIONS, Arrays.asList(FootnoteExtension.create(), TablesExtension.create()))
2220
.toImmutable();
2321

2422
final private static Map<String, DataHolder> optionsMap = new HashMap<>();

0 commit comments

Comments
 (0)