Skip to content

Commit

Permalink
Merge pull request kovetskiy#248 from prokod/bugfix/prokod/kovetskiy#247
Browse files Browse the repository at this point in the history


To add fallback to blockquote when type is none
  • Loading branch information
mrueg authored Jan 31, 2023
2 parents cd08a70 + ce9573a commit b82e18f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions pkg/mark/markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down
7 changes: 6 additions & 1 deletion pkg/mark/testdata/quotes.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ <h2 id="second-heading">Second Heading</h2>
<li>Warn bullet 1</li>
<li>Warn bullet 2</li>
</ul>
</ac:rich-text-body></ac:structured-macro>
</ac:rich-text-body></ac:structured-macro>
<h2 id="simple-blockquote">Simple Blockquote</h2>

<blockquote>
<p>This paragraph is a simple blockquote</p>
</blockquote>
4 changes: 4 additions & 0 deletions pkg/mark/testdata/quotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@
>
> * Warn bullet 1
> * Warn bullet 2
## Simple Blockquote

> This paragraph is a simple blockquote

0 comments on commit b82e18f

Please sign in to comment.