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
d50f41d0
Commit
d50f41d0
authored
Jul 16, 2019
by
Martin Hanzel
Committed by
Kushal Pandya
Jul 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix linebreak rendering in Mermaid flowcharts
parent
38aa79de
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
1 deletion
+25
-1
app/assets/javascripts/behaviors/markdown/render_mermaid.js
app/assets/javascripts/behaviors/markdown/render_mermaid.js
+2
-1
changelogs/unreleased/mh-mermaid-linebreaks.yml
changelogs/unreleased/mh-mermaid-linebreaks.yml
+5
-0
spec/features/markdown/mermaid_spec.rb
spec/features/markdown/mermaid_spec.rb
+18
-0
No files found.
app/assets/javascripts/behaviors/markdown/render_mermaid.js
View file @
d50f41d0
...
...
@@ -36,7 +36,8 @@ export default function renderMermaid($els) {
});
$els
.
each
((
i
,
el
)
=>
{
const
source
=
el
.
textContent
;
// Mermaid doesn't like `<br />` tags, so collapse all like tags into `<br>`, which is parsed correctly.
const
source
=
el
.
textContent
.
replace
(
/<br
\s
*
\/
>/g
,
'
<br>
'
);
/**
* Restrict the rendering to a certain amount of character to
...
...
changelogs/unreleased/mh-mermaid-linebreaks.yml
0 → 100644
View file @
d50f41d0
---
title
:
Fix linebreak rendering in Mermaid flowcharts
merge_request
:
30730
author
:
type
:
fixed
spec/features/markdown/mermaid_spec.rb
View file @
d50f41d0
...
...
@@ -21,4 +21,22 @@ describe 'Mermaid rendering', :js do
expect
(
page
).
to
have_selector
(
'svg text'
,
text:
label
)
end
end
it
'renders linebreaks in Mermaid diagrams'
do
description
=
<<~
MERMAID
```mermaid
graph TD;
A(Line 1<br>Line 2)-->B(Line 1<br/>Line 2);
C(Line 1<br />Line 2)-->D(Line 1<br />Line 2);
```
MERMAID
project
=
create
(
:project
,
:public
)
issue
=
create
(
:issue
,
project:
project
,
description:
description
)
visit
project_issue_path
(
project
,
issue
)
expected
=
'<text><tspan xml:space="preserve" dy="1em" x="1">Line 1</tspan><tspan xml:space="preserve" dy="1em" x="1">Line 2</tspan></text>'
expect
(
page
.
html
.
scan
(
expected
).
count
).
to
be
(
4
)
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