Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,34 @@ class Foo {
formatSource(input, expected);
}

public void testMarkdownFencedCodeBlock2() throws JavaModelException {
setComplianceLevel(CompilerOptions.VERSION_23);
String input = """
/// A markdown comment, with a codeblock.
/// ```java
/// void foo() {
///
/// System.out.println("Hello, World!"); // 2 spaces indented
///
/// }
/// ```
class Foo { }
""";
String expected = """
/// A markdown comment, with a codeblock.
/// ```java
/// void foo() {
///
/// System.out.println("Hello, World!"); // 2 spaces indented
///
/// }
/// ```
class Foo {
}
""";
formatSource(input, expected);
}

public void testMarkdownFencedCodeBlockWithTilde() throws JavaModelException {
setComplianceLevel(CompilerOptions.VERSION_23);
String input = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1691,7 +1691,8 @@ private void getCodeToFormat(int startPos, int endPos, StringBuilder sb, int[] p
if (c == '*')
lineStart = (this.ctm.charAt(i + 1) == ' ') ? i + 2 : i + 1;
if (c == '/' && isMarkdown)
lineStart = ((this.ctm.charAt(i + 1) == '/') && (this.ctm.charAt(i + 2) == '/')) ? i + 4
lineStart = ((this.ctm.charAt(i + 1) == '/') && (this.ctm.charAt(i + 2) == '/'))
? (this.ctm.charAt(i + 3) == ' ' ? i + 4 : i + 3)
: i + 1;
break;
}
Expand Down
Loading