From ce9573a86e68225692bc1b10b965110bf75ae1a9 Mon Sep 17 00:00:00 2001
From: Noam Asor
Date: Sat, 28 Jan 2023 21:15:31 +0100
Subject: [PATCH] To add fallack to blockquote when type is none
---
README.md | 9 +++++++++
pkg/mark/markdown.go | 4 ++--
pkg/mark/testdata/quotes.html | 7 ++++++-
pkg/mark/testdata/quotes.md | 4 ++++
4 files changed, 21 insertions(+), 3 deletions(-)
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 `` 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(`
true
@@ -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(`
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
Warn bullet 1
Warn bullet 2
-
\ No newline at end of file
+
+Simple Blockquote
+
+
+This paragraph is a simple 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