Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: test/dart_codegen/expect/convert/html_escape.dart

Issue 959073002: Fix new line breaks on } (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/dart_codegen/expect/convert/ascii.dart ('k') | test/dart_codegen/expect/convert/json.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 part of dart.convert; 1 part of dart.convert;
2 const HtmlEscape HTML_ESCAPE = const HtmlEscape(); 2 const HtmlEscape HTML_ESCAPE = const HtmlEscape();
3 class HtmlEscapeMode {final String _name; 3 class HtmlEscapeMode {final String _name;
4 final bool escapeLtGt; 4 final bool escapeLtGt;
5 final bool escapeQuot; 5 final bool escapeQuot;
6 final bool escapeApos; 6 final bool escapeApos;
7 final bool escapeSlash; 7 final bool escapeSlash;
8 static const HtmlEscapeMode UNKNOWN = const HtmlEscapeMode._('unknown', true, t rue, true, true); 8 static const HtmlEscapeMode UNKNOWN = const HtmlEscapeMode._('unknown', true, t rue, true, true);
9 static const HtmlEscapeMode ATTRIBUTE = const HtmlEscapeMode._('attribute', fal se, true, false, false); 9 static const HtmlEscapeMode ATTRIBUTE = const HtmlEscapeMode._('attribute', fal se, true, false, false);
10 static const HtmlEscapeMode ELEMENT = const HtmlEscapeMode._('element', true, f alse, false, true); 10 static const HtmlEscapeMode ELEMENT = const HtmlEscapeMode._('element', true, f alse, false, true);
11 const HtmlEscapeMode._(this._name, this.escapeLtGt, this.escapeQuot, this.escap eApos, this.escapeSlash); 11 const HtmlEscapeMode._(this._name, this.escapeLtGt, this.escapeQuot, this.escap eApos, this.escapeSlash);
12 String toString() => _name; 12 String toString() => _name;
13 } 13 }
14 class HtmlEscape extends Converter<String, String> {final HtmlEscapeMode mode; 14 class HtmlEscape extends Converter<String, String> {final HtmlEscapeMode mode;
15 const HtmlEscape([this.mode = HtmlEscapeMode.UNKNOWN]); 15 const HtmlEscape([this.mode = HtmlEscapeMode.UNKNOWN]);
16 String convert(String text) { 16 String convert(String text) {
17 var val = _convert(text, 0, text.length); 17 var val = _convert(text, 0, text.length);
18 return val == null ? text : val; 18 return val == null ? text : val;
19 } 19 }
20 String _convert(String text, int start, int end) { 20 String _convert(String text, int start, int end) {
21 StringBuffer result = null; 21 StringBuffer result = null;
22 for (int i = start; 22 for (int i = start; i < end; i++) {
23 i < end;
24 i++) {
25 var ch = text[i]; 23 var ch = text[i];
26 String replace = null; 24 String replace = null;
27 switch (ch) {case '&': replace = '&amp;'; 25 switch (ch) {case '&': replace = '&amp;';
28 break; 26 break;
29 case '\u00A0': replace = '&nbsp;'; 27 case '\u00A0': replace = '&nbsp;';
30 break; 28 break;
31 case '"': if (mode.escapeQuot) replace = '&quot;'; 29 case '"': if (mode.escapeQuot) replace = '&quot;';
32 break; 30 break;
33 case "'": if (mode.escapeApos) replace = '&#x27;'; 31 case "'": if (mode.escapeApos) replace = '&#x27;';
34 break; 32 break;
(...skipping 29 matching lines...) Expand all
64 if (val == null) { 62 if (val == null) {
65 _sink.addSlice(chunk, start, end, isLast); 63 _sink.addSlice(chunk, start, end, isLast);
66 } 64 }
67 else { 65 else {
68 _sink.add(val); 66 _sink.add(val);
69 if (isLast) _sink.close(); 67 if (isLast) _sink.close();
70 } 68 }
71 } 69 }
72 void close() => _sink.close(); 70 void close() => _sink.close();
73 } 71 }
OLDNEW
« no previous file with comments | « test/dart_codegen/expect/convert/ascii.dart ('k') | test/dart_codegen/expect/convert/json.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698