22
22
// NB: This utility assumes UN*X style line endings, \n, in the LaTeX
23
23
// source file received as input; it will not work with other styles.
24
24
25
+ import 'dart:convert' ;
25
26
import 'dart:io' ;
26
27
27
28
import 'package:crypto/crypto.dart' ;
28
29
import 'package:convert/convert.dart' ;
29
- import 'package:utf/utf.dart' ;
30
30
31
31
// ----------------------------------------------------------------------
32
32
// Normalization of the text: removal or normalization of parts that
@@ -40,7 +40,7 @@ final whitespaceRE = new RegExp(r"(?:(?=\s).){2,}"); // \s except end-of-line
40
40
/// given [startOffset] and [endOffset] , bounded to be valid indices
41
41
/// into the string if needed, then inserts [glue] where text was
42
42
/// removed. If there is no match then [line] is returned.
43
- cutMatch (line, match, {startOffset: 0 , endOffset: 0 , glue: "" }) {
43
+ cutMatch (line, match, {startOffset = 0 , endOffset = 0 , glue = "" }) {
44
44
if (match == null ) return line;
45
45
var start = match.start + startOffset;
46
46
var end = match.end + endOffset;
@@ -50,20 +50,20 @@ cutMatch(line, match, {startOffset: 0, endOffset: 0, glue: ""}) {
50
50
return line.substring (0 , start) + glue + line.substring (end);
51
51
}
52
52
53
- cutRegexp (line, re, {startOffset: 0 , endOffset: 0 , glue: "" }) {
53
+ cutRegexp (line, re, {startOffset = 0 , endOffset = 0 , glue = "" }) {
54
54
return cutMatch (line, re.firstMatch (line),
55
55
startOffset: startOffset, endOffset: endOffset, glue: glue);
56
56
}
57
57
58
58
/// Removes the rest of [line] starting from the beginning of the
59
59
/// given [match] , and adjusting with the given [offset] . If there
60
60
/// is no match then [line] is returned.
61
- cutFromMatch (line, match, {offset: 0 , glue: "" }) {
61
+ cutFromMatch (line, match, {offset = 0 , glue = "" }) {
62
62
if (match == null ) return line;
63
63
return line.substring (0 , match.start + offset) + glue;
64
64
}
65
65
66
- cutFromRegexp (line, re, {offset: 0 , glue: "" }) {
66
+ cutFromRegexp (line, re, {offset = 0 , glue = "" }) {
67
67
return cutFromMatch (line, re.firstMatch (line), offset: offset, glue: glue);
68
68
}
69
69
@@ -242,8 +242,7 @@ bool isntHashBlockTerminator(line) => !isSectioningCommand(line);
242
242
extractHashLabel (line) {
243
243
var startMatch = hashLabelStartRE.firstMatch (line);
244
244
var endMatch = hashLabelEndRE.firstMatch (line);
245
- assert (startMatch != null && endMatch != null );
246
- return line.substring (startMatch.end, endMatch.start);
245
+ return line.substring (startMatch! .end, endMatch! .start);
247
246
}
248
247
249
248
// Event classes: Keep track of relevant information about the LaTeX
@@ -491,7 +490,7 @@ computeHashValue(lines, startIndex, nextIndex, listSink) {
491
490
final gatheredLine = gatherLines (lines, startIndex, nextIndex);
492
491
final simplifiedLine = simplifyLine (gatheredLine);
493
492
listSink.write (" % $simplifiedLine \n " );
494
- var digest = sha1.convert (encodeUtf8 (simplifiedLine));
493
+ var digest = sha1.convert (utf8. encode (simplifiedLine));
495
494
return digest.bytes;
496
495
}
497
496
0 commit comments