Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
6a477b9b
Commit
6a477b9b
authored
Apr 27, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add blockquote fence syntax to Markdown
parent
92772f85
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
345 additions
and
2 deletions
+345
-2
doc/markdown/markdown.md
doc/markdown/markdown.md
+33
-1
lib/banzai/filter/blockquote_fence_filter.rb
lib/banzai/filter/blockquote_fence_filter.rb
+50
-0
lib/banzai/pipeline/pre_process_pipeline.rb
lib/banzai/pipeline/pre_process_pipeline.rb
+2
-1
spec/fixtures/blockquote_fence_after.md
spec/fixtures/blockquote_fence_after.md
+115
-0
spec/fixtures/blockquote_fence_before.md
spec/fixtures/blockquote_fence_before.md
+131
-0
spec/lib/banzai/filter/blockquote_fence_filter_spec.rb
spec/lib/banzai/filter/blockquote_fence_filter_spec.rb
+14
-0
No files found.
doc/markdown/markdown.md
View file @
6a477b9b
...
...
@@ -7,11 +7,12 @@
*
[
Newlines
](
#newlines
)
*
[
Multiple underscores in words
](
#multiple-underscores-in-words
)
*
[
URL auto-linking
](
#url-auto-linking
)
*
[
Multiline Blockquote
](
#multiline-blockquote
)
*
[
Code and Syntax Highlighting
](
#code-and-syntax-highlighting
)
*
[
Inline Diff
](
#inline-diff
)
*
[
Emoji
](
#emoji
)
*
[
Special GitLab references
](
#special-gitlab-references
)
*
[
Task
l
ists
](
#task-lists
)
*
[
Task
L
ists
](
#task-lists
)
**[Standard Markdown](#standard-markdown)**
...
...
@@ -89,6 +90,37 @@ GFM will autolink almost any URL you copy and paste into your text.
*
irc://irc.freenode.net/gitlab
*
http://localhost:3000
## Multiline Blockquote
On top of standard Markdown
[
blockquotes
](
#blockquotes
)
, which require prepending
`>`
to quoted lines,
GFM supports multiline blockquotes fenced by
<code>
>>>
</code>
.
```
no-highlight
>>>
If you paste a message from somewhere else
that
spans
multiple lines,
you can quote that without having to manually prepend `>` to every line!
>>>
```
>>>
If you paste a message from somewhere else
that
spans
multiple lines,
you can quote that without having to manually prepend
`>`
to every line!
>>>
## Code and Syntax Highlighting
_GitLab uses the
[
Rouge Ruby library
][
rouge
]
for syntax highlighting. For a
...
...
lib/banzai/filter/blockquote_fence_filter.rb
0 → 100644
View file @
6a477b9b
module
Banzai
module
Filter
class
BlockquoteFenceFilter
<
HTML
::
Pipeline
::
TextFilter
REGEX
=
%r{
(?<code>
# Code blocks:
# ```
# Anything, including ignored `>>>` blocks
# ```
^```.+?
\n
```$
)
|
(?<html>
# HTML:
# <tag>
# Anything, including ignored `>>>` blocks
# </tag>
^<[^>]+?>.+?
\n
<
\/
[^>]+?>$
)
|
(
^>>>
\n
(?<quote>
(?:
(?!^```|^<[^>]+?>).
|
\g
<code>
|
\g
<html>
)
+?)
\n
>>>$
)
}mx
.
freeze
def
initialize
(
text
,
context
=
nil
,
result
=
nil
)
super
text
,
context
,
result
@text
=
@text
.
delete
"
\r
"
end
def
call
@text
.
gsub
(
REGEX
)
do
if
$~
[
:quote
]
$~
[
:quote
].
gsub
(
/^/
,
"> "
).
gsub
(
/^> $/
,
">"
)
else
$~
[
0
]
end
end
end
end
end
end
lib/banzai/pipeline/pre_process_pipeline.rb
View file @
6a477b9b
...
...
@@ -3,7 +3,8 @@ module Banzai
class
PreProcessPipeline
<
BasePipeline
def
self
.
filters
FilterArray
[
Filter
::
YamlFrontMatterFilter
Filter
::
YamlFrontMatterFilter
,
Filter
::
BlockquoteFenceFilter
,
]
end
...
...
spec/fixtures/blockquote_fence_after.md
0 → 100644
View file @
6a477b9b
Single
`>>>`
inside code block:
```
# Code
>>>
# Code
```
Double
`>>>`
inside code block:
```
# Code
>>>
# Code
>>>
# Code
```
Blockquote outside code block:
> Quote
Code block inside blockquote:
> Quote
>
> ```
> # Code
> ```
>
> Quote
Single
`>>>`
inside code block inside blockquote:
> Quote
>
> ```
> # Code
> >>>
> # Code
> ```
>
> Quote
Double
`>>>`
inside code block inside blockquote:
> Quote
>
> ```
> # Code
> >>>
> # Code
> >>>
> # Code
> ```
>
> Quote
Single
`>>>`
inside HTML:
<pre>
# Code
>>>
# Code
</pre>
Double
`>>>`
inside HTML:
<pre>
# Code
>>>
# Code
>>>
# Code
</pre>
Blockquote outside HTML:
> Quote
HTML inside blockquote:
> Quote
>
> <pre>
> # Code
> </pre>
>
> Quote
Single
`>>>`
inside HTML inside blockquote:
> Quote
>
> <pre>
> # Code
> >>>
> # Code
> </pre>
>
> Quote
Double
`>>>`
inside HTML inside blockquote:
> Quote
>
> <pre>
> # Code
> >>>
> # Code
> >>>
> # Code
> </pre>
>
> Quote
spec/fixtures/blockquote_fence_before.md
0 → 100644
View file @
6a477b9b
Single
`>>>`
inside code block:
```
# Code
>>>
# Code
```
Double
`>>>`
inside code block:
```
# Code
>>>
# Code
>>>
# Code
```
Blockquote outside code block:
>>>
Quote
>>>
Code block inside blockquote:
>>>
Quote
```
# Code
```
Quote
>>>
Single
`>>>`
inside code block inside blockquote:
>>>
Quote
```
# Code
>>>
# Code
```
Quote
>>>
Double
`>>>`
inside code block inside blockquote:
>>>
Quote
```
# Code
>>>
# Code
>>>
# Code
```
Quote
>>>
Single
`>>>`
inside HTML:
<pre>
# Code
>>>
# Code
</pre>
Double
`>>>`
inside HTML:
<pre>
# Code
>>>
# Code
>>>
# Code
</pre>
Blockquote outside HTML:
>>>
Quote
>>>
HTML inside blockquote:
>>>
Quote
<pre>
# Code
</pre>
Quote
>>>
Single
`>>>`
inside HTML inside blockquote:
>>>
Quote
<pre>
# Code
>>>
# Code
</pre>
Quote
>>>
Double
`>>>`
inside HTML inside blockquote:
>>>
Quote
<pre>
# Code
>>>
# Code
>>>
# Code
</pre>
Quote
>>>
spec/lib/banzai/filter/blockquote_fence_filter_spec.rb
0 → 100644
View file @
6a477b9b
require
'rails_helper'
describe
Banzai
::
Filter
::
BlockquoteFenceFilter
,
lib:
true
do
include
FilterSpecHelper
it
'convers blockquote fences to blockquote lines'
do
content
=
File
.
read
(
Rails
.
root
.
join
(
'spec/fixtures/blockquote_fence_before.md'
))
expected
=
File
.
read
(
Rails
.
root
.
join
(
'spec/fixtures/blockquote_fence_after.md'
))
output
=
filter
(
content
)
expect
(
output
).
to
eq
(
expected
)
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment