Skip to content

Commit

Permalink
test: test parse multiline html comment
Browse files Browse the repository at this point in the history
test multiline html comment for identify confluence macro + test publishing

#285
  • Loading branch information
bsorrentino committed Mar 20, 2023
1 parent 2825387 commit 17ba7f4
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ public static String processLinkUrl( String url, MarkdownParserContext parseCont
// }

/**
*
* [Match multiline text using regular expression](https://stackoverflow.com/a/3652392/521197)
*/
private static Pattern isConfluenceMacroPattern = Pattern.compile( "^[\\s]*\\{([\\w-]+)(([:][\\w-]+(=(.+))?)([|].+)*)?\\}[\\s]*$" );
private static Pattern isConfluenceMacroPattern = Pattern.compile( "^[\\s]*\\{([\\w-]+)(([:][\\w-]+(=(.+))?)([|].+)*)?\\}[\\s]*$", Pattern.DOTALL );
private static Pattern isConfluenceVariable = Pattern.compile( "^[\\s]*\\$\\{([\\w-\\.]+)\\}[\\s]*$" );

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.bsc.makdown.commonmark

import org.bsc.confluence.model.Site
import org.bsc.markdown.MarkdownVisitorHelper.isConfluenceMacro
import org.bsc.markdown.commonmark.CommonmarkConfluenceWikiVisitor.parseHTMLComment
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue
Expand All @@ -26,11 +27,14 @@ class Issue285Test {

assertTrue( multiLineMatcher.matches() )
assertEquals( 2, multiLineMatcher.groupCount() )

val content = multiLineMatcher.group(2).trimEnd()
assertEquals( """
{excerpt:title=MyExcerpt}
This is the content that I want to use as my excerpt.
{excerpt}
""".trimIndent(), multiLineMatcher.group(2).trimEnd() )
""".trimIndent(), content )
assertTrue( isConfluenceMacro( content ), "$content\n It is not recognized as confluence macro!" )

}

Expand Down
20 changes: 20 additions & 0 deletions test-publishing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,26 @@

</configuration>
</execution>
<!--
mvn confluence-reporting:deploy@issue285
mvn confluence-reporting:delete@issue285
-->
<execution>
<id>issue285</id>
<goals>
<goal>deploy</goal>
<goal>delete</goal>
</goals>
<configuration>
<encoding>UTF-8</encoding>
<failOnError>true</failOnError>
<siteDescriptor>${basedir}/src/site/confluence/issue285/site.yml</siteDescriptor>
<markdownProcessor>
<skipHtml>true</skipHtml>
</markdownProcessor>

</configuration>
</execution>

</executions>
</plugin>
Expand Down
11 changes: 11 additions & 0 deletions test-publishing/src/site/confluence/issue285/issue285.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## TEST ISSUE 285


<!-- {excerpt:title=MyExcerpt}
This is the content that I want to use as my excerpt.
{excerpt} -->

<!-- {excerpt:title=MyExcerpt} This is the content that I want to use as my excerpt. {excerpt} -->

<h1>TEST ISSUE 285</h1>

4 changes: 4 additions & 0 deletions test-publishing/src/site/confluence/issue285/site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
home:
uri: issue285.md
parentPageTitle: "Home"
name: "Issue #285"

0 comments on commit 17ba7f4

Please sign in to comment.