mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 22:31:50 +00:00
Move markdown library.
This moves markdown into two places: - The one under samples/ is intended to be a "real" markdown parser. Eventually, it will probably live as a third-party library outside of our standard lib but still easily accessible. - The one inside dartdoc will change to become the parser used to parse Gilad's forthcoming dartdoc comment syntax. Review URL: http://codereview.chromium.org//8953042 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@2606 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
4354008724
commit
91218f5967
|
@ -18,7 +18,7 @@
|
|||
#import('../../frog/lang.dart');
|
||||
#import('../../frog/file_system.dart');
|
||||
#import('../../frog/file_system_node.dart');
|
||||
#import('../markdown/lib.dart', prefix: 'md');
|
||||
#import('markdown.dart', prefix: 'md');
|
||||
|
||||
#source('classify.dart');
|
||||
#source('comment_map.dart');
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
// 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.
|
||||
|
||||
/// Parses text in markdown format. Use this entrypoint if you want to parse
|
||||
/// markdown from your own Dart code. To parse markdown by running the script
|
||||
/// directly from the command line, see markdown.dart.
|
||||
/// Parses text in a markdown-like format and renders to HTML.
|
||||
#library('markdown');
|
||||
|
||||
#source('ast.dart');
|
|
@ -5,7 +5,7 @@
|
|||
/// Unit tests for markdown.
|
||||
#library('markdown_tests');
|
||||
|
||||
#import('../lib.dart');
|
||||
#import('../markdown.dart');
|
||||
|
||||
// TODO(rnystrom): Better path to unittest.
|
||||
#import('../../../client/testing/unittest/unittest_vm.dart');
|
|
@ -1,4 +0,0 @@
|
|||
A markdown parsing library in Dart.
|
||||
|
||||
If you want to use this as a library, import "lib.dart". To use it as a
|
||||
standalone script, run "markdown.dart".
|
|
@ -1,46 +0,0 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// 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.
|
||||
|
||||
/// Standalone script for parsing markdown from files and converting to HTML.
|
||||
#library('markdown_app');
|
||||
|
||||
#import('lib.dart');
|
||||
|
||||
main() {
|
||||
final args = (new Options()).arguments;
|
||||
|
||||
if (args.length > 2) {
|
||||
print('Usage:');
|
||||
print(' dart markdown.dart <inputfile> [<outputfile>]');
|
||||
print('');
|
||||
print('Reads a file containing markdown and converts it to HTML.');
|
||||
print('If <outputfile> is omitted, prints to stdout.');
|
||||
return;
|
||||
}
|
||||
|
||||
final source = readFile(args[0]);
|
||||
final html = markdownToHtml(source);
|
||||
|
||||
if (args.length == 1) {
|
||||
print(html);
|
||||
} else {
|
||||
writeFile(args[1], html);
|
||||
}
|
||||
}
|
||||
|
||||
String readFile(String path) {
|
||||
final file = (new File(path)).openSync();
|
||||
final length = file.lengthSync();
|
||||
final buffer = new List<int>(length);
|
||||
final bytes = file.readListSync(buffer, 0, length);
|
||||
file.closeSync();
|
||||
return new String.fromCharCodes(buffer);
|
||||
}
|
||||
|
||||
void writeFile(String path, String text) {
|
||||
final file = new File(path);
|
||||
final stream = file.openOutputStream();
|
||||
stream.write(text.charCodes());
|
||||
stream.close();
|
||||
}
|
Loading…
Reference in a new issue