summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/banzai/filter/blockquote_fence_filter.rb43
-rw-r--r--spec/fixtures/blockquote_fence_after.md2
-rw-r--r--spec/fixtures/blockquote_fence_before.md2
3 files changed, 34 insertions, 13 deletions
diff --git a/lib/banzai/filter/blockquote_fence_filter.rb b/lib/banzai/filter/blockquote_fence_filter.rb
index fb815c2d837..d2c4b1e4d76 100644
--- a/lib/banzai/filter/blockquote_fence_filter.rb
+++ b/lib/banzai/filter/blockquote_fence_filter.rb
@@ -5,35 +5,56 @@ module Banzai
(?<code>
# Code blocks:
# ```
- # Anything, including ignored `>>>` blocks
+ # Anything, including `>>>` blocks which are ignored by this filter
# ```
- ^```.+?\n```$
+
+ ^```
+ .+?
+ \n```$
)
|
(?<html>
- # HTML:
+ # HTML block:
# <tag>
- # Anything, including ignored `>>>` blocks
+ # Anything, including `>>>` blocks which are ignored by this filter
# </tag>
- ^<[^>]+?>.+?\n<\/[^>]+?>$
+
+ ^<[^>]+?>\n
+ .+?
+ \n<\/[^>]+?>$
)
|
- (
- ^>>>\n(?<quote>
+ (?:
+ # Blockquote:
+ # >>>
+ # Anything, including code and HTML blocks
+ # >>>
+
+ ^>>>\n
+ (?<quote>
(?:
- (?!^```|^<[^>]+?>).
+ # Any character that doesn't introduce a code or HTML block
+ (?!
+ ^```
+ |
+ ^<[^>]+?>\n
+ )
+ .
|
+ # A code block
\g<code>
|
+ # An HTML block
\g<html>
- )
- +?)\n>>>$
+ )+?
+ )
+ \n>>>$
)
}mx.freeze
def initialize(text, context = nil, result = nil)
super text, context, result
- @text = @text.delete "\r"
+ @text = @text.delete("\r")
end
def call
diff --git a/spec/fixtures/blockquote_fence_after.md b/spec/fixtures/blockquote_fence_after.md
index 5ab136f76c3..2652a842c0e 100644
--- a/spec/fixtures/blockquote_fence_after.md
+++ b/spec/fixtures/blockquote_fence_after.md
@@ -8,7 +8,7 @@ Single `>>>` inside code block:
Double `>>>` inside code block:
-```
+```txt
# Code
>>>
# Code
diff --git a/spec/fixtures/blockquote_fence_before.md b/spec/fixtures/blockquote_fence_before.md
index e6689b6c5dd..d52eec72896 100644
--- a/spec/fixtures/blockquote_fence_before.md
+++ b/spec/fixtures/blockquote_fence_before.md
@@ -8,7 +8,7 @@ Single `>>>` inside code block:
Double `>>>` inside code block:
-```
+```txt
# Code
>>>
# Code