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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
04c41cb3
Commit
04c41cb3
authored
Oct 27, 2020
by
Guillaume Grossetie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not process PlantUML diagrams with Kroki if PlantUML is enabled
parent
8cb4c0dd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
9 deletions
+28
-9
lib/banzai/filter/kroki_filter.rb
lib/banzai/filter/kroki_filter.rb
+6
-7
spec/lib/banzai/filter/kroki_filter_spec.rb
spec/lib/banzai/filter/kroki_filter_spec.rb
+22
-2
No files found.
lib/banzai/filter/kroki_filter.rb
View file @
04c41cb3
...
...
@@ -14,13 +14,12 @@ module Banzai
end
.
join
(
', '
)
def
call
# QUESTION: should we make Kroki and PlantUML mutually exclusive?
# Potentially, Kroki and PlantUML could work side by side.
# In fact, if both PlantUML and Kroki are enabled, PlantUML could still render PlantUML diagrams and Kroki could render the other diagrams?
# Having said that, since Kroki can render PlantUML diagrams, maybe it will be confusing...
#
# What about Mermaid? should we keep client side rendering for Mermaid?
return
doc
unless
settings
.
kroki_enabled
&&
doc
.
at
(
DIAGRAM_SELECTORS
)
plantuml_enabled
=
settings
.
plantuml_enabled
diagram_selectors
=
::
Gitlab
::
Kroki
::
DIAGRAM_TYPES
.
map
do
|
diagram_type
|
# if PlantUML is enabled, PlantUML diagrams will be processed by the PlantUML filter.
%(pre[lang="#{diagram_type}"] > code)
if
(
plantuml_enabled
&&
diagram_type
!=
'plantuml'
)
||
!
plantuml_enabled
end
.
compact
.
join
(
', '
)
return
doc
unless
settings
.
kroki_enabled
&&
doc
.
at
(
diagram_selectors
)
diagram_format
=
"svg"
doc
.
css
(
DIAGRAM_SELECTORS
).
each
do
|
node
|
...
...
spec/lib/banzai/filter/kroki_filter_spec.rb
View file @
04c41cb3
...
...
@@ -5,17 +5,37 @@ require 'spec_helper'
RSpec
.
describe
Banzai
::
Filter
::
KrokiFilter
do
include
FilterSpecHelper
it
'replaces nomnoml pre tag with img tag'
do
it
'replaces nomnoml pre tag with img tag
if kroki is enabled
'
do
stub_application_setting
(
kroki_enabled:
true
,
kroki_url:
"http://localhost:8000"
)
doc
=
filter
(
"<pre lang='nomnoml'><code>[Pirate|eyeCount: Int|raid();pillage()|
\n
[beard]--[parrot]
\n
[beard]-:>[foul mouth]
\n
]</code></pre>"
)
expect
(
doc
.
to_s
).
to
eq
'<img src="http://localhost:8000/nomnoml/svg/eNqLDsgsSixJrUmtTHXOL80rsVLwzCupKUrMTNHQtC7IzMlJTE_V0KzhUlCITkpNLEqJ1dWNLkgsKsoviUUSs7KLTssvzVHIzS8tyYjligUAMhEd0g==">'
end
it
'does not replace nomnoml pre tag with img tag if disabled'
do
it
'replaces nomnoml pre tag with img tag if both kroki and plantuml are enabled'
do
stub_application_setting
(
kroki_enabled:
true
,
kroki_url:
"http://localhost:8000"
,
plantuml_enabled:
true
,
plantuml_url:
"http://localhost:8080"
)
doc
=
filter
(
"<pre lang='nomnoml'><code>[Pirate|eyeCount: Int|raid();pillage()|
\n
[beard]--[parrot]
\n
[beard]-:>[foul mouth]
\n
]</code></pre>"
)
expect
(
doc
.
to_s
).
to
eq
'<img src="http://localhost:8000/nomnoml/svg/eNqLDsgsSixJrUmtTHXOL80rsVLwzCupKUrMTNHQtC7IzMlJTE_V0KzhUlCITkpNLEqJ1dWNLkgsKsoviUUSs7KLTssvzVHIzS8tyYjligUAMhEd0g==">'
end
it
'does not replace nomnoml pre tag with img tag if kroki is disabled'
do
stub_application_setting
(
kroki_enabled:
false
)
doc
=
filter
(
"<pre lang='nomnoml'><code>[Pirate|eyeCount: Int|raid();pillage()|
\n
[beard]--[parrot]
\n
[beard]-:>[foul mouth]
\n
]</code></pre>"
)
expect
(
doc
.
to_s
).
to
eq
"<pre lang=
\"
nomnoml
\"
><code>[Pirate|eyeCount: Int|raid();pillage()|
\n
[beard]--[parrot]
\n
[beard]-:>[foul mouth]
\n
]</code></pre>"
end
it
'does not replace plantuml pre tag with img tag if both kroki and plantuml are enabled'
do
stub_application_setting
(
kroki_enabled:
true
,
kroki_url:
"http://localhost:8000"
,
plantuml_enabled:
true
,
plantuml_url:
"http://localhost:8080"
)
doc
=
filter
(
"<pre lang='plantuml'><code>Bob->Alice : hello</code></pre>"
)
expect
(
doc
.
to_s
).
to
eq
'<pre lang="plantuml"><code>Bob->Alice : hello</code></pre>'
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