Skip to content

Commit

Permalink
#2564 - replace double new lines following a paren heading with a sin…
Browse files Browse the repository at this point in the history
…gle newline
  • Loading branch information
rmmayo committed Jun 4, 2024
1 parent dc344e3 commit a242ad1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions service/src/main/java/skills/services/CustomValidator.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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()
Expand Down
Loading

0 comments on commit a242ad1

Please sign in to comment.