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

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

Issue 11267018: Make getKeys, getValues getters (keys, values). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status files with co19 issue number. Created 8 years, 1 month 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
« no previous file with comments | « pkg/dartdoc/lib/mirrors_util.dart ('k') | pkg/dartdoc/lib/src/mirrors/dart2js_mirror.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 String renderToHtml(List<Node> nodes) => new HtmlRenderer().render(nodes); 5 String renderToHtml(List<Node> nodes) => new HtmlRenderer().render(nodes);
6 6
7 /// Translates a parsed AST to HTML. 7 /// Translates a parsed AST to HTML.
8 class HtmlRenderer implements NodeVisitor { 8 class HtmlRenderer implements NodeVisitor {
9 static const _BLOCK_TAGS = const RegExp( 9 static const _BLOCK_TAGS = const RegExp(
10 'blockquote|h1|h2|h3|h4|h5|h6|hr|p|pre'); 10 'blockquote|h1|h2|h3|h4|h5|h6|hr|p|pre');
(...skipping 17 matching lines...) Expand all
28 bool visitElementBefore(Element element) { 28 bool visitElementBefore(Element element) {
29 // Hackish. Separate block-level elements with newlines. 29 // Hackish. Separate block-level elements with newlines.
30 if (!buffer.isEmpty && 30 if (!buffer.isEmpty &&
31 _BLOCK_TAGS.firstMatch(element.tag) != null) { 31 _BLOCK_TAGS.firstMatch(element.tag) != null) {
32 buffer.add('\n'); 32 buffer.add('\n');
33 } 33 }
34 34
35 buffer.add('<${element.tag}'); 35 buffer.add('<${element.tag}');
36 36
37 // Sort the keys so that we generate stable output. 37 // Sort the keys so that we generate stable output.
38 // TODO(rnystrom): This assumes getKeys() returns a fresh mutable 38 // TODO(rnystrom): This assumes keys returns a fresh mutable
39 // collection. 39 // collection.
40 final attributeNames = element.attributes.getKeys(); 40 final attributeNames = element.attributes.keys;
41 attributeNames.sort((a, b) => a.compareTo(b)); 41 attributeNames.sort((a, b) => a.compareTo(b));
42 for (final name in attributeNames) { 42 for (final name in attributeNames) {
43 buffer.add(' $name="${element.attributes[name]}"'); 43 buffer.add(' $name="${element.attributes[name]}"');
44 } 44 }
45 45
46 if (element.isEmpty) { 46 if (element.isEmpty) {
47 // Empty element like <hr/>. 47 // Empty element like <hr/>.
48 buffer.add(' />'); 48 buffer.add(' />');
49 return false; 49 return false;
50 } else { 50 } else {
51 buffer.add('>'); 51 buffer.add('>');
52 return true; 52 return true;
53 } 53 }
54 } 54 }
55 55
56 void visitElementAfter(Element element) { 56 void visitElementAfter(Element element) {
57 buffer.add('</${element.tag}>'); 57 buffer.add('</${element.tag}>');
58 } 58 }
59 } 59 }
OLDNEW
« no previous file with comments | « pkg/dartdoc/lib/mirrors_util.dart ('k') | pkg/dartdoc/lib/src/mirrors/dart2js_mirror.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698