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 /** | |
97 * Formats a string of a given (or estimated, if not provided) | 85 * Formats a string of a given (or estimated, if not provided) |
98 * [direction] for use in HTML output of the context directionality, so | 86 * [direction] for use in HTML output of the context directionality, so |
99 * an opposite-directionality string is neither garbled nor garbles what | 87 * an opposite-directionality string is neither garbled nor garbles what |
100 * follows it. | 88 * follows it. |
101 * If the input string's directionality doesn't match the context | 89 * If the input string's directionality doesn't match the context |
102 * directionality, we wrap it with a `span` tag and add a `dir` attribute | 90 * directionality, we wrap it with a `span` tag and add a `dir` attribute |
103 * (either "dir=rtl" or "dir=ltr"). | 91 * (either "dir=rtl" or "dir=ltr"). |
104 * If alwaysSpan was true when constructing the formatter, the input is always | 92 * If alwaysSpan was true when constructing the formatter, the input is always |
105 * wrapped with `span` tag, skipping the dir attribute when it's not needed. | 93 * wrapped with `span` tag, skipping the dir attribute when it's not needed. |
106 * | 94 * |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 if (contextDirection == TextDirection.LTR) { | 175 if (contextDirection == TextDirection.LTR) { |
188 return Bidi.LRM; | 176 return Bidi.LRM; |
189 } else { | 177 } else { |
190 return Bidi.RLM; | 178 return Bidi.RLM; |
191 } | 179 } |
192 } else { | 180 } else { |
193 return ''; | 181 return ''; |
194 } | 182 } |
195 } | 183 } |
196 } | 184 } |
OLD | NEW |