stream method
Extracts text content from a file and returns it as a stream of strings.
Implementing classes must define how to parse their specific file format. @param file The file to extract text from
Implementation
@override
Stream<String> stream(File file) async* {
File output = File("${file.path}.pandoc.txt");
try {
ProcessResult result = await Process.run("pandoc", [
"-o",
output.path,
file.path,
]);
if (result.stdout != null && result.stdout.isNotEmpty) {
print("[Pandoc]: ${result.stdout}");
}
if (result.stderr != null && result.stderr.isNotEmpty) {
print("[Pandoc] STDERR: ${result.stderr}");
}
} catch (e, es) {
error("==> Pandoc failed to convert ${file.path}");
throw e;
}
yield* output.openRead().transform(Utf8Decoder()).transform(LineSplitter());
await output.delete();
}