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
Léo-Paul Géneau
gitlab-ce
Commits
ffd7fbf5
Commit
ffd7fbf5
authored
Nov 22, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved to es6 modules
parent
1374da4c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
50 deletions
+45
-50
app/assets/javascripts/render_gfm.js
app/assets/javascripts/render_gfm.js
+4
-4
app/assets/javascripts/render_math.js
app/assets/javascripts/render_math.js
+35
-40
app/assets/javascripts/render_mermaid.js
app/assets/javascripts/render_mermaid.js
+6
-4
spec/javascripts/notes_spec.js
spec/javascripts/notes_spec.js
+0
-2
No files found.
app/assets/javascripts/render_gfm.js
View file @
ffd7fbf5
import
'
./render_math
'
;
import
renderMath
from
'
./render_math
'
;
import
'
./render_mermaid
'
;
import
renderMermaid
from
'
./render_mermaid
'
;
// Render Gitlab flavoured Markdown
// Render Gitlab flavoured Markdown
//
//
...
@@ -7,8 +7,8 @@ import './render_mermaid';
...
@@ -7,8 +7,8 @@ import './render_mermaid';
//
//
$
.
fn
.
renderGFM
=
function
renderGFM
()
{
$
.
fn
.
renderGFM
=
function
renderGFM
()
{
this
.
find
(
'
.js-syntax-highlight
'
).
syntaxHighlight
();
this
.
find
(
'
.js-syntax-highlight
'
).
syntaxHighlight
();
this
.
find
(
'
.js-render-math
'
).
renderMath
(
);
renderMath
(
this
.
find
(
'
.js-render-math
'
)
);
this
.
find
(
'
.js-render-mermaid
'
).
renderMermaid
(
);
renderMermaid
(
this
.
find
(
'
.js-render-mermaid
'
)
);
return
this
;
return
this
;
};
};
...
...
app/assets/javascripts/render_math.js
View file @
ffd7fbf5
/* eslint-disable func-names, space-before-function-paren, consistent-return, no-var, no-else-return, prefer-arrow-callback, max-len, no-console */
/* global katex */
/* global katex */
// Renders math using KaTeX in any element with the
// Renders math using KaTeX in any element with the
...
@@ -8,49 +7,45 @@
...
@@ -8,49 +7,45 @@
//
//
// <code class="js-render-math"></div>
// <code class="js-render-math"></div>
//
//
(
function
()
{
// Only load once
// Only load once
var
katexLoaded
=
false
;
let
katexLoaded
=
false
;
// Loop over all math elements and render math
// Loop over all math elements and render math
var
renderWithKaTeX
=
function
(
elements
)
{
function
renderWithKaTeX
(
elements
)
{
elements
.
each
(
function
()
{
elements
.
each
(
function
katexElementsLoop
()
{
var
mathNode
=
$
(
'
<span></span>
'
);
const
mathNode
=
$
(
'
<span></span>
'
);
var
$this
=
$
(
this
);
const
$this
=
$
(
this
);
var
display
=
$this
.
attr
(
'
data-math-style
'
)
===
'
display
'
;
const
display
=
$this
.
attr
(
'
data-math-style
'
)
===
'
display
'
;
try
{
try
{
katex
.
render
(
$this
.
text
(),
mathNode
.
get
(
0
),
{
displayMode
:
display
});
katex
.
render
(
$this
.
text
(),
mathNode
.
get
(
0
),
{
displayMode
:
display
});
mathNode
.
insertAfter
(
$this
);
mathNode
.
insertAfter
(
$this
);
$this
.
remove
();
$this
.
remove
();
}
catch
(
err
)
{
}
catch
(
err
)
{
// What can we do??
throw
err
;
console
.
log
(
err
.
message
);
}
}
});
});
};
}
$
.
fn
.
renderMath
=
function
()
{
export
default
function
renderMath
(
$els
)
{
var
$this
=
this
;
if
(
!
$els
.
length
)
return
;
if
(
$this
.
length
===
0
)
return
;
if
(
katexLoaded
)
renderWithKaTeX
(
$this
);
if
(
katexLoaded
)
{
else
{
renderWithKaTeX
(
$els
);
// Request CSS file so it is in the cache
}
else
{
$
.
get
(
gon
.
katex_css_url
,
function
()
{
$
.
get
(
gon
.
katex_css_url
,
()
=>
{
var
css
=
$
(
'
<link>
'
,
const
css
=
$
(
'
<link>
'
,
{
{
rel
:
'
stylesheet
'
,
rel
:
'
stylesheet
'
,
type
:
'
text/css
'
,
type
:
'
text/css
'
,
href
:
gon
.
katex_css_url
,
href
:
gon
.
katex_css_url
,
});
});
css
.
appendTo
(
'
head
'
);
css
.
appendTo
(
'
head
'
);
// Load KaTeX js
// Load KaTeX js
$
.
getScript
(
gon
.
katex_js_url
,
function
()
{
$
.
getScript
(
gon
.
katex_js_url
,
()
=>
{
katexLoaded
=
true
;
katexLoaded
=
true
;
renderWithKaTeX
(
$thi
s
);
// Run KaTeX
renderWithKaTeX
(
$el
s
);
// Run KaTeX
});
});
});
});
}
}
};
}
}).
call
(
window
);
app/assets/javascripts/render_mermaid.js
View file @
ffd7fbf5
...
@@ -14,8 +14,8 @@
...
@@ -14,8 +14,8 @@
import
Flash
from
'
./flash
'
;
import
Flash
from
'
./flash
'
;
$
.
fn
.
renderMermaid
=
function
renderMermaid
(
)
{
export
default
function
renderMermaid
(
$els
)
{
if
(
this
.
length
===
0
)
return
;
if
(
!
$els
.
length
)
return
;
import
(
/* webpackChunkName: 'mermaid' */
'
blackst0ne-mermaid
'
).
then
((
mermaid
)
=>
{
import
(
/* webpackChunkName: 'mermaid' */
'
blackst0ne-mermaid
'
).
then
((
mermaid
)
=>
{
mermaid
.
initialize
({
mermaid
.
initialize
({
...
@@ -23,8 +23,10 @@ $.fn.renderMermaid = function renderMermaid() {
...
@@ -23,8 +23,10 @@ $.fn.renderMermaid = function renderMermaid() {
theme
:
'
neutral
'
,
theme
:
'
neutral
'
,
});
});
mermaid
.
init
(
undefined
,
this
);
$els
.
each
((
i
,
el
)
=>
{
mermaid
.
init
(
undefined
,
el
);
});
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
Flash
(
`Can't load mermaid module:
${
err
}
`
);
Flash
(
`Can't load mermaid module:
${
err
}
`
);
});
});
}
;
}
spec/javascripts/notes_spec.js
View file @
ffd7fbf5
...
@@ -4,8 +4,6 @@
...
@@ -4,8 +4,6 @@
import
'
autosize
'
;
import
'
autosize
'
;
import
'
~/gl_form
'
;
import
'
~/gl_form
'
;
import
'
~/lib/utils/text_utility
'
;
import
'
~/lib/utils/text_utility
'
;
import
'
~/render_math
'
;
import
'
~/render_mermaid
'
;
import
'
~/render_gfm
'
;
import
'
~/render_gfm
'
;
import
'
~/notes
'
;
import
'
~/notes
'
;
...
...
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