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

Unified Diff: dart/utils/dartdoc/dartdoc.dart

Issue 8974006: Modify the dartdoc code rendering. Syntax highlightning (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/
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
Index: dart/utils/dartdoc/dartdoc.dart
===================================================================
--- dart/utils/dartdoc/dartdoc.dart (revision 2559)
+++ dart/utils/dartdoc/dartdoc.dart (working copy)
@@ -570,7 +570,7 @@
if (includeSource && showCode) {
writeln('<pre class="source">');
- write(formatCode(span));
+ writeln(md.escapeHtml('${unindentCode(span)}'));
Bob Nystrom 2011/12/19 23:17:34 You don't need to interpolate here.
michael.haubenwallner 2011/12/20 08:54:54 Small problem on the client side: when the code st
Bob Nystrom 2011/12/20 18:46:36 Right, sorry if I wasn't clear. Escaping is defini
writeln('</pre>');
}
@@ -699,9 +699,9 @@
}
/**
- * Takes a string of Dart code and turns it into sanitized HTML.
+ * Unindents a bunch of Dart code lines
Bob Nystrom 2011/12/19 23:17:34 This needs a better comment. Just take the "Remove
michael.haubenwallner 2011/12/20 08:54:54 Done.
Bob Nystrom 2011/12/20 18:46:36 When you've made changes during a review, you have
*/
- formatCode(SourceSpan span) {
+ unindentCode(SourceSpan span) {
// Remove leading indentation to line up with first line.
final column = getSpanColumn(span);
final lines = span.text.split('\n');
@@ -711,7 +711,15 @@
}
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 | « AUTHORS ('k') | dart/utils/dartdoc/interact.dart » ('j') | dart/utils/dartdoc/interact.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698