Skip to content

Commit c2fd649

Browse files
author
koneal
committed
fixes #6 hash character not at beginning of line
1 parent 244a782 commit c2fd649

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

autoload/levels.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ endfunction
7373

7474
" TODO: don't pass in outline
7575
function! Header(outline, line, lNum) abort
76-
let l:pattern = '\v(#+)\s*(.*)'
76+
let l:pattern = '\v^\s*(#+)\s*(.*)'
7777
let l:matches = matchlist(a:line, l:pattern)
7878

7979
let l:max_levels = get(g:, 'markdrawer_drawer_max_levels', 6)

ftplugin/markdown.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
" Maintainer: Kevin O'Neal oneal.kevin@gmail.com
2-
" Version: 0.1
2+
" Version: 0.3
33

44
if !exists('g:markdrawer_prefix')
55
let g:markdrawer_prefix = ' '

test/header.vader

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
11
Before:
2-
let pattern = '\v(#+)\s*(.*)'
2+
let pattern = '\v^\s*(#+)\s*(.*)'
33

44
Execute(simple header) :
55
let actual = matchlist('# first', pattern)
6-
AssertEqual actual[1], '#'
7-
AssertEqual actual[2], 'first'
6+
Assert len(actual) > 0, 'no matches found'
7+
AssertEqual '#', actual[1]
8+
AssertEqual 'first', actual[2]
89

9-
Execute(space in front ) :
10+
Execute(suport for space in front ) :
1011
let actual = matchlist(' ## second', pattern)
11-
AssertEqual actual[1], '##'
12-
AssertEqual actual[2], 'second'
12+
Assert len(actual) > 0, 'no matches found'
13+
AssertEqual '##', actual[1]
14+
AssertEqual 'second', actual[2]
1315

1416
Execute(crammed together) :
15-
let actual = matchlist(' ###third', pattern)
16-
AssertEqual actual[1], '###'
17-
AssertEqual actual[2], 'third'
17+
let actual = matchlist('###third', pattern)
18+
Assert len(actual) > 0, 'no matches found'
19+
AssertEqual '###', actual[1]
20+
AssertEqual 'third', actual[2]
1821

1922
Execute(no match found) :
2023
let actual = matchlist(' blah', pattern)
21-
Assert len(actual) == 0
24+
Assert len(actual) == 0, 'should be empty'
25+
26+
Execute(hash not in front) :
27+
let actual = matchlist('scary #', pattern)
28+
Assert len(actual) == 0, 'should be empty'
29+
30+
Execute(escaped hash) :
31+
let actual = matchlist('`#`', pattern)
32+
Assert len(actual) == 0, 'should be empty'
2233

test/simple.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ else
1212
### Second Sub Empty
1313

1414
## Moving
15-
moving row 1
15+
moving row 1 # should not see this
1616
moving row 2
1717
## First of Second
1818
Lorem Ipsum with
@@ -21,4 +21,5 @@ lines
2121
# Second Main
2222
A List
2323
- one
24-
- two
24+
- two
25+
`#` funky stuff

0 commit comments

Comments
 (0)