1
1
import { regExpToken , tokens } from '../tokenTypes'
2
2
3
- const { NONE , SPACE , LINE , COLOR } = tokens
3
+ const { SPACE , LINE , COLOR } = tokens
4
4
5
5
const STYLE = regExpToken ( / ^ ( s o l i d | d o u b l e | d o t t e d | d a s h e d ) $ / )
6
6
@@ -13,30 +13,27 @@ module.exports = tokenStream => {
13
13
let style
14
14
let color
15
15
16
- if ( tokenStream . matches ( NONE ) ) {
17
- tokenStream . expectEmpty ( )
18
- return {
19
- $merge : {
20
- textDecorationLine : defaultTextDecorationLine ,
21
- textDecorationStyle : defaultTextDecorationStyle ,
22
- textDecorationColor : defaultTextDecorationColor ,
23
- } ,
24
- }
25
- }
26
-
27
16
let didParseFirst = false
28
17
while ( tokenStream . hasTokens ( ) ) {
29
18
if ( didParseFirst ) tokenStream . expect ( SPACE )
30
19
31
20
if ( line === undefined && tokenStream . matches ( LINE ) ) {
32
- line = tokenStream . lastValue
21
+ const lines = [ tokenStream . lastValue ]
33
22
34
23
tokenStream . saveRewindPoint ( )
35
- if ( tokenStream . matches ( SPACE ) && tokenStream . matches ( LINE ) ) {
36
- line += ` ${ tokenStream . lastValue } `
24
+ if (
25
+ lines [ 0 ] !== 'none' &&
26
+ tokenStream . matches ( SPACE ) &&
27
+ tokenStream . matches ( LINE )
28
+ ) {
29
+ lines . push ( tokenStream . lastValue )
30
+ // Underline comes before line-through
31
+ lines . sort ( ) . reverse ( )
37
32
} else {
38
33
tokenStream . rewind ( )
39
34
}
35
+
36
+ line = lines . join ( ' ' )
40
37
} else if ( style === undefined && tokenStream . matches ( STYLE ) ) {
41
38
style = tokenStream . lastValue
42
39
} else if ( color === undefined && tokenStream . matches ( COLOR ) ) {
0 commit comments