| OLD | NEW |
| 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 { |
| 11 static const _BLOCK_TAGS = const RegExp( | 11 static const _BLOCK_TAGS = new RegExp( |
| 12 'blockquote|h1|h2|h3|h4|h5|h6|hr|p|pre'); | 12 'blockquote|h1|h2|h3|h4|h5|h6|hr|p|pre'); |
| 13 | 13 |
| 14 StringBuffer buffer; | 14 StringBuffer buffer; |
| 15 | 15 |
| 16 HtmlRenderer(); | 16 HtmlRenderer(); |
| 17 | 17 |
| 18 String render(List<Node> nodes) { | 18 String render(List<Node> nodes) { |
| 19 buffer = new StringBuffer(); | 19 buffer = new StringBuffer(); |
| 20 | 20 |
| 21 for (final node in nodes) node.accept(this); | 21 for (final node in nodes) node.accept(this); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 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 } |
| OLD | NEW |