Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
ac4952c5
Commit
ac4952c5
authored
Oct 18, 2014
by
RawKStar77
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle edge case in scope.insertMath() rather than applyInlineMarkup()
parent
7eb036d5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
markdown.coffee
h/static/scripts/directives/markdown.coffee
+6
-5
No files found.
h/static/scripts/directives/markdown.coffee
View file @
ac4952c5
...
@@ -65,10 +65,7 @@ markdown = ['$filter', '$sanitize', '$sce', '$timeout', ($filter, $sanitize, $sc
...
@@ -65,10 +65,7 @@ markdown = ['$filter', '$sanitize', '$sce', '$timeout', ($filter, $sanitize, $sc
# Check to see if markup has already been applied before to the selection.
# Check to see if markup has already been applied before to the selection.
slice1
=
text
.
before
.
slice
(
text
.
before
.
length
-
markupL
.
length
)
slice1
=
text
.
before
.
slice
(
text
.
before
.
length
-
markupL
.
length
)
slice2
=
text
.
after
.
slice
(
0
,
markupR
.
length
)
slice2
=
text
.
after
.
slice
(
0
,
markupR
.
length
)
# Edge case: scope.insertMath() is called for inline and block markup, to avoid a case
if
(
slice1
==
markupL
and
slice2
==
markupR
)
# in which pressing the math button to remove block math markup adds inline math inside of
# block math $$\(LaTex or MathML\)$$ we check for $$ here.
if
(
slice1
==
markupL
and
slice2
==
markupR
)
or
(
slice1
==
'$$'
and
slice2
==
'$$'
)
# Remove markup
# Remove markup
newtext
=
(
newtext
=
(
text
.
before
.
slice
(
0
,
(
text
.
before
.
length
-
markupL
.
length
))
+
text
.
before
.
slice
(
0
,
(
text
.
before
.
length
-
markupL
.
length
))
+
...
@@ -93,7 +90,11 @@ markdown = ['$filter', '$sanitize', '$sce', '$timeout', ($filter, $sanitize, $sc
...
@@ -93,7 +90,11 @@ markdown = ['$filter', '$sanitize', '$sce', '$timeout', ($filter, $sanitize, $sc
scope
.
insertMath
=
->
scope
.
insertMath
=
->
text
=
userSelection
()
text
=
userSelection
()
index
=
text
.
before
.
length
index
=
text
.
before
.
length
if
index
==
0
or
input
.
value
[
index
-
1
]
==
'
\n
'
if
(
index
==
0
or
input
.
value
[
index
-
1
]
==
'
\n
'
or
(
input
.
value
[
index
-
1
]
==
'$'
and
input
.
value
[
index
-
2
]
==
'$'
)
)
applyInlineMarkup
(
'$$'
,
'LaTeX or MathML'
)
applyInlineMarkup
(
'$$'
,
'LaTeX or MathML'
)
else
else
applyInlineMarkup
(
'
\\
('
,
'LaTeX or MathML'
,
'
\\
)'
)
applyInlineMarkup
(
'
\\
('
,
'LaTeX or MathML'
,
'
\\
)'
)
...
...
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