Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CodeMirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Moritz Aurel Pascal Schubotz
CodeMirror
Commits
e367de8a
Commit
e367de8a
authored
9 years ago
by
Marijn Haverbeke
Browse files
Options
Downloads
Patches
Plain Diff
[markdown mode] Don't get confused when the start of line is multiplexed away
Issue #3535
parent
ece5c232
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mode/markdown/markdown.js
+20
-15
20 additions, 15 deletions
mode/markdown/markdown.js
with
20 additions
and
15 deletions
mode/markdown/markdown.js
+
20
−
15
View file @
e367de8a
...
...
@@ -86,6 +86,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
return
f
(
stream
,
state
);
}
function
lineIsEmpty
(
line
)
{
return
!
line
||
!
/
\S
/
.
test
(
line
.
string
)
}
// Blocks
...
...
@@ -110,7 +113,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
state
.
trailingSpace
=
0
;
state
.
trailingSpaceNewLine
=
false
;
// Mark this line as blank
state
.
thisLineHasContent
=
false
;
state
.
prevLine
=
state
.
thisLine
state
.
thisLine
=
null
return
null
;
}
...
...
@@ -141,7 +145,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
var
match
=
null
;
if
(
state
.
indentationDiff
>=
4
)
{
stream
.
skipToEnd
();
if
(
prevLineIsIndentedCode
||
!
state
.
prevLine
HasContent
)
{
if
(
prevLineIsIndentedCode
||
lineIsEmpty
(
state
.
prevLine
)
)
{
state
.
indentation
-=
4
;
state
.
indentedCode
=
true
;
return
code
;
...
...
@@ -155,7 +159,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
if
(
modeCfg
.
highlightFormatting
)
state
.
formatting
=
"
header
"
;
state
.
f
=
state
.
inline
;
return
getType
(
state
);
}
else
if
(
state
.
prevLineHasContent
&&
!
state
.
quote
&&
!
prevLineIsList
&&
!
prevLineIsIndentedCode
&&
(
match
=
stream
.
match
(
setextHeaderRE
)))
{
}
else
if
(
!
lineIsEmpty
(
state
.
prevLine
)
&&
!
state
.
quote
&&
!
prevLineIsList
&&
!
prevLineIsIndentedCode
&&
(
match
=
stream
.
match
(
setextHeaderRE
)))
{
state
.
header
=
match
[
0
].
charAt
(
0
)
==
'
=
'
?
1
:
2
;
if
(
modeCfg
.
highlightFormatting
)
state
.
formatting
=
"
header
"
;
state
.
f
=
state
.
inline
;
...
...
@@ -170,7 +175,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
}
else
if
(
stream
.
match
(
hrRE
,
true
))
{
state
.
hr
=
true
;
return
hr
;
}
else
if
((
!
state
.
prevLine
HasContent
||
prevLineIsList
)
&&
(
stream
.
match
(
ulRE
,
false
)
||
stream
.
match
(
olRE
,
false
)))
{
}
else
if
((
lineIsEmpty
(
state
.
prevLine
)
||
prevLineIsList
)
&&
(
stream
.
match
(
ulRE
,
false
)
||
stream
.
match
(
olRE
,
false
)))
{
var
listType
=
null
;
if
(
stream
.
match
(
ulRE
,
true
))
{
listType
=
'
ul
'
;
...
...
@@ -656,8 +661,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
return
{
f
:
blockNormal
,
prevLine
HasContent
:
false
,
thisLine
HasContent
:
false
,
prevLine
:
null
,
thisLine
:
null
,
block
:
blockNormal
,
htmlState
:
null
,
...
...
@@ -688,8 +693,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
return
{
f
:
s
.
f
,
prevLine
HasContent
:
s
.
prevLine
HasContent
,
thisLine
HasContent
:
s
.
thisLineHasContent
,
prevLine
:
s
.
prevLine
,
thisLine
:
s
.
this
,
block
:
s
.
block
,
htmlState
:
s
.
htmlState
&&
CodeMirror
.
copyState
(
htmlMode
,
s
.
htmlState
),
...
...
@@ -724,22 +729,22 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
// Reset state.formatting
state
.
formatting
=
false
;
if
(
stream
.
sol
()
)
{
var
forceBlankLine
=
!!
state
.
header
||
state
.
hr
;
if
(
stream
!=
state
.
thisLine
)
{
var
forceBlankLine
=
state
.
header
||
state
.
hr
;
// Reset state.header and state.hr
state
.
header
=
0
;
state
.
hr
=
false
;
if
(
stream
.
match
(
/^
\s
*$/
,
true
)
||
forceBlankLine
)
{
state
.
prevLineHasContent
=
false
;
blankLine
(
state
);
return
forceBlankLine
?
this
.
token
(
stream
,
state
)
:
null
;
}
else
{
state
.
prevLineHasContent
=
state
.
thisLineHasContent
;
state
.
thisLineHasContent
=
true
;
if
(
!
forceBlankLine
)
return
null
state
.
prevLine
=
null
}
state
.
prevLine
=
state
.
thisLine
state
.
thisLine
=
stream
// Reset state.taskList
state
.
taskList
=
false
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment