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

Unified Diff: third_party/pkg/markdown/lib/src/html_renderer.dart

Issue 189333002: pkg/docgen: update markdown to 0.5.1 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: updates Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/pkg/markdown/lib/src/document.dart ('k') | third_party/pkg/markdown/lib/src/inline_parser.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/pkg/markdown/lib/src/html_renderer.dart
diff --git a/third_party/pkg/markdown/lib/src/markdown/html_renderer.dart b/third_party/pkg/markdown/lib/src/html_renderer.dart
similarity index 70%
rename from third_party/pkg/markdown/lib/src/markdown/html_renderer.dart
rename to third_party/pkg/markdown/lib/src/html_renderer.dart
index 5494394f36872b799bcd6efbd5febbc799c4b950..97b900b5881ea0a2eded1c74f2a8729389b13bc2 100644
--- a/third_party/pkg/markdown/lib/src/markdown/html_renderer.dart
+++ b/third_party/pkg/markdown/lib/src/html_renderer.dart
@@ -2,7 +2,27 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-part of markdown;
+library markdown.html_renderer;
+
+import 'ast.dart';
+import 'document.dart';
+
+/// Converts the given string of markdown to HTML.
+String markdownToHtml(String markdown, {inlineSyntaxes, linkResolver,
+ bool inlineOnly: false}) {
+ var document = new Document(inlineSyntaxes: inlineSyntaxes,
+ linkResolver: linkResolver);
+
+ if (inlineOnly) {
+ return renderToHtml(document.parseInline(markdown));
+ } else {
+ // Replace windows line endings with unix line endings, and split.
+ var lines = markdown.replaceAll('\r\n','\n').split('\n');
+ document.parseRefLinks(lines);
+ var blocks = document.parseLines(lines);
+ return renderToHtml(blocks);
+ }
+}
String renderToHtml(List<Node> nodes) => new HtmlRenderer().render(nodes);
« no previous file with comments | « third_party/pkg/markdown/lib/src/document.dart ('k') | third_party/pkg/markdown/lib/src/inline_parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698