BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
a30d957f
Commit
a30d957f
authored
Apr 13, 2017
by
Jacob Schatz
Committed by
Felipe Artur
Apr 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge branch 'notebook-katex-rendering-improvements' into 'master'
Correctly parse katex math in IPyhton notebooks Closes #30900 See merge request !10678
parent
af5656ed
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
15 deletions
+44
-15
notebooklab.js
vendor/assets/javascripts/notebooklab.js
+44
-15
No files found.
vendor/assets/javascripts/notebooklab.js
View file @
a30d957f
...
...
@@ -699,6 +699,48 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
//
//
var
renderer
=
new
_marked2
.
default
.
Renderer
();
/*
Regex to match KaTex blocks.
Supports the following:
\begin{equation}<math>\end{equation}
$$<math>$$
inline $<math>$
The matched text then goes through the KaTex renderer & then outputs the HTML
*/
var
katexRegexString
=
'(
\
n ^
\\\\
begin{[a-zA-Z]+}
\\
s
\
n |
\
n ^
\\
$
\\
$
\
n |
\
n
\\
s
\\
$(?!
\\
$)
\
n)
\
n (.+?)
\
n(
\
n
\\
s
\\\\
end{[a-zA-Z]+}$
\
n |
\
n
\\
$
\\
$$
\
n |
\
n
\\
$
\
n)
\
n'
.
replace
(
/
\s
/g
,
''
).
trim
();
renderer
.
paragraph
=
function
(
t
)
{
var
text
=
t
;
var
inline
=
false
;
if
(
typeof
katex
!==
'undefined'
)
{
var
katexString
=
text
.
replace
(
/
\\
/g
,
'
\
\'
);
var matches = new RegExp(katexRegexString, '
gi
').exec(katexString);
if (matches && matches.length > 0) {
if (matches[1].trim() === '
$
' && matches[3].trim() === '
$
') {
inline = true;
text = katexString.replace(matches[0], '') + '
' + katex.renderToString(matches[2]);
} else {
text = katex.renderToString(matches[2]);
}
}
}
return '
<
p
class
=
"' + (inline ? 'inline-katex' : '') + '"
>
' + text + '
<
/p>'
;
};
_marked2
.
default
.
setOptions
({
sanitize
:
true
,
renderer
:
renderer
});
exports
.
default
=
{
components
:
{
prompt
:
_prompt2
.
default
...
...
@@ -711,20 +753,7 @@ exports.default = {
},
computed
:
{
markdown
:
function
markdown
()
{
var
regex
=
new
RegExp
(
'^
\\
$
\\
$(.*)
\\
$
\\
$$'
,
'g'
);
var
source
=
this
.
cell
.
source
.
map
(
function
(
line
)
{
var
matches
=
regex
.
exec
(
line
.
trim
());
// Only render use the Katex library if it is actually loaded
if
(
matches
&&
matches
.
length
>
0
&&
typeof
katex
!==
'undefined'
)
{
return
katex
.
renderToString
(
matches
[
1
]);
}
return
line
;
});
return
(
0
,
_marked2
.
default
)(
source
.
join
(
''
));
return
(
0
,
_marked2
.
default
)(
this
.
cell
.
source
.
join
(
''
));
}
}
};
...
...
@@ -3047,7 +3076,7 @@ exports = module.exports = __webpack_require__(1)(undefined);
// module
exports
.
push
([
module
.
i
,
".markdown .katex{display:block;text-align:center}"
,
""
]);
exports
.
push
([
module
.
i
,
".markdown .katex{display:block;text-align:center}
.markdown .inline-katex .katex{display:inline;text-align:initial}
"
,
""
]);
// exports
...
...
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