File tree 1 file changed +6
-3
lines changed
1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,10 @@ is_start_of_tag = (char)-> char is '<'
3
3
is_whitespace = (char )-> / ^ \s + $ / .test char
4
4
is_tag = (token )-> / ^ \s * <[^ >] + >\s * $ / .test token
5
5
isnt_tag = (token )-> not is_tag token
6
+ is_script_tag = (token ) -> token is ' <script'
7
+ ends_in_end_script_tag = (token ) ->
8
+ token_end = token .substr token .length - 9
9
+ token_end is ' </script>'
6
10
7
11
class Match
8
12
constructor : (@start_in_before , @start_in_after , @length )->
@@ -22,8 +26,7 @@ html_to_tokens = (html)->
22
26
when ' script'
23
27
if is_end_of_tag char
24
28
current_word += ' >'
25
- end = current_word .substr current_word .length - 9
26
- if end is ' </script>'
29
+ if ends_in_end_script_tag current_word
27
30
words .push current_word
28
31
current_word = ' '
29
32
if is_whitespace char
@@ -33,7 +36,7 @@ html_to_tokens = (html)->
33
36
else
34
37
current_word += char
35
38
when ' tag'
36
- if current_word is ' <script '
39
+ if is_script_tag current_word
37
40
mode = ' script'
38
41
current_word += char
39
42
else if is_end_of_tag char
You can’t perform that action at this time.
0 commit comments