Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/banzai/filter/blockquote_fence_filter.rb')
-rw-r--r--lib/banzai/filter/blockquote_fence_filter.rb13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/banzai/filter/blockquote_fence_filter.rb b/lib/banzai/filter/blockquote_fence_filter.rb
index e5cf20d00df..8681173b1f4 100644
--- a/lib/banzai/filter/blockquote_fence_filter.rb
+++ b/lib/banzai/filter/blockquote_fence_filter.rb
@@ -6,14 +6,14 @@ module Banzai
REGEX = %r{
#{::Gitlab::Regex.markdown_code_or_html_blocks}
|
- (?=(?<=^\n|\A)>>>\ *\n.*\n>>>\ *(?=\n$|\z))(?:
+ (?=(?<=^\n|\A)\ *>>>\ *\n.*\n\ *>>>\ *(?=\n$|\z))(?:
# Blockquote:
# >>>
# Anything, including code and HTML blocks
# >>>
- (?<=^\n|\A)>>>\ *\n
- (?<quote>
+ (?<=^\n|\A)(?<indent>\ *)>>>\ *\n
+ (?<blockquote>
(?:
# Any character that doesn't introduce a code or HTML block
(?!
@@ -30,7 +30,7 @@ module Banzai
\g<html>
)+?
)
- \n>>>\ *(?=\n$|\z)
+ \n\ *>>>\ *(?=\n$|\z)
)
}mx.freeze
@@ -41,10 +41,11 @@ module Banzai
def call
@text.gsub(REGEX) do
- if $~[:quote]
+ if $~[:blockquote]
# keep the same number of source lines/positions by replacing the
# fence lines with newlines
- "\n" + $~[:quote].gsub(/^/, "> ").gsub(/^> $/, ">") + "\n"
+ indent = $~[:indent]
+ "\n" + $~[:blockquote].gsub(/^#{Regexp.quote(indent)}/, "#{indent}> ").gsub(/^> $/, ">") + "\n"
else
$~[0]
end