diff --git a/CHANGELOG.md b/CHANGELOG.md index c50e79dd..bf98b103 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,89 @@ +## Next release +### Generic changes + +**Merge branch 'bugfix/curly_braces_in_table_#295' into develop** + + +[761397a935fbc5b](https://github.com/bsorrentino/maven-confluence-plugin/commit/761397a935fbc5b) bsorrentino *2023-10-12 17:19:03* + +**feat: enhance escapeMarkdownText method** + + * enable fine grained escaping on markdown text + * resolve #295 + +[1157223261d86b6](https://github.com/bsorrentino/maven-confluence-plugin/commit/1157223261d86b6) bsorrentino *2023-10-12 17:17:40* + +**fix: enable escaping on TableCell** + + * working on #295 + +[ee97f605962a828](https://github.com/bsorrentino/maven-confluence-plugin/commit/ee97f605962a828) bsorrentino *2023-10-12 17:16:46* + +**test: add unit test** + + * working on #295 + +[a65b74a001e9bb5](https://github.com/bsorrentino/maven-confluence-plugin/commit/a65b74a001e9bb5) bsorrentino *2023-10-12 17:16:07* + +**Merge branch 'bugfix/relative_link_#294' into develop** + + +[3019d28e99fceff](https://github.com/bsorrentino/maven-confluence-plugin/commit/3019d28e99fceff) bsorrentino *2023-10-11 16:49:16* + +**fix: check prefix before apply** + + * check link prefix before apply it + * resolve #294 + +[c8d619ed504b8f7](https://github.com/bsorrentino/maven-confluence-plugin/commit/c8d619ed504b8f7) bsorrentino *2023-10-11 14:56:15* + +**test: add test data** + + * prepare for reproduce issue + * working #294 + +[c6550ce83a6b3d7](https://github.com/bsorrentino/maven-confluence-plugin/commit/c6550ce83a6b3d7) bsorrentino *2023-10-11 14:55:23* + +**build: move to next development version** + + +[e102f99740d02ab](https://github.com/bsorrentino/maven-confluence-plugin/commit/e102f99740d02ab) bsorrentino *2023-10-11 08:29:13* + +**refactor: remove lombok usage** + + +[5786d8cff33c956](https://github.com/bsorrentino/maven-confluence-plugin/commit/5786d8cff33c956) bsorrentino *2023-10-11 08:02:47* + +**build: move to maven 3.6.0 compatibility** + + +[14ccb9769202ef8](https://github.com/bsorrentino/maven-confluence-plugin/commit/14ccb9769202ef8) bsorrentino *2023-10-11 07:56:27* + +**Merge branch 'master' into develop** + + +[1158634c0129498](https://github.com/bsorrentino/maven-confluence-plugin/commit/1158634c0129498) bsorrentino *2023-06-26 09:07:59* + +**Merge branch 'hotfix/changelog'** + + +[e3810ee009337d4](https://github.com/bsorrentino/maven-confluence-plugin/commit/e3810ee009337d4) bsorrentino *2023-06-26 09:07:57* + +**docs(changelog.md): update** + + +[e69cb1d0ab22f21](https://github.com/bsorrentino/maven-confluence-plugin/commit/e69cb1d0ab22f21) bsorrentino *2023-06-26 09:07:31* + +**Merge tag 'v7.12' into develop** + + * new release + +[8736e5277f5d031](https://github.com/bsorrentino/maven-confluence-plugin/commit/8736e5277f5d031) bsorrentino *2023-06-26 09:05:20* + + ## v7.12 ### Generic changes diff --git a/README.md b/README.md index 68b5d428..42b9d7fb 100644 --- a/README.md +++ b/README.md @@ -28,16 +28,17 @@ For practical samples refer to folder/module [test-publishing](https://github.co ## News -| Date | Release | Info | -|------------------|-------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| **Jun 23, 2023** | [Release 7.12](https://github.com/bsorrentino/maven-confluence-plugin/releases/tag/v7.12) | Merged PR [#288](https://github.com/bsorrentino/maven-confluence-plugin/pull/288) that fix [#287](https://github.com/bsorrentino/maven-confluence-plugin/issue/287) "**Maven report generation breaks, if a new page was added with new attachments and references to it**". Thanks to [williamschey](https://github.com/williamschey) for contribution. | -| **Mar 23, 2023** | [Release 7.11](https://github.com/bsorrentino/maven-confluence-plugin/releases/tag/v7.11) | Support of Confluence `Excerpt` macro. Refer to [#285](https://github.com/bsorrentino/maven-confluence-plugin/issues/285) | -| **Mar 4, 2023** | [Release 7.10](https://github.com/bsorrentino/maven-confluence-plugin/releases/tag/v7.10) | Allow to skip html tags in markdown processing. Refer to [#284](https://github.com/bsorrentino/maven-confluence-plugin/issues/284) | -| **Jan 4, 2023** | [Release 7.9](https://github.com/bsorrentino/maven-confluence-plugin/releases/tag/v7.9) | Fix problem Problem parsing `%` character from markdown to wiki. Refer to [#282](https://github.com/bsorrentino/maven-confluence-plugin/issues/282) | -| **Dec 9, 2022** | [Release 7.8](https://github.com/bsorrentino/maven-confluence-plugin/releases/tag/v7.8) | Merged PR [#281](https://github.com/bsorrentino/maven-confluence-plugin/pull/281) that fix [#280](https://github.com/bsorrentino/maven-confluence-plugin/issue/280) "**allows specifying additional HTTP headers in the servers section of settings.xml**". Thanks to [DirkMahler](https://github.com/DirkMahler) for contribution. | -| **Jul 3, 2022** | [Release 7.7](https://github.com/bsorrentino/maven-confluence-plugin/releases/tag/v7.7) | Merged PR [#266](https://github.com/bsorrentino/maven-confluence-plugin/pull/266) "**Adding JSON Support**". Thanks to [jksevend](https://github.com/jksevend) for contribution. | -| **Jun 3, 2022** | [Release 7.6](https://github.com/bsorrentino/maven-confluence-plugin/releases/tag/v7.6) | Merged PR [#267](https://github.com/bsorrentino/maven-confluence-plugin/pull/267) "**added function to define jira instance baseurl**", that fix issue [#136](https://github.com/bsorrentino/maven-confluence-plugin/issues/136). Thanks to [tspindler](https://github.com/tspindler) for contribution. | -| **Apr 1, 2022** | [Release 7.5](https://github.com/bsorrentino/maven-confluence-plugin/releases/tag/v7.5) | Fix empty table cell not handled properly. Refer to [#264](https://github.com/bsorrentino/maven-confluence-plugin/issues/ | -| **Jan 10, 2022** | [Release 7.4](https://github.com/bsorrentino/maven-confluence-plugin/releases/tag/v7.4) | Fix problem with **encoding**. Refer to [#261](https://github.com/bsorrentino/maven-confluence-plugin/issues/261). | +| Date | Release | Info | +|------------------|-------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **Cct 12, 2023** | [Release 7.13](https://github.com/bsorrentino/maven-confluence-plugin/releases/tag/v7.13) | fix some links between markdown files point to non-existing pages [#294](https://github.com/bsorrentino/maven-confluence-plugin/issues/294). fix curly braces in table recognized as macro [#295](https://github.com/bsorrentino/maven-confluence-plugin/issues/295). | +| **Jun 23, 2023** | [Release 7.12](https://github.com/bsorrentino/maven-confluence-plugin/releases/tag/v7.12) | Merged PR [#288](https://github.com/bsorrentino/maven-confluence-plugin/pull/288) that fix [#287](https://github.com/bsorrentino/maven-confluence-plugin/issue/287) "**Maven report generation breaks, if a new page was added with new attachments and references to it**". Thanks to [williamschey](https://github.com/williamschey) for contribution. | +| **Mar 23, 2023** | [Release 7.11](https://github.com/bsorrentino/maven-confluence-plugin/releases/tag/v7.11) | Support of Confluence `Excerpt` macro. Refer to [#285](https://github.com/bsorrentino/maven-confluence-plugin/issues/285) | +| **Mar 4, 2023** | [Release 7.10](https://github.com/bsorrentino/maven-confluence-plugin/releases/tag/v7.10) | Allow to skip html tags in markdown processing. Refer to [#284](https://github.com/bsorrentino/maven-confluence-plugin/issues/284) | +| **Jan 4, 2023** | [Release 7.9](https://github.com/bsorrentino/maven-confluence-plugin/releases/tag/v7.9) | Fix problem Problem parsing `%` character from markdown to wiki. Refer to [#282](https://github.com/bsorrentino/maven-confluence-plugin/issues/282) | +| **Dec 9, 2022** | [Release 7.8](https://github.com/bsorrentino/maven-confluence-plugin/releases/tag/v7.8) | Merged PR [#281](https://github.com/bsorrentino/maven-confluence-plugin/pull/281) that fix [#280](https://github.com/bsorrentino/maven-confluence-plugin/issue/280) "**allows specifying additional HTTP headers in the servers section of settings.xml**". Thanks to [DirkMahler](https://github.com/DirkMahler) for contribution. | +| **Jul 3, 2022** | [Release 7.7](https://github.com/bsorrentino/maven-confluence-plugin/releases/tag/v7.7) | Merged PR [#266](https://github.com/bsorrentino/maven-confluence-plugin/pull/266) "**Adding JSON Support**". Thanks to [jksevend](https://github.com/jksevend) for contribution. | +| **Jun 3, 2022** | [Release 7.6](https://github.com/bsorrentino/maven-confluence-plugin/releases/tag/v7.6) | Merged PR [#267](https://github.com/bsorrentino/maven-confluence-plugin/pull/267) "**added function to define jira instance baseurl**", that fix issue [#136](https://github.com/bsorrentino/maven-confluence-plugin/issues/136). Thanks to [tspindler](https://github.com/tspindler) for contribution. | +| **Apr 1, 2022** | [Release 7.5](https://github.com/bsorrentino/maven-confluence-plugin/releases/tag/v7.5) | Fix empty table cell not handled properly. Refer to [#264](https://github.com/bsorrentino/maven-confluence-plugin/issues/ | +| **Jan 10, 2022** | [Release 7.4](https://github.com/bsorrentino/maven-confluence-plugin/releases/tag/v7.4) | Fix problem with **encoding**. Refer to [#261](https://github.com/bsorrentino/maven-confluence-plugin/issues/261). | ### [Release History](HISTORY.md) diff --git a/addon-scrollversions/pom.xml b/addon-scrollversions/pom.xml index e8e995cc..1bb069c5 100644 --- a/addon-scrollversions/pom.xml +++ b/addon-scrollversions/pom.xml @@ -5,7 +5,7 @@ maven-confluence-parent org.bsc.maven - 7.12 + 7.13 4.0.0 diff --git a/core/pom.xml b/core/pom.xml index deaa29df..e736fb83 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -5,7 +5,7 @@ maven-confluence-parent org.bsc.maven - 7.12 + 7.13 4.0.0 diff --git a/core/src/main/java/org/bsc/markdown/MarkdownVisitorHelper.java b/core/src/main/java/org/bsc/markdown/MarkdownVisitorHelper.java index ea99d222..2e29b303 100644 --- a/core/src/main/java/org/bsc/markdown/MarkdownVisitorHelper.java +++ b/core/src/main/java/org/bsc/markdown/MarkdownVisitorHelper.java @@ -9,7 +9,6 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.Optional; -import java.util.function.BiFunction; import java.util.function.Predicate; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -110,11 +109,14 @@ public static String processLinkUrl( String url, MarkdownParserContext parseCont return result; }; + return parseContext.getSite() .flatMap( site -> site.getHome().findPage( comparePath ) ) .map( page -> parseContext.getPagePrefixToApply() - .filter( prefixToApply -> !url.startsWith(prefixToApply) ) - .map( prefixToApply -> format( "%s - %s", prefixToApply, page.getName() ) ) + .map( prefixToApply -> prefixToApply.concat(" - ")) + .filter( prefixToApply -> !url.startsWith(prefixToApply) ) // check prefix already applied + .filter( prefixToApply -> !page.getName().startsWith(prefixToApply) ) // check prefix already applied + .map( prefixToApply -> prefixToApply.concat( page.getName() ) ) .orElse( page.getName() ) ) .orElse(url) ; @@ -183,19 +185,20 @@ public static Matcher parseConfluenceMacro( @NonNull String text ) { return confluenceMacroWithContentPattern.matcher(text); } - /** - * - * @param text - * @return - */ - public static String escapeMarkdownText( String text ) { - // GUARD - if( text == null || text.isEmpty() ) return text; + public enum EscapeTextEnum { + LeftCurlyBrace( "(\\\\)?(\\{)" ), + RightCurlyBrace("(\\\\)?(\\})"), + LeftSquareBrace("(\\\\)?(\\[)"), + RightSquareBrace("(\\\\)?(])"); + + private final String pattern; + EscapeTextEnum( String pattern) { + this.pattern = pattern; + } -// if( SkipEscapeMarkdownText.TOC.matches( text ) ) return text; -// if( SkipEscapeMarkdownText.CHILDREN.matches( text ) ) return text; + public String replaceAll( String value) { + if( value == null || value.isEmpty() ) return value; - final BiFunction replaceAll = (pattern, value ) -> { final Matcher m = Pattern.compile(pattern).matcher(value); boolean result = m.find(); @@ -210,17 +213,23 @@ public static String escapeMarkdownText( String text ) { return sb.toString(); } return value; - }; - - final String leftS[] = { "(\\\\)?(\\[)", "(\\\\)?(\\{)" }; - final String rightS[] = { "(\\\\)?(])", "(\\\\)?(\\})" }; - - return replaceAll - .andThen( result -> replaceAll.apply( rightS[0], result ) ) - .andThen( result -> replaceAll.apply( rightS[1], result ) ) - .andThen( result -> replaceAll.apply( leftS[0], result ) ) - .apply( leftS[1], text ); + } + } + /** + * Escapes special Markdown characters in a string. + * + * @param text text The text to escape + * @param firstEscape + * @param nextEscapes + * @return The escaped text + */ + public static String escapeMarkdownText(String text, EscapeTextEnum firstEscape, EscapeTextEnum... nextEscapes ) { + String result = firstEscape.replaceAll(text); + for (EscapeTextEnum escapeTextEnum : nextEscapes) { + result = escapeTextEnum.replaceAll(result); + } + return result; } } diff --git a/gitlog+jira/pom.xml b/gitlog+jira/pom.xml index 877d12d5..ce78723e 100644 --- a/gitlog+jira/pom.xml +++ b/gitlog+jira/pom.xml @@ -5,7 +5,7 @@ maven-confluence-parent org.bsc.maven - 7.12 + 7.13 4.0.0 diff --git a/plugin-reporting/pom.xml b/plugin-reporting/pom.xml index 1478ee90..93d585fd 100755 --- a/plugin-reporting/pom.xml +++ b/plugin-reporting/pom.xml @@ -5,7 +5,7 @@ maven-confluence-parent org.bsc.maven - 7.12 + 7.13 diff --git a/pom.xml b/pom.xml index 65037848..c7d34777 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.bsc.maven maven-confluence-parent pom - 7.12 + 7.13 CONFLUENCE-REPORTING::Parent Maven's plugin that allow to generate "project's documentation" directly to confluence allowing, in the same time, to keep in-sync both project & documentation @@ -76,7 +76,7 @@ 3.6.0 true - 3.3.1 + 3.6.0 2.4 ${project.artifactId}-${project.version} @@ -160,7 +160,7 @@ org.apache.maven maven-aether-provider - ${mavenVersion} + 3.3.9 test diff --git a/processor-commonmark/pom.xml b/processor-commonmark/pom.xml index bbfd93a7..26f94303 100644 --- a/processor-commonmark/pom.xml +++ b/processor-commonmark/pom.xml @@ -5,7 +5,7 @@ maven-confluence-parent org.bsc.maven - 7.12 + 7.13 4.0.0 diff --git a/processor-commonmark/src/main/java/org/bsc/markdown/commonmark/CommonmarkConfluenceWikiVisitor.java b/processor-commonmark/src/main/java/org/bsc/markdown/commonmark/CommonmarkConfluenceWikiVisitor.java index 989f1936..366f9d41 100644 --- a/processor-commonmark/src/main/java/org/bsc/markdown/commonmark/CommonmarkConfluenceWikiVisitor.java +++ b/processor-commonmark/src/main/java/org/bsc/markdown/commonmark/CommonmarkConfluenceWikiVisitor.java @@ -22,7 +22,6 @@ import java.util.regex.Pattern; import static java.lang.String.format; -import static java.util.Optional.of; import static java.util.Optional.ofNullable; import static org.bsc.markdown.MarkdownVisitorHelper.*; @@ -91,8 +90,14 @@ private boolean isParentRoot(Node node) { * @return */ public static String escapeMarkdownText( Node node, String text ) { - if( node!=null && node.getParent() instanceof TableCell) return text; - return MarkdownVisitorHelper.escapeMarkdownText(text); + + if( node!=null && node.getParent() instanceof TableCell ) { + return MarkdownVisitorHelper.escapeMarkdownText(text, EscapeTextEnum.LeftCurlyBrace); + } + return MarkdownVisitorHelper.escapeMarkdownText(text, EscapeTextEnum.LeftCurlyBrace, + EscapeTextEnum.LeftSquareBrace, + EscapeTextEnum.RightCurlyBrace, + EscapeTextEnum.RightSquareBrace); } private final static Pattern isHTMLCommentPattern = Pattern.compile( "^([\\s]*)$", Pattern.DOTALL ); diff --git a/processor-commonmark/src/test/kotlin/org/bsc/makdown/commonmark/Issue295Test.kt b/processor-commonmark/src/test/kotlin/org/bsc/makdown/commonmark/Issue295Test.kt new file mode 100644 index 00000000..9a8320a1 --- /dev/null +++ b/processor-commonmark/src/test/kotlin/org/bsc/makdown/commonmark/Issue295Test.kt @@ -0,0 +1,36 @@ +package org.bsc.makdown.commonmark + +import org.bsc.confluence.model.Site +import org.bsc.markdown.MarkdownVisitorHelper.* +import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Test +import java.nio.file.Paths + +class Issue295Test { + + var site = Site().apply { + basedir = Paths.get(System.getProperty("user.dir")) + } + + @Test + fun `escape text between curly braces`() { + + assertEquals( "\\{0,128}", escapeMarkdownText( "{0,128}", EscapeTextEnum.LeftCurlyBrace )) + assertEquals( "\\{0,128\\}", escapeMarkdownText( "{0,128}", + EscapeTextEnum.LeftCurlyBrace, EscapeTextEnum.RightCurlyBrace )) + assertEquals( "\\[0,128]", escapeMarkdownText( "[0,128]", EscapeTextEnum.LeftSquareBrace )) + assertEquals( "\\[0,128\\]", escapeMarkdownText( "[0,128]", + EscapeTextEnum.LeftSquareBrace, EscapeTextEnum.RightSquareBrace )) + } + + @Test + fun parse() { + val content = parseResource( this.javaClass, "issue295", this.site ) + + assertEquals(""" + ||Property||Default||Required||Description||Example|| + |someEntry|{{\{0,128}}}|false|value that is being misinterpreted as a macro|-| + """.trimIndent(), content ) + } + +} \ No newline at end of file diff --git a/processor-commonmark/src/test/resources/issue295.md b/processor-commonmark/src/test/resources/issue295.md new file mode 100644 index 00000000..48fdd241 --- /dev/null +++ b/processor-commonmark/src/test/resources/issue295.md @@ -0,0 +1,3 @@ +| Property | Default | Required | Description | Example | +|-----------|------------|----------|-----------------------------------------------|---------| +| someEntry | `\{0,128}` | false | value that is being misinterpreted as a macro | - | \ No newline at end of file diff --git a/processor-freemarker/pom.xml b/processor-freemarker/pom.xml index ccc6ed90..1c09374a 100644 --- a/processor-freemarker/pom.xml +++ b/processor-freemarker/pom.xml @@ -5,7 +5,7 @@ org.bsc.maven maven-confluence-parent - 7.12 + 7.13 maven-confluence-processor-freemarker CONFLUENCE-REPORTING::Freemaker::Processor diff --git a/service-rest-api/pom.xml b/service-rest-api/pom.xml index c48d168c..9642cf63 100644 --- a/service-rest-api/pom.xml +++ b/service-rest-api/pom.xml @@ -5,7 +5,7 @@ maven-confluence-parent org.bsc.maven - 7.12 + 7.13 4.0.0 diff --git a/service-rest-api/src/main/java/org/bsc/confluence/rest/AbstractRESTConfluenceService.java b/service-rest-api/src/main/java/org/bsc/confluence/rest/AbstractRESTConfluenceService.java index 590df7d2..ba6e36a8 100644 --- a/service-rest-api/src/main/java/org/bsc/confluence/rest/AbstractRESTConfluenceService.java +++ b/service-rest-api/src/main/java/org/bsc/confluence/rest/AbstractRESTConfluenceService.java @@ -5,7 +5,6 @@ */ package org.bsc.confluence.rest; -import lombok.val; import okhttp3.*; import org.apache.commons.io.IOUtils; import org.bsc.confluence.ConfluenceService; @@ -58,7 +57,7 @@ public ServiceException(String message, Response res ) { */ public CompletableFuture fromRequestAsync( final Request req ) { - val result = new CompletableFuture(); + final CompletableFuture result = new CompletableFuture(); client.build().newCall(req).enqueue( new Callback() { diff --git a/service-xmlrpc-api/pom.xml b/service-xmlrpc-api/pom.xml index 6eeee256..c4ead193 100644 --- a/service-xmlrpc-api/pom.xml +++ b/service-xmlrpc-api/pom.xml @@ -5,7 +5,7 @@ maven-confluence-parent org.bsc.maven - 7.12 + 7.13 4.0.0 diff --git a/test-plugin/pom.xml b/test-plugin/pom.xml index a7f36398..7f40e622 100644 --- a/test-plugin/pom.xml +++ b/test-plugin/pom.xml @@ -6,7 +6,7 @@ maven-confluence-parent org.bsc.maven - 7.12 + 7.13 diff --git a/test-publishing/pom.xml b/test-publishing/pom.xml index d3235356..3e58047e 100644 --- a/test-publishing/pom.xml +++ b/test-publishing/pom.xml @@ -3,7 +3,7 @@ maven-confluence-parent org.bsc.maven - 7.12 + 7.13 4.0.0 @@ -92,6 +92,40 @@ --> + + + commonmark + + deploy + delete + + + ${basedir}/src/site/confluence/issue154/site-commonmark.yaml + + + wiki + + + + + issue294 + + deploy + delete + + + UTF-8 + true + ${basedir}/src/site/confluence/issue294/site.yaml + + + @@ -330,23 +364,6 @@ - - commonmark - - deploy - delete - - - ${basedir}/src/site/confluence/issue154/site-commonmark.yaml - - - wiki - - -