@@ -17,11 +17,28 @@ export default (text, doLinkify = false) => {
17
17
} )
18
18
}
19
19
} else {
20
- const firstChar = string . slice ( 0 , 1 )
21
- const lastChar = string . slice ( - 1 )
20
+ if ( string . length > 2 ) {
21
+ const formats = [ ]
22
22
23
- if ( string . length > 2 && firstChar === '*' && lastChar === '*' ) {
24
- result = { bind : true , content : `<b>${ string . slice ( 1 , - 1 ) } </b>` }
23
+ string = testString ( string , '*' , 'b' , formats )
24
+ string = testString ( string , '_' , 'i' , formats )
25
+
26
+ string = testString ( string , '*' , 'b' , formats )
27
+ string = testString ( string , '~' , 'del' , formats )
28
+
29
+ string = testString ( string , '*' , 'b' , formats )
30
+ string = testString ( string , '_' , 'i' , formats )
31
+ string = testString ( string , '|' , 'ins' , formats )
32
+
33
+ string = testString ( string , '*' , 'b' , formats )
34
+ string = testString ( string , '_' , 'i' , formats )
35
+ string = testString ( string , '~' , 'del' , formats )
36
+
37
+ formats . map ( format => {
38
+ string = `<${ format } >${ string } </${ format } >`
39
+ } )
40
+
41
+ result = { bind : formats . length , content : string }
25
42
} else {
26
43
result = { content : string }
27
44
}
@@ -35,3 +52,12 @@ export default (text, doLinkify = false) => {
35
52
36
53
return formattedStrings
37
54
}
55
+
56
+ function testString ( string , sign , type , formats ) {
57
+ if ( string . slice ( 0 , 1 ) === sign && string . slice ( - 1 ) === sign ) {
58
+ string = string . slice ( 1 , - 1 )
59
+ formats . push ( type )
60
+ }
61
+
62
+ return string
63
+ }
0 commit comments