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
Tatuya Kamada
gitlab-ce
Commits
359c4176
Commit
359c4176
authored
Jan 19, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly copy/paste allowed HTML
parent
5bc46716
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
0 deletions
+53
-0
app/assets/javascripts/copy_as_gfm.js.es6
app/assets/javascripts/copy_as_gfm.js.es6
+22
-0
spec/features/copy_as_gfm_spec.rb
spec/features/copy_as_gfm_spec.rb
+31
-0
No files found.
app/assets/javascripts/copy_as_gfm.js.es6
View file @
359c4176
...
...
@@ -91,6 +91,28 @@
return text.trim();
},
},
SanitizationFilter: {
'br'(el, text) {
return '<br>';
},
'dl'(el, text) {
let lines = text.trim().split('\n');
// Add two spaces to the front of subsequent list items lines,
// or leave the line entirely blank.
lines = lines.map((s) => {
s = s.trim();
if (s.length === 0) return '';
return ` ${s}`;
});
return `<dl>\n${lines.join('\n')}\n</dl>`;
},
'sub, dt, dd, kbd, q, samp, var, ruby, rt, rp, abbr'(el, text) {
const tag = el.nodeName.toLowerCase();
return `<${tag}>${text}</${tag}>`;
},
},
SyntaxHighlightFilter: {
'pre.code.highlight'(el, text) {
let lang = el.getAttribute('lang');
...
...
spec/features/copy_as_gfm_spec.rb
View file @
359c4176
...
...
@@ -233,6 +233,37 @@ describe 'Copy as GFM', feature: true, js: true do
end
end
it
'supports SanitizationFilter'
do
verify
(
<<-
GFM
.
strip_heredoc
BR: <br>
<sub>sub</sub>
<dl>
<dt>dt</dt>
<dd>dd</dd>
</dl>
<kbd>kbd</kbd>
<q>q</q>
<samp>samp</samp>
<var>var</var>
<ruby>ruby</ruby>
<rt>rt</rt>
<rp>rp</rp>
<abbr>abbr</abbr>
GFM
)
end
it
'supports SyntaxHighlightFilter'
do
verify
(
<<-
GFM
.
strip_heredoc
,
...
...
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