OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of intl; | 5 part of intl; |
6 | 6 |
7 /** | 7 /** |
8 * Bidi stands for Bi-directional text. | 8 * Bidi stands for Bi-directional text. |
9 * According to [Wikipedia](http://en.wikipedia.org/wiki/Bi-directional_text): | 9 * According to [Wikipedia](http://en.wikipedia.org/wiki/Bi-directional_text): |
10 * Bi-directional text is text containing text in both text directionalities, | 10 * Bi-directional text is text containing text in both text directionalities, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 _alwaysSpan = alwaysSpan; | 75 _alwaysSpan = alwaysSpan; |
76 BidiFormatter.RTL([alwaysSpan=false]) : contextDirection = TextDirection.RTL, | 76 BidiFormatter.RTL([alwaysSpan=false]) : contextDirection = TextDirection.RTL, |
77 _alwaysSpan = alwaysSpan; | 77 _alwaysSpan = alwaysSpan; |
78 BidiFormatter.UNKNOWN([alwaysSpan=false]) : | 78 BidiFormatter.UNKNOWN([alwaysSpan=false]) : |
79 contextDirection = TextDirection.UNKNOWN, _alwaysSpan = alwaysSpan; | 79 contextDirection = TextDirection.UNKNOWN, _alwaysSpan = alwaysSpan; |
80 | 80 |
81 /** Is true if the known context direction for this formatter is RTL. */ | 81 /** Is true if the known context direction for this formatter is RTL. */ |
82 bool get isRTL => contextDirection == TextDirection.RTL; | 82 bool get isRTL => contextDirection == TextDirection.RTL; |
83 | 83 |
84 /** | 84 /** |
| 85 * Escapes HTML-special characters of [text] so that the result can be |
| 86 * included verbatim in HTML source code, either in an element body or in an |
| 87 * attribute value. |
| 88 * |
| 89 * *htmlEscape* is deprecated. Use [HtmlEscape] from the `dart:convert` |
| 90 * package. *htmlEscape* will be removed the 30th of September 2013. |
| 91 */ |
| 92 // TODO(kevmoo) Remove this! |
| 93 @deprecated |
| 94 String htmlEscape(String text) => HTML_ESCAPE.convert(text); |
| 95 |
| 96 /** |
85 * Formats a string of a given (or estimated, if not provided) | 97 * Formats a string of a given (or estimated, if not provided) |
86 * [direction] for use in HTML output of the context directionality, so | 98 * [direction] for use in HTML output of the context directionality, so |
87 * an opposite-directionality string is neither garbled nor garbles what | 99 * an opposite-directionality string is neither garbled nor garbles what |
88 * follows it. | 100 * follows it. |
89 * If the input string's directionality doesn't match the context | 101 * If the input string's directionality doesn't match the context |
90 * directionality, we wrap it with a `span` tag and add a `dir` attribute | 102 * directionality, we wrap it with a `span` tag and add a `dir` attribute |
91 * (either "dir=rtl" or "dir=ltr"). | 103 * (either "dir=rtl" or "dir=ltr"). |
92 * If alwaysSpan was true when constructing the formatter, the input is always | 104 * If alwaysSpan was true when constructing the formatter, the input is always |
93 * wrapped with `span` tag, skipping the dir attribute when it's not needed. | 105 * wrapped with `span` tag, skipping the dir attribute when it's not needed. |
94 * | 106 * |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 if (contextDirection == TextDirection.LTR) { | 187 if (contextDirection == TextDirection.LTR) { |
176 return Bidi.LRM; | 188 return Bidi.LRM; |
177 } else { | 189 } else { |
178 return Bidi.RLM; | 190 return Bidi.RLM; |
179 } | 191 } |
180 } else { | 192 } else { |
181 return ''; | 193 return ''; |
182 } | 194 } |
183 } | 195 } |
184 } | 196 } |
OLD | NEW |