File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ const removeMarkdownToken = str => String(str)
18
18
. replace ( / ( \\ ) ( \* | _ | ` ) / g, '$2' ) // remove escape char '\'
19
19
20
20
exports . removeTailHtml = ( str ) => {
21
- return String ( str ) . replace ( / < .* > \s * $ / g, '' )
21
+ return String ( str ) . replace ( / \s * ? < .* > \s * $ / g, '' )
22
22
}
23
23
24
24
// only remove some md tokens.
Original file line number Diff line number Diff line change
1
+ import {
2
+ parseHeaders ,
3
+ removeTailHtml
4
+ } from '@/util/parseHeaders'
5
+
6
+ describe ( 'parseHeaders' , ( ) => {
7
+ test ( 'should unescape html' , ( ) => {
8
+ const input = '<div>'
9
+ expect ( parseHeaders ( input ) ) . toBe ( '<div>' )
10
+ } )
11
+
12
+ test ( 'should remove markdown tokens correctly' , ( ) => {
13
+ const asserts = {
14
+ // #238
15
+ '[vue](vuejs.org)' : 'vue' ,
16
+ '`vue`' : 'vue' ,
17
+ '*vue*' : 'vue' ,
18
+ '**vue**' : 'vue' ,
19
+ '***vue***' : 'vue' ,
20
+ '_vue_' : 'vue' ,
21
+ '\\_vue\\_' : '_vue_' ,
22
+ '\\*vue\\*' : '*vue*' ,
23
+
24
+ // #564 For multiple markdown tokens
25
+ '`a` and `b`' : 'a and b' ,
26
+ '***bold and italic***' : 'bold and italic' ,
27
+ '**bold** and *italic*' : 'bold and italic'
28
+ }
29
+ Object . keys ( asserts ) . forEach ( input => {
30
+ expect ( parseHeaders ( input ) ) . toBe ( asserts [ input ] )
31
+ } )
32
+ } )
33
+
34
+ test ( 'should remove tail html correctly' , ( ) => {
35
+ expect ( removeTailHtml ( '# H1 <div></div>>' ) ) . toBe ( '# H1' )
36
+ } )
37
+ } )
You can’t perform that action at this time.
0 commit comments