Skip to content

Commit e746b9b

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents c7f6b9f + d630d6a commit e746b9b

3 files changed

Lines changed: 35 additions & 1 deletion

File tree

flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/formatter/FormatterModifiedAST.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,4 +242,36 @@ public void test_LinkText() throws Exception {
242242
//System.out.println("\n\nFormatted\n");
243243
//System.out.println(formatted);
244244
}
245+
246+
@Test
247+
public void test_CRLFInFencedCodeBlock() throws Exception {
248+
249+
final String input =
250+
"following sample:\n" +
251+
"\n" +
252+
"```xml\n" +
253+
"<dependency>\r\n" +
254+
" <groupId>com.vladsch.flexmark</groupId>\r\n" +
255+
" <artifactId>flexmark-all</artifactId>\r\n" +
256+
" <version>0.60.2</version>\r\n" +
257+
"</dependency>\r\n" +
258+
"```\n\n";
259+
260+
final String expected =
261+
"following sample:\n" +
262+
"\n" +
263+
"```xml\n" +
264+
"<dependency>\r\n" +
265+
" <groupId>com.vladsch.flexmark</groupId>\r\n" +
266+
" <artifactId>flexmark-all</artifactId>\r\n" +
267+
" <version>0.60.2</version>\r\n" +
268+
"</dependency>\r\n" +
269+
"```\n\n";
270+
271+
Node document = PARSER.parse(input);
272+
273+
String formatted = RENDERER.render(document);
274+
275+
assertEquals(expected,formatted);
276+
}
245277
}

flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/LineAppendableImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,8 @@ private LineInfo getLineRange(int start, int end, CharSequence prefix) {
318318
assert start <= end;
319319

320320
CharSequence sequence = appendable.toSequence();
321-
CharSequence text = start == Range.NULL.getStart() && end == Range.NULL.getEnd() ? BasedSequence.NULL : sequence.subSequence(start, end);
321+
CharSequence text = start == Range.NULL.getStart() && end == Range.NULL.getEnd() ? BasedSequence.NULL :
322+
(end - start) > 0 && sequence.charAt(end - 1) == '\r' ? sequence.subSequence(start, end - 1) : sequence.subSequence(start, end);
322323
CharSequence eol = trimmedEOL(sequence);
323324

324325
if (eol == null || eol.length() == 0) {

flexmark-util/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
<dependency>
7272
<groupId>junit</groupId>
7373
<artifactId>junit</artifactId>
74+
<scope>test</scope>
7475
</dependency>
7576
<dependency>
7677
<groupId>org.jetbrains</groupId>

0 commit comments

Comments
 (0)