Skip to content

Commit 4b5e197

Browse files
committed
Add space in header regex
1 parent 3a96439 commit 4b5e197

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

ftplugin/markdown.vim

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,20 @@
4848
" For each level, contains the regexp that matches at that level only.
4949
"
5050
let s:levelRegexpDict = {
51-
\ 1: '\v^(#[^#]@=|.+\n\=+$)',
52-
\ 2: '\v^(##[^#]@=|.+\n-+$)',
53-
\ 3: '\v^###[^#]@=',
54-
\ 4: '\v^####[^#]@=',
55-
\ 5: '\v^#####[^#]@=',
56-
\ 6: '\v^######[^#]@='
51+
\ 1: '\v^(#[^#]@=\s+|.+\n\=+$)',
52+
\ 2: '\v^(##[^#]@=\s+|.+\n-+$)',
53+
\ 3: '\v^###[^#]@=\s+',
54+
\ 4: '\v^####[^#]@=\s+',
55+
\ 5: '\v^#####[^#]@=\s+',
56+
\ 6: '\v^######[^#]@=\s+'
5757
\ }
5858

5959
" Maches any header level of any type.
6060
"
6161
" This could be deduced from `s:levelRegexpDict`, but it is more
6262
" efficient to have a single regexp for this.
6363
"
64-
let s:headersRegexp = '\v^(#|.+\n(\=+|-+)$)'
64+
let s:headersRegexp = '\v^(#{1,6}\s+|.+\n(\=+|-+)$)'
6565

6666
" Returns the line number of the first header before `line`, called the
6767
" current header.

test/map.vader

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,16 @@ Given markdown;
9494

9595
b
9696

97+
#ignore
98+
9799
# c
98100

99101
d
100102

101103
Execute (]] same level):
102104
AssertEqual line('.'), 1
103105
normal ]]
104-
AssertEqual line('.'), 5
106+
AssertEqual line('.'), 7
105107
normal [[
106108
AssertEqual line('.'), 1
107109

@@ -110,14 +112,16 @@ Given markdown;
110112

111113
b
112114

115+
##ignore
116+
113117
## c
114118

115119
d
116120

117121
Execute (]] different levels level):
118122
AssertEqual line('.'), 1
119123
normal ]]
120-
AssertEqual line('.'), 5
124+
AssertEqual line('.'), 7
121125
normal [[
122126
AssertEqual line('.'), 1
123127

@@ -126,6 +130,8 @@ Given markdown;
126130

127131
b
128132

133+
#ignore
134+
129135
## c
130136

131137
d
@@ -137,7 +143,7 @@ f
137143
Execute (][ different levels level):
138144
AssertEqual line('.'), 1
139145
normal ][
140-
AssertEqual line('.'), 9
146+
AssertEqual line('.'), 11
141147
normal []
142148
AssertEqual line('.'), 1
143149

test/toc.vader

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,11 @@ Execute (Toc multiple headers):
138138

139139
Expect (multiple headers):
140140
h1 space
141-
h1 nospace
142141
h1 2 spaces
143142
h1 trailing hash
144143
h2 space
145-
h2 nospace
146144
h2 trailing hash
147145
h3 space
148-
h3 nospace
149146
h3 trailing hash
150147
h4
151148
h5

0 commit comments

Comments
 (0)