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

Side by Side Diff: packages/barback/example/markdown_converter/lib/transformer.dart

Issue 3014633002: Roll to pickup pool changes (Closed)
Patch Set: Created 3 years, 2 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 unified diff | Download patch
OLDNEW
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 import 'package:barback/barback.dart'; 5 import 'package:barback/barback.dart';
6 import 'package:markdown/markdown.dart'; 6 import 'package:markdown/markdown.dart';
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 9
10 class ConvertMarkdown extends Transformer { 10 class ConvertMarkdown extends Transformer {
11
12 // A constructor named "asPlugin" is required. It can be empty, but 11 // A constructor named "asPlugin" is required. It can be empty, but
13 // it must be present. It is how pub determines that you want this 12 // it must be present. It is how pub determines that you want this
14 // class to be publicly available as a loadable transformer plugin. 13 // class to be publicly available as a loadable transformer plugin.
15 ConvertMarkdown.asPlugin(); 14 ConvertMarkdown.asPlugin();
16 15
17 // Any markdown file with one of the following extensions is 16 // Any markdown file with one of the following extensions is
18 // converted to HTML. 17 // converted to HTML.
19 String get allowedExtensions => ".md .markdown .mdown"; 18 String get allowedExtensions => ".md .markdown .mdown";
20 19
21 Future apply(Transform transform) async { 20 Future apply(Transform transform) async {
22 var content = await transform.primaryInput.readAsString(); 21 var content = await transform.primaryInput.readAsString();
23 22
24 // The extension of the output is changed to ".html". 23 // The extension of the output is changed to ".html".
25 var id = transform.primaryInput.id.changeExtension(".html"); 24 var id = transform.primaryInput.id.changeExtension(".html");
26 25
27 var newContent = 26 var newContent =
28 "<html><body>" + markdownToHtml(content) + "</body></html>"; 27 "<html><body>" + markdownToHtml(content) + "</body></html>";
29 transform.addOutput(new Asset.fromString(id, newContent)); 28 transform.addOutput(new Asset.fromString(id, newContent));
30 } 29 }
31 } 30 }
OLDNEW
« no previous file with comments | « packages/barback/example/lazy_transformer/lib/transformer.dart ('k') | packages/barback/lib/src/asset/asset.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698