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