Commit 24e7c3e3 authored by Douwe Maan's avatar Douwe Maan

Add more comments to regex

parent 2fcb2b33
...@@ -5,35 +5,56 @@ module Banzai ...@@ -5,35 +5,56 @@ module Banzai
(?<code> (?<code>
# Code blocks: # Code blocks:
# ``` # ```
# Anything, including ignored `>>>` blocks # Anything, including `>>>` blocks which are ignored by this filter
# ``` # ```
^```.+?\n```$
^```
.+?
\n```$
) )
| |
(?<html> (?<html>
# HTML: # HTML block:
# <tag> # <tag>
# Anything, including ignored `>>>` blocks # Anything, including `>>>` blocks which are ignored by this filter
# </tag> # </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> \g<code>
| |
# An HTML block
\g<html> \g<html>
)+?
) )
+?)\n>>>$ \n>>>$
) )
}mx.freeze }mx.freeze
def initialize(text, context = nil, result = nil) def initialize(text, context = nil, result = nil)
super text, context, result super text, context, result
@text = @text.delete "\r" @text = @text.delete("\r")
end end
def call def call
......
...@@ -8,7 +8,7 @@ Single `>>>` inside code block: ...@@ -8,7 +8,7 @@ Single `>>>` inside code block:
Double `>>>` inside code block: Double `>>>` inside code block:
``` ```txt
# Code # Code
>>> >>>
# Code # Code
......
...@@ -8,7 +8,7 @@ Single `>>>` inside code block: ...@@ -8,7 +8,7 @@ Single `>>>` inside code block:
Double `>>>` inside code block: Double `>>>` inside code block:
``` ```txt
# Code # Code
>>> >>>
# Code # Code
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment