Repository: kovetskiy/mark (go)

Issue:
Simple block quotes are no longer rendered properly in confluence with 8.6
## Bug

*Version Affected:* 8.6
*Does this exist in previous versions?* No

### Steps to Reproduce
1. Create the following markdown doc:
```markdown
# Test Doc for Blockquotes

## Simple Blockquote

> This paragraph is a simple blockquote
```
2. Publish the doc

*Expected Result:* Blockquote appears in `<blockquote>` HTML node
*Actual Result:* Blockquote renders as an error box with the text `📜Unknown Macro: 'none'` 

## Background

I am still in the process of debugging what exactly is occurring but, following an upgrade to 8.6, when publishing to confluence we now see an error box in any place in the document which uses "simple" blockquotes (ie `> some blockquote`). Downgrading to 8.5 resolved the issue and blockquotes returned to their normal appearance.

Assuming I do not get pulled in to other work my plan is to create some tesk markdown and compare the HTML output of 8.5 to 8.6 and dig into the code to understand why this regression occurred.

Pull request:
To add fallback to blockquote when type is none
This PR should fix #247 

Patch:
diff --git a/README.md b/README.md
index f288534..fe70ac9 100644
--- a/README.md
+++ b/README.md
@@ -207,6 +207,15 @@ use `-` as the first character, if you want to have the other goodies
 
 [Code Block Macro]: https://confluence.atlassian.com/doc/code-block-macro-139390.html
 
+### Block Quotes
+
+Block Quotes are converted to Confluence Info/Warn/Note box when the following conditions are met
+
+1. The BlockQuote is on the root level of the document (not nested)
+1. The first line of the BlockQuote contains one of the following patterns `Info/Warn/Note`
+
+In any other case the default behaviour will be resumed and html `<blockquote>` tag will be used
+
 ## Template & Macros
 
 By default, mark provides several built-in templates and macros:
diff --git a/pkg/mark/markdown.go b/pkg/mark/markdown.go
index ddea59f..1122c92 100644
--- a/pkg/mark/markdown.go
+++ b/pkg/mark/markdown.go
@@ -247,7 +247,7 @@ func (renderer ConfluenceRenderer) RenderNode(
 
 		re := regexp.MustCompile(`[\n\t]`)
 
-		if quoteLevel == 0 && entering {
+		if quoteLevel == 0 && entering && quoteType != None {
 			if _, err := writer.Write([]byte(re.ReplaceAllString(fmt.Sprintf(`
 			<ac:structured-macro ac:name="%s">
 			<ac:parameter ac:name="icon">true</ac:parameter>
@@ -257,7 +257,7 @@ func (renderer ConfluenceRenderer) RenderNode(
 			}
 			return bf.GoToNext
 		}
-		if quoteLevel == 0 && !entering {
+		if quoteLevel == 0 && !entering && quoteType != None {
 			if _, err := writer.Write([]byte(re.ReplaceAllString(`
 			</ac:rich-text-body>
 			</ac:structured-macro>


Test patch:
diff --git a/pkg/mark/testdata/quotes.html b/pkg/mark/testdata/quotes.html
index d9819a5..1eb3596 100644
--- a/pkg/mark/testdata/quotes.html
+++ b/pkg/mark/testdata/quotes.html
@@ -24,4 +24,9 @@ b</p>
 <li>Warn bullet 1</li>
 <li>Warn bullet 2</li>
 </ul>
-</ac:rich-text-body></ac:structured-macro>
\ No newline at end of file
+</ac:rich-text-body></ac:structured-macro>
+<h2 id="simple-blockquote">Simple Blockquote</h2>
+
+<blockquote>
+<p>This paragraph is a simple blockquote</p>
+</blockquote>
diff --git a/pkg/mark/testdata/quotes.md b/pkg/mark/testdata/quotes.md
index 7f23b73..b9837ae 100644
--- a/pkg/mark/testdata/quotes.md
+++ b/pkg/mark/testdata/quotes.md
@@ -18,3 +18,7 @@
 >
 > * Warn bullet 1
 > * Warn bullet 2
+
+## Simple Blockquote
+
+> This paragraph is a simple blockquote