File tree 3 files changed +100
-4
lines changed
3 files changed +100
-4
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ def get_toc_open_tag(self):
74
74
return toc_open_tags
75
75
76
76
def get_toc_close_tag (self , start ):
77
- close_tags = self .view .find_all ("^ <!-- /MarkdownTOC -->\n " )
77
+ close_tags = self .view .find_all (r' <!--[\s\n]+ /MarkdownTOC[\s\n]+ -->\n' )
78
78
close_tags = self .remove_items_in_codeblock (close_tags )
79
79
for close_tag in close_tags :
80
80
if start < close_tag .begin ():
Original file line number Diff line number Diff line change @@ -39,13 +39,13 @@ def moveTo(self, pos):
39
39
def getTOC_text (self ):
40
40
"""Find TOC in the document, and return the list texts in it."""
41
41
toc_region = self .view .find (
42
- " <!-- MarkdownTOC . *-->(.|\n )+?<!-- /MarkdownTOC -->" ,
42
+ r' <!--[\s\n]+ MarkdownTOC[\s\n]+[^>] *-->\n (.|\n)+?<!--[\s\n]+ /MarkdownTOC[\s\n]+ -->' ,
43
43
sublime .IGNORECASE )
44
44
toc_all = self .view .substr (toc_region )
45
45
46
46
# pick toc contents
47
- toc_contents = re .sub (r'<!-- MarkdownTOC .* -->' , '' , toc_all )
48
- toc_contents = re .sub (r'<!-- /MarkdownTOC -->' , '' , toc_contents )
47
+ toc_contents = re .sub (r'<!--[\s\n]+ MarkdownTOC[\s\n]+[^>]* -->' , '' , toc_all )
48
+ toc_contents = re .sub (r'<!--[\s\n]+ /MarkdownTOC[\s\n]+ -->' , '' , toc_contents )
49
49
toc_contents = toc_contents .rstrip ()
50
50
51
51
return toc_contents
Original file line number Diff line number Diff line change
1
+ # coding:utf-8
2
+ from base import TestBase
3
+
4
+ class TagVariation (TestBase ):
5
+ """Test for attributes 'style'"""
6
+
7
+ # for debug
8
+ # def tearDown(self):
9
+ # pass
10
+
11
+ def test_1 (self ):
12
+ """Tag Variation 1"""
13
+ text = \
14
+ """
15
+
16
+ <!-- MarkdownTOC autolink="true" bracket="square" style="ordered" -->
17
+
18
+ <!-- /MarkdownTOC -->
19
+
20
+ # foo
21
+ """
22
+ toc = self .init_update (text )['toc' ]
23
+ self .assert_In ('1. [foo][foo]' , toc )
24
+
25
+ def test_2 (self ):
26
+ """Tag Variation 2"""
27
+ text = \
28
+ """
29
+
30
+ <!-- MarkdownTOC
31
+ autolink="true" bracket="square" style="ordered" -->
32
+
33
+ <!-- /MarkdownTOC -->
34
+
35
+ # foo
36
+ """
37
+ toc = self .init_update (text )['toc' ]
38
+ self .assert_In ('1. [foo][foo]' , toc )
39
+
40
+ def test_3 (self ):
41
+ """Tag Variation 3"""
42
+ text = \
43
+ """
44
+
45
+ <!--
46
+ MarkdownTOC
47
+ autolink="true"
48
+ bracket="square"
49
+ style="ordered" -->
50
+
51
+ <!-- /MarkdownTOC -->
52
+
53
+ # foo
54
+ """
55
+ toc = self .init_update (text )['toc' ]
56
+ self .assert_In ('1. [foo][foo]' , toc )
57
+
58
+ def test_4 (self ):
59
+ """Tag Variation 4"""
60
+ text = \
61
+ """
62
+
63
+ <!--
64
+ MarkdownTOC
65
+ autolink="true"
66
+ bracket="square"
67
+ style="ordered"
68
+ -->
69
+
70
+ <!-- /MarkdownTOC -->
71
+
72
+ # foo
73
+ """
74
+ toc = self .init_update (text )['toc' ]
75
+ self .assert_In ('1. [foo][foo]' , toc )
76
+
77
+ def test_5 (self ):
78
+ """Tag Variation 5"""
79
+ text = \
80
+ """
81
+
82
+ <!--
83
+ MarkdownTOC
84
+ autolink="true"
85
+ bracket="square"
86
+ style="ordered"
87
+ -->
88
+
89
+ <!--
90
+ /MarkdownTOC
91
+ -->
92
+
93
+ # foo
94
+ """
95
+ toc = self .init_update (text )['toc' ]
96
+ self .assert_In ('1. [foo][foo]' , toc )
You can’t perform that action at this time.
0 commit comments