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
dbd633b6
Commit
dbd633b6
authored
Sep 23, 2014
by
RawKStar77
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Break up long lines of code over multiple lines
parent
f4ceb8d0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
7 deletions
+22
-7
markdown.coffee
h/static/scripts/directives/markdown.coffee
+22
-7
No files found.
h/static/scripts/directives/markdown.coffee
View file @
dbd633b6
...
...
@@ -53,7 +53,10 @@ markdown = ['$filter', '$timeout', ($filter, $timeout) ->
slice2
=
text
.
after
.
slice
(
0
,
markup
.
length
)
if
slice1
==
markup
and
slice2
==
markup
# Remove markup
newtext
=
text
.
before
.
slice
(
0
,
(
text
.
before
.
length
-
markup
.
length
))
+
text
.
selection
+
text
.
after
.
slice
(
markup
.
length
)
newtext
=
(
text
.
before
.
slice
(
0
,
(
text
.
before
.
length
-
markup
.
length
))
+
text
.
selection
+
text
.
after
.
slice
(
markup
.
length
)
)
start
=
text
.
before
.
length
-
markup
.
length
end
=
(
text
.
before
+
text
.
selection
).
length
-
markup
.
length
insertMarkup
(
newtext
,
start
,
end
)
...
...
@@ -148,7 +151,10 @@ markdown = ['$filter', '$timeout', ($filter, $timeout) ->
# The partial selection happens to fall on the firstline
newstring
=
markup
+
newstring
else
newstring
=
newstring
.
substring
(
0
,
(
indexoflastnewline
+
1
))
+
markup
+
newstring
.
substring
(
indexoflastnewline
+
1
)
newstring
=
(
newstring
.
substring
(
0
,
(
indexoflastnewline
+
1
))
+
markup
+
newstring
.
substring
(
indexoflastnewline
+
1
)
)
value
=
newstring
+
text
.
after
start
=
(
text
.
before
+
markup
).
length
end
=
(
text
.
before
+
text
.
selection
+
markup
).
length
...
...
@@ -167,10 +173,13 @@ markdown = ['$filter', '$timeout', ($filter, $timeout) ->
end
=
(
text
.
before
+
markup
).
length
insertMarkup
(
value
,
start
,
end
)
else
# No selection, cursor is not on new line.
Go to the previous newline and insert markup there.
#
#
Check to see if markup has already been inserted.
# No selection, cursor is not on new line.
# Check to see if markup has already been inserted.
if
text
.
before
.
slice
(
text
.
before
.
length
-
markup
.
length
)
==
markup
newtext
=
text
.
before
.
substring
(
0
,
(
index
))
+
"
\n
"
+
text
.
before
.
substring
(
index
+
1
+
markup
.
length
)
+
text
.
after
newtext
=
(
text
.
before
.
substring
(
0
,
(
index
))
+
"
\n
"
+
text
.
before
.
substring
(
index
+
1
+
markup
.
length
)
+
text
.
after
)
i
=
0
for
char
in
text
.
before
if
char
==
"
\n
"
and
i
!=
0
...
...
@@ -190,12 +199,18 @@ markdown = ['$filter', '$timeout', ($filter, $timeout) ->
insertMarkup
(
newtext
,
start
,
end
)
# Check to see if markup has already been inserted and undo it.
else
if
text
.
before
.
slice
((
index
+
1
),
(
index
+
1
+
markup
.
length
))
==
markup
newtext
=
text
.
before
.
substring
(
0
,
(
index
))
+
"
\n
"
+
text
.
before
.
substring
(
index
+
1
+
markup
.
length
)
+
text
.
after
newtext
=
(
text
.
before
.
substring
(
0
,
(
index
))
+
"
\n
"
+
text
.
before
.
substring
(
index
+
1
+
markup
.
length
)
+
text
.
after
)
start
=
text
.
before
.
length
-
markup
.
length
end
=
text
.
before
.
length
-
markup
.
length
insertMarkup
(
newtext
,
start
,
end
)
else
newtext
=
text
.
before
.
substring
(
0
,
(
index
))
+
"
\n
"
+
markup
+
text
.
before
.
substring
(
index
+
1
)
+
text
.
after
newtext
=
(
text
.
before
.
substring
(
0
,
(
index
))
+
"
\n
"
+
markup
+
text
.
before
.
substring
(
index
+
1
)
+
text
.
after
)
start
=
(
text
.
before
+
markup
).
length
end
=
(
text
.
before
+
markup
).
length
insertMarkup
(
newtext
,
start
,
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