-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue #235 - added support of declaring confluence macro inside html …
…comment. Removed confluence macro detection skipping the escaping of markdown text
- Loading branch information
1 parent
9ad6560
commit 957a048
Showing
8 changed files
with
208 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.bsc.markdown | ||
|
||
import org.bsc.markdown.MarkdownVisitorHelper.isConfluenceMacro | ||
import org.junit.Test | ||
import org.junit.jupiter.api.Assertions.assertTrue | ||
import java.util.regex.Pattern | ||
|
||
class MacroParsingTest { | ||
|
||
@Test | ||
fun parse() { | ||
|
||
val regexp = Pattern.compile( "^[\\s]*\\{([\\w-]+)(([:][\\w-]+(=(.+))?)([|].+)*)?\\}[\\s]*$" ) | ||
|
||
val macros = arrayOf( | ||
" {toc} ", | ||
"{toc:style=disc|indent=20px}", | ||
"{toc:type=flat|separator=pipe|maxLevel=3}", | ||
"{toc:outline=true|indent=0px|minLevel=2}", | ||
"{children}", | ||
"{children:all=true}", | ||
"{children:depth=x}", | ||
"{children:depth=x|style=h3}", | ||
"{children:excerpt=true}", | ||
"{children:page=Another Page}", | ||
" {children:page=/}", | ||
"{children:page=SPACEKEY:} ", | ||
"{children:page=SPACEKEY:Page+Title}", | ||
" {children:first=x}", | ||
"{children:sort=<mode>|reverse=false}", | ||
"{blog-posts:max=5}", | ||
"{blog-posts:max=5|content=excerpts}", | ||
"{blog-posts:max=5|content=titles}", | ||
"{blog-posts:time=7d|spaces=@all}", | ||
"{blog-posts:max=15|time=14d|content=excerpts}", | ||
"{blog-posts:labels=confluence,atlassian}", | ||
"{blog-posts:labels=+atlassian,+confluence,+content}", | ||
"{navmap:mylabel}", | ||
"{navmap:mylabel|wrapAfter=3|cellWidth=110|cellHeight=20|theme=mytheme}", | ||
"{toc-zone:separator=brackets|location=top} ", | ||
"{toc-zone}", | ||
) | ||
|
||
for( literal in macros ) { | ||
println( "evaluate macro $literal") | ||
assertTrue( isConfluenceMacro(literal) ) | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
processor-commonmark/src/test/kotlin/org/bsc/makdown/commonmark/Issue235Test.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.bsc.makdown.commonmark | ||
|
||
import org.bsc.confluence.model.Site | ||
import org.bsc.markdown.commonmark.CommonmarkConfluenceWikiVisitor.parseHTMLComment | ||
import org.junit.Test | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Assertions.assertTrue | ||
import java.nio.file.Paths | ||
import java.util.regex.Pattern | ||
|
||
class Issue235Test { | ||
|
||
var site = Site().apply { | ||
basedir = Paths.get(System.getProperty("user.dir")) | ||
} | ||
|
||
@Test | ||
fun parseHtmlBlock() { | ||
|
||
val singleLineMatcher = parseHTMLComment("<!-- {xxxxxxx:yyyyyy} -->") | ||
|
||
assertTrue( singleLineMatcher.matches() ) | ||
assertEquals( 1, singleLineMatcher.groupCount() ) | ||
assertEquals( "{xxxxxxx:yyyyyy}", singleLineMatcher.group(1).trimEnd() ) | ||
|
||
val multiLineMatcher = parseHTMLComment("""<!-- | ||
{xxxxxxx:yyyyyy} | ||
--> | ||
""".trimIndent()) | ||
|
||
assertTrue( multiLineMatcher.matches() ) | ||
assertEquals( 1, multiLineMatcher.groupCount() ) | ||
assertEquals( "{xxxxxxx:yyyyyy}", multiLineMatcher.group(1).trimEnd() ) | ||
|
||
} | ||
|
||
@Test | ||
fun parseMacros() { | ||
val content = parseResource( this.javaClass, "issue235", this.site ) | ||
|
||
assertEquals(""" | ||
{html} | ||
<!-- | ||
Hello world! | ||
--> | ||
{html} | ||
{macro} | ||
{macro:scope} | ||
{macros:scope|property=value} | ||
{macros:scope|property1=value1, property2=value2} | ||
""".trimIndent(), content ) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!-- | ||
Hello world! | ||
--> | ||
|
||
<!-- {macro} --> | ||
|
||
<!-- {macro:scope} --> | ||
|
||
<!-- {macros:scope|property=value} --> | ||
|
||
<!-- {macros:scope|property1=value1, property2=value2} --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
# This is table of content | ||
|
||
{toc} | ||
|
||
{toc:minLevel=2} | ||
<!-- {toc} --> | ||
|
||
{toc:type=flat|separator=pipe:minLevel=2} | ||
<!-- {toc:minLevel=2} --> | ||
|
||
<!-- {toc:type=flat|separator=pipe:minLevel=2} --> | ||
|