convertToMarkDown method
Converts the story into MarkdownDocument
MarkdownDocument is a wrapper around string that helps to generate valid MD file.
The story must contain history (it has to be started first).
The imagePrefix
argument should point to the root folder where all images are located.
Implementation
MarkdownDocument convertToMarkDown(String imagePrefix) {
MarkdownDocument doc = MarkdownDocument(imagePrefix);
doc.h1(title);
doc.h2(description);
doc.h2(authors);
history.forEach((element) {
doc.separator();
doc.text(element.text);
if (element.imagePath.isNotEmpty) {
doc.separator();
// add black and white image if available
element.imagePath.length == 1
? doc.image(element.imagePath[0])
: doc.image(element.imagePath[1]);
}
});
return doc;
}