Skip to content

Reproduce issue with mvn: fornatWithNewLine after flexmark over MD en… #1454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
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
@@ -248,7 +248,7 @@ private static String getSystemProperty(String name) {
return value;
}

private static String[] groupWithSteps(String group, String[] includes, String... steps) {
protected static String[] groupWithSteps(String group, String[] includes, String... steps) {
String[] result = new String[steps.length + includes.length + 2];
result[0] = "<" + group + ">";
System.arraycopy(includes, 0, result, 1, includes.length);
@@ -261,11 +261,11 @@ private static String[] groupWithSteps(String group, String... steps) {
return groupWithSteps(group, new String[]{}, steps);
}

private static String[] including(String... includes) {
protected static String[] including(String... includes) {
return groupWithSteps("includes", groupWithSteps("include", includes));
}

private static String[] formats(String... formats) {
protected static String[] formats(String... formats) {
return groupWithSteps("formats", formats);
}

Original file line number Diff line number Diff line change
@@ -15,6 +15,10 @@
*/
package com.diffplug.spotless.maven.markdown;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.junit.jupiter.api.Test;

import com.diffplug.spotless.maven.MavenIntegrationHarness;
@@ -30,4 +34,21 @@ public void testFlexmarkWithDefaultConfig() throws Exception {
assertFile("markdown_test.md").sameAsResource("markdown/flexmark/FlexmarkFormatted.md");
}


@Test
public void testFlexmarkWithDefaultConfig_endsWithCodeBlock_withNewLine() throws Exception {
List<String> configurations = new ArrayList<>();

configurations.addAll(Arrays.asList(formats(groupWithSteps("format", including("*.md"), "<endWithNewline/>"))));
configurations.addAll(Arrays.asList(groupWithSteps("markdown", including("**/*.md"), "<flexmark />")));

writePom(configurations.toArray(new String[0]));

setFile("markdown_test.md").toResource("markdown/flexmark/EndsWithCodeBlockUnformatted.md");
mavenRunner().withArguments("spotless:apply").runNoError().error();
assertFile("markdown_test.md").sameAsResource("markdown/flexmark/EndsWithCodeBlockFormattedWithNewLine.md");

mavenRunner().withArguments("spotless:check").runNoError().error();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```
someCode
```

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```
someCode
```

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```
someCode
```
Original file line number Diff line number Diff line change
@@ -29,4 +29,12 @@ void behavior() throws Exception {
"markdown/flexmark/FlexmarkUnformatted.md",
"markdown/flexmark/FlexmarkFormatted.md");
}

@Test
void endsWithcodeBlock() throws Exception {
StepHarness.forStep(FlexmarkStep.create(TestProvisioner.mavenCentral()))
.testResource(
"markdown/flexmark/EndsWithCodeBlockUnformatted.md",
"markdown/flexmark/EndsWithCodeBlockFormatted.md");
}
}