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

Side by Side Diff: sdk/lib/_internal/dartdoc/lib/src/markdown/html_renderer.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 markdown; 5 part of markdown;
6 6
7 String renderToHtml(List<Node> nodes) => new HtmlRenderer().render(nodes); 7 String renderToHtml(List<Node> nodes) => new HtmlRenderer().render(nodes);
8 8
9 /// Translates a parsed AST to HTML. 9 /// Translates a parsed AST to HTML.
10 class HtmlRenderer implements NodeVisitor { 10 class HtmlRenderer implements NodeVisitor {
(...skipping 21 matching lines...) Expand all
32 if (!buffer.isEmpty && 32 if (!buffer.isEmpty &&
33 _BLOCK_TAGS.firstMatch(element.tag) != null) { 33 _BLOCK_TAGS.firstMatch(element.tag) != null) {
34 buffer.add('\n'); 34 buffer.add('\n');
35 } 35 }
36 36
37 buffer.add('<${element.tag}'); 37 buffer.add('<${element.tag}');
38 38
39 // Sort the keys so that we generate stable output. 39 // Sort the keys so that we generate stable output.
40 // TODO(rnystrom): This assumes keys returns a fresh mutable 40 // TODO(rnystrom): This assumes keys returns a fresh mutable
41 // collection. 41 // collection.
42 final attributeNames = element.attributes.keys; 42 final attributeNames = element.attributes.keys.toList();
43 attributeNames.sort((a, b) => a.compareTo(b)); 43 attributeNames.sort((a, b) => a.compareTo(b));
44 for (final name in attributeNames) { 44 for (final name in attributeNames) {
45 buffer.add(' $name="${element.attributes[name]}"'); 45 buffer.add(' $name="${element.attributes[name]}"');
46 } 46 }
47 47
48 if (element.isEmpty) { 48 if (element.isEmpty) {
49 // Empty element like <hr/>. 49 // Empty element like <hr/>.
50 buffer.add(' />'); 50 buffer.add(' />');
51 return false; 51 return false;
52 } else { 52 } else {
53 buffer.add('>'); 53 buffer.add('>');
54 return true; 54 return true;
55 } 55 }
56 } 56 }
57 57
58 void visitElementAfter(Element element) { 58 void visitElementAfter(Element element) {
59 buffer.add('</${element.tag}>'); 59 buffer.add('</${element.tag}>');
60 } 60 }
61 } 61 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/dartdoc/lib/src/markdown/block_parser.dart ('k') | sdk/lib/_internal/dartdoc/test/dartdoc_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698