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

Unified Diff: utils/dartdoc/dartdoc.dart

Issue 9004030: Syntax highlighting on the client. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years 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 | « no previous file | utils/dartdoc/interact.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/dartdoc/dartdoc.dart
diff --git a/utils/dartdoc/dartdoc.dart b/utils/dartdoc/dartdoc.dart
index 657e99d83abd5d6072bbaa0a235c9835d2eb4849..cba4adcd1c54ac812b75e6abe1c56ce57897ee3e 100644
--- a/utils/dartdoc/dartdoc.dart
+++ b/utils/dartdoc/dartdoc.dart
@@ -570,7 +570,7 @@ class Dartdoc {
if (includeSource && showCode) {
writeln('<pre class="source">');
- write(formatCode(span));
+ writeln(md.escapeHtml(unindentCode(span)));
writeln('</pre>');
}
@@ -699,10 +699,9 @@ class Dartdoc {
}
/**
- * Takes a string of Dart code and turns it into sanitized HTML.
+ * Remove leading indentation to line up with first line.
*/
- formatCode(SourceSpan span) {
- // Remove leading indentation to line up with first line.
+ unindentCode(SourceSpan span) {
final column = getSpanColumn(span);
final lines = span.text.split('\n');
// TODO(rnystrom): Dirty hack.
@@ -711,6 +710,14 @@ class Dartdoc {
}
final code = Strings.join(lines, '\n');
+ return code;
+ }
+
+ /**
+ * Takes a string of Dart code and turns it into sanitized HTML.
+ */
+ formatCode(SourceSpan span) {
+ final code = unindentCode(span);
// Syntax highlight.
return classifySource(new SourceFile('', code));
« no previous file with comments | « no previous file | utils/dartdoc/interact.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698