Skip to content

Commit 493e28b

Browse files
authored
Merge pull request #1 from nalbion/html_converter
Fixed Travis build for HTML Converter
2 parents 20728e8 + 1db03aa commit 493e28b

File tree

3 files changed

+26
-32
lines changed

3 files changed

+26
-32
lines changed

packages/notus/lib/convert.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ export 'src/convert/markdown.dart';
1414
/// Markdown codec for Notus documents.
1515
const NotusMarkdownCodec notusMarkdown = NotusMarkdownCodec();
1616

17-
const NotusHTMLCodec notusHTML = const NotusHTMLCodec();
17+
const NotusHTMLCodec notusHTML = NotusHTMLCodec();

packages/notus/lib/src/convert/html.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ class _NotusHTMLEncoder extends Converter<Delta, String> {
124124

125125
@override
126126
String convert(Delta input) {
127-
final iterator = new DeltaIterator(input);
128-
final buffer = new StringBuffer();
129-
final lineBuffer = new StringBuffer();
127+
final iterator = DeltaIterator(input);
128+
final buffer = StringBuffer();
129+
final lineBuffer = StringBuffer();
130130
NotusAttribute<String> currentBlockStyle;
131-
NotusStyle currentInlineStyle = new NotusStyle();
131+
NotusStyle currentInlineStyle = NotusStyle();
132132
List<String> currentBlockLines = [];
133133

134134
void _handleBlock(NotusAttribute<String> blockStyle) {
@@ -222,7 +222,7 @@ class _NotusHTMLEncoder extends Converter<Delta, String> {
222222
}
223223

224224
String _writeLine(String text, NotusStyle style) {
225-
StringBuffer buffer = new StringBuffer();
225+
StringBuffer buffer = StringBuffer();
226226
if (style.contains(NotusAttribute.heading)) {
227227
_writeAttribute(buffer, style.get(NotusAttribute.heading));
228228
}
@@ -284,7 +284,7 @@ class _NotusHTMLEncoder extends Converter<Delta, String> {
284284
} else if (attribute.key == NotusAttribute.embed.key) {
285285
_writeEmbedTag(buffer, attribute, close: close);
286286
} else {
287-
throw new ArgumentError('Cannot handle $attribute');
287+
throw ArgumentError('Cannot handle $attribute');
288288
}
289289
}
290290

packages/notus/test/convert/html_test.dart

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ void main() {
8282
test('decode intersecting inline ', () {
8383
final b = NotusAttribute.bold.toJson();
8484
final i = NotusAttribute.italic.toJson();
85-
final bi = new Map<String, dynamic>.from(b);
85+
final bi = Map<String, dynamic>.from(b);
8686
bi.addAll(i);
87-
final delta = new Delta()
87+
final delta = Delta()
8888
..insert('This')
8989
..insert('house', b)
9090
..insert('is a', bi)
@@ -98,20 +98,20 @@ void main() {
9898

9999
test('decode a tag', () {
100100
final l = NotusAttribute.link.fromString('http://foo.com');
101-
final delta = new Delta()..insert('a tag', l.toJson())..insert("\n");
101+
final delta = Delta()..insert('a tag', l.toJson())..insert("\n");
102102
final html = '<a href="http://foo.com">a tag</a>\n';
103103
final result = notusHTML.decode(html);
104104
expect(result, delta);
105105
});
106106

107107
test('decode br tag', () {
108-
final delta = new Delta()..insert('\n')..insert("\n");
108+
final delta = Delta()..insert('\n')..insert("\n");
109109
final html = '<br>\n';
110110
final result = notusHTML.decode(html);
111111
expect(result, delta);
112112
});
113113
test('decode nested br tag ', () {
114-
final delta = new Delta()..insert('<b>a<br></b>')..insert("\n");
114+
final delta = Delta()..insert('<b>a<br></b>')..insert("\n");
115115
final html = '<b>a<br></b>\n';
116116
final result = notusHTML.decode(html);
117117
expect(result, delta);
@@ -169,9 +169,7 @@ void main() {
169169
});
170170
test('decode heading styles', () {
171171
runFor(NotusAttribute<int> attribute, String source, String html) {
172-
final delta = new Delta()
173-
..insert(source)
174-
..insert('\n', attribute.toJson());
172+
final delta = Delta()..insert(source)..insert('\n', attribute.toJson());
175173
final result = notusHTML.decode(html);
176174
expect(result, delta);
177175
}
@@ -184,7 +182,7 @@ void main() {
184182
test('decode heading styles with container attribute', () {
185183
runFor(NotusAttribute<int> attribute, String source, String html) {
186184
final attr = attribute.toJson();
187-
final delta = new Delta()..insert(source)..insert('\n', attr);
185+
final delta = Delta()..insert(source)..insert('\n', attr);
188186
final result = notusHTML.decode(html);
189187
expect(result.toString(), delta.toString());
190188
}
@@ -220,9 +218,7 @@ void main() {
220218

221219
test('decode singe block', () {
222220
runFor(NotusAttribute<String> attribute, String source, String html) {
223-
final delta = new Delta()
224-
..insert(source)
225-
..insert('\n', attribute.toJson());
221+
final delta = Delta()..insert(source)..insert('\n', attribute.toJson());
226222
final result = notusHTML.decode(html);
227223
expect(result, delta);
228224
}
@@ -290,9 +286,9 @@ void main() {
290286
test('decode complex intersecting inline ', () {
291287
final b = NotusAttribute.bold.toJson();
292288
final i = NotusAttribute.italic.toJson();
293-
final bi = new Map<String, dynamic>.from(b);
294-
final bia = new Map<String, dynamic>.from(b);
295-
final biaimage = new Map<String, dynamic>.from(b);
289+
final bi = Map<String, dynamic>.from(b);
290+
final bia = Map<String, dynamic>.from(b);
291+
final biaimage = Map<String, dynamic>.from(b);
296292
final l = NotusAttribute.link.fromString('https://github.com').toJson();
297293
bi.addAll(i);
298294
bia.addAll(i);
@@ -381,7 +377,7 @@ void main() {
381377

382378
test('encode bold italic', () {
383379
runFor(NotusAttribute<bool> attribute, String expected) {
384-
final delta = new Delta()
380+
final delta = Delta()
385381
..insert('This ')
386382
..insert('house', attribute.toJson())
387383
..insert(' is a ')
@@ -399,10 +395,10 @@ void main() {
399395
test('encode intersecting inline styles', () {
400396
final b = NotusAttribute.bold.toJson();
401397
final i = NotusAttribute.italic.toJson();
402-
final bi = new Map<String, dynamic>.from(b);
398+
final bi = Map<String, dynamic>.from(b);
403399
bi.addAll(i);
404400

405-
final delta = new Delta()
401+
final delta = Delta()
406402
..insert('This ')
407403
..insert('house', b)
408404
..insert(' is a ', bi)
@@ -480,7 +476,7 @@ void main() {
480476
test('encode normalize inline styles', () {
481477
final b = NotusAttribute.bold.toJson();
482478
final i = NotusAttribute.italic.toJson();
483-
final delta = new Delta()
479+
final delta = Delta()
484480
..insert('This')
485481
..insert(' house ', b)
486482
..insert('is a')
@@ -494,7 +490,7 @@ void main() {
494490
test('encode links', () {
495491
final b = NotusAttribute.bold.toJson();
496492
final link = NotusAttribute.link.fromString('https://github.com');
497-
final delta = new Delta()
493+
final delta = Delta()
498494
..insert('This')
499495
..insert(' house ', b)
500496
..insert('is a')
@@ -508,9 +504,7 @@ void main() {
508504

509505
test('encode heading styles', () {
510506
runFor(NotusAttribute<int> attribute, String source, String expected) {
511-
final delta = new Delta()
512-
..insert(source)
513-
..insert('\n', attribute.toJson());
507+
final delta = Delta()..insert(source)..insert('\n', attribute.toJson());
514508
final result = notusHTML.encode(delta);
515509
expect(result, expected);
516510
}
@@ -522,7 +516,7 @@ void main() {
522516
test('encode heading styles', () {
523517
runFor(NotusAttribute<int> attribute, String source, String expected) {
524518
final attr = attribute.toJson();
525-
final delta = new Delta()..insert(source)..insert('\n', attr);
519+
final delta = Delta()..insert(source)..insert('\n', attr);
526520
final result = notusHTML.encode(delta);
527521
expect(result, expected);
528522
}
@@ -630,7 +624,7 @@ void main() {
630624
});
631625
test('encode multiline blocks', () {
632626
runFor(NotusAttribute<String> attribute, String source, String expected) {
633-
final delta = new Delta()
627+
final delta = Delta()
634628
..insert(source)
635629
..insert('\n', attribute.toJson())
636630
..insert(source)

0 commit comments

Comments
 (0)