diff --git a/service/src/main/java/skills/services/CustomValidator.groovy b/service/src/main/java/skills/services/CustomValidator.groovy index 3615e92a83..f02819b9a9 100644 --- a/service/src/main/java/skills/services/CustomValidator.groovy +++ b/service/src/main/java/skills/services/CustomValidator.groovy @@ -82,6 +82,7 @@ class CustomValidator { private static final Pattern TABLE_FIX = ~/(?m)(^\n)(^[|].+[|]$\n^[|].*[-]{3,}.*[|]$)/ private static final Pattern CODEBLOCK_FIX = ~/(?m)(^\n)(^[`]{3}$)/ private static final Pattern LIST_FIX = ~/(?m)(^\n)(\s*\d\. |\* |- .*$)/ + private static final Pattern HEADING_FIX = ~/(?m)([(].+[)].*$)\n(\n.*$)/ @PostConstruct CustomValidator init() { @@ -249,6 +250,7 @@ class CustomValidator { toValidate = TABLE_FIX.matcher(toValidate).replaceAll('$2') toValidate = CODEBLOCK_FIX.matcher(toValidate).replaceAll('$2') toValidate = LIST_FIX.matcher(toValidate).replaceAll('$2') + toValidate = HEADING_FIX.matcher(toValidate).replaceAll('$1$2') // remove two+ newlines from codeblocks so we do not split StringBuilder out = new StringBuilder() diff --git a/service/src/test/java/skills/services/CustomValidatorSpec.groovy b/service/src/test/java/skills/services/CustomValidatorSpec.groovy index b3a74f9472..a4756cd0db 100644 --- a/service/src/test/java/skills/services/CustomValidatorSpec.groovy +++ b/service/src/test/java/skills/services/CustomValidatorSpec.groovy @@ -679,6 +679,27 @@ if (a == true) { validator.init() then: + + //FAILS + validator.validateDescription("""(A)\n\n| (A) this is some text | (A) this is some text |""").valid + + // BREAKS also + validator.validateDescription("""(A)\n\n Column1  | Column2  | Column3  | Column4  | Column5  | Column6  | Column7  | Column8  | Column9  | +| -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | +| eafe  |   |   |   |   |   |   |   |   | +|   | eafe  |   |   |   |   |   |   |   | +|   |   |   | eafe  |   |   |   |   |   | +|   |   |   | eafe  |   |   |   |   |   | +|   |   |   |   |   | eafe  |   |   |   | +|   |   |   |   |   |   |   |   |   | +|   |   |   |   |   |   |   |   | eafe  | +""" + validator.validateDescription(test).valid + validator.validateDescription("""(A) this is some normal text (A) cool, not cools""").valid