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

Unified Diff: pkg/intl/lib/bidi_formatter.dart

Issue 10952004: Change intl to use new pub layout (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/intl/intl_standalone.dart ('k') | pkg/intl/lib/bidi_utils.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/intl/lib/bidi_formatter.dart
===================================================================
--- pkg/intl/lib/bidi_formatter.dart (revision 12504)
+++ pkg/intl/lib/bidi_formatter.dart (working copy)
@@ -73,13 +73,31 @@
_alwaysSpan = alwaysSpan;
BidiFormatter.RTL([alwaysSpan=false]) : contextDirection = TextDirection.RTL,
_alwaysSpan = alwaysSpan;
- BidiFormatter.UNKNOWN([alwaysSpan=false]) :
+ BidiFormatter.UNKNOWN([alwaysSpan=false]) :
contextDirection = TextDirection.UNKNOWN, _alwaysSpan = alwaysSpan;
/** Is true if the known context direction for this formatter is RTL. */
bool get isRTL => contextDirection == TextDirection.RTL;
/**
+ * Escapes HTML-special characters of [text] so that the result can be
+ * included verbatim in HTML source code, either in an element body or in an
+ * attribute value.
+ */
+ String htmlEscape(String text) {
+ // TODO(alanknight): This is copied into here directly to avoid having a
+ // dependency on the htmlescape library, which is difficult to do in a way
+ // that's compatible with both package: links and direct links in the SDK.
+ // Once pub is used in test.dart (Issue #4968) this should be removed.
+ // TODO(efortuna): A more efficient implementation.
+ return text.replaceAll("&", "&")
+ .replaceAll("<", "&lt;")
+ .replaceAll(">", "&gt;")
+ .replaceAll('"', "&quot;")
+ .replaceAll("'", "&apos;");
+ }
+
+ /**
* Formats a string of a given (or estimated, if not provided)
* [direction] for use in HTML output of the context directionality, so
* an opposite-directionality string is neither garbled nor garbles what
@@ -114,7 +132,7 @@
}
/**
- * Format [text] of a known (if specified) or estimated [direction] for use
+ * Format [text] of a known (if specified) or estimated [direction] for use
* in *plain-text* output of the context directionality, so an
* opposite-directionality text is neither garbled nor garbles what follows
* it. Unlike wrapWithSpan, this makes use of unicode BiDi formatting
@@ -144,7 +162,7 @@
/**
* Estimates the directionality of [text] using the best known
- * general-purpose method (using relative word counts). A
+ * general-purpose method (using relative word counts). A
* TextDirection.UNKNOWN return value indicates completely neutral input.
* [isHtml] is true if [text] HTML or HTML-escaped.
*/
@@ -157,7 +175,7 @@
* (not necessarily the direction of [text]). The function returns an LRM or
* RLM if the overall directionality or the exit directionality of [text] is
* opposite the context directionality. Otherwise
- * return the empty string. [isHtml] is true if [text] is HTML or
+ * return the empty string. [isHtml] is true if [text] is HTML or
* HTML-escaped.
*/
String _resetDir(String text, TextDirection direction, bool isHtml) {
« no previous file with comments | « pkg/intl/intl_standalone.dart ('k') | pkg/intl/lib/bidi_utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698