| 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 /// Standalone script for parsing markdown from files and converting to HTML. | 5 /// Standalone script for parsing markdown from files and converting to HTML. |
| 6 #library('markdown_app'); | 6 library markdown_app; |
| 7 | 7 |
| 8 #import('dart:io'); | 8 import 'dart:io'; |
| 9 #import('lib.dart'); | 9 import 'lib.dart'; |
| 10 | 10 |
| 11 main() { | 11 main() { |
| 12 final args = (new Options()).arguments; | 12 final args = (new Options()).arguments; |
| 13 | 13 |
| 14 if (args.length > 2) { | 14 if (args.length > 2) { |
| 15 print('Usage:'); | 15 print('Usage:'); |
| 16 print(' dart markdown.dart <inputfile> [<outputfile>]'); | 16 print(' dart markdown.dart <inputfile> [<outputfile>]'); |
| 17 print(''); | 17 print(''); |
| 18 print('Reads a file containing markdown and converts it to HTML.'); | 18 print('Reads a file containing markdown and converts it to HTML.'); |
| 19 print('If <outputfile> is omitted, prints to stdout.'); | 19 print('If <outputfile> is omitted, prints to stdout.'); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 38 file.closeSync(); | 38 file.closeSync(); |
| 39 return new String.fromCharCodes(buffer); | 39 return new String.fromCharCodes(buffer); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void writeFile(String path, String text) { | 42 void writeFile(String path, String text) { |
| 43 final file = new File(path); | 43 final file = new File(path); |
| 44 final stream = file.openOutputStream(); | 44 final stream = file.openOutputStream(); |
| 45 stream.write(text.charCodes); | 45 stream.write(text.charCodes); |
| 46 stream.close(); | 46 stream.close(); |
| 47 } | 47 } |
| OLD | NEW |