| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library pub_dartlang_org.colored_markdown; | 5 library pub_dartlang_org.colored_markdown; |
| 6 | 6 |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 | 8 |
| 9 import 'package:analyzer/analyzer.dart'; | 9 import 'package:analyzer/analyzer.dart'; |
| 10 import 'package:analyzer/src/generated/scanner.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
| 11 import 'package:analyzer/src/dart/scanner/reader.dart'; |
| 12 import 'package:analyzer/src/dart/scanner/scanner.dart'; |
| 11 import 'package:analyzer/src/string_source.dart'; | 13 import 'package:analyzer/src/string_source.dart'; |
| 12 import 'package:html/parser.dart' as html; | 14 import 'package:html/parser.dart' as html; |
| 13 import 'package:markdown/markdown.dart'; | 15 import 'package:markdown/markdown.dart'; |
| 14 | 16 |
| 15 String markdownToHtml(String text) { | 17 String markdownToHtml(String text) { |
| 16 var lines = text.replaceAll('\r\n', '\n').split('\n'); | 18 var lines = text.replaceAll('\r\n', '\n').split('\n'); |
| 17 var document = new Document(); | 19 var document = new Document(); |
| 18 var blocks = document.parseLines(lines); | 20 var blocks = document.parseLines(lines); |
| 19 | 21 |
| 20 var colorizer = new ColorizeDartCode(); | 22 var colorizer = new ColorizeDartCode(); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 215 |
| 214 bool _isCodeElement(Element element) | 216 bool _isCodeElement(Element element) |
| 215 => element.tag == 'code' && | 217 => element.tag == 'code' && |
| 216 element.attributes['class'] == 'language-dart' && | 218 element.attributes['class'] == 'language-dart' && |
| 217 element.children.length == 1 && | 219 element.children.length == 1 && |
| 218 element.children[0] is Text; | 220 element.children[0] is Text; |
| 219 | 221 |
| 220 Text _getSourceFromElement(Element element) | 222 Text _getSourceFromElement(Element element) |
| 221 => (element.children.first as Element).children.first as Text; | 223 => (element.children.first as Element).children.first as Text; |
| 222 } | 224 } |
| OLD | NEW |