parse method
Parses the file content and performs various transformations and parsing operations.
This method reads the content of the file, performs image parsing, replaces empty-line tags with
tags,
replaces hyperlink tags with correct href attribute, and then parses the description and body of the file.
Throws an exception if there is an error while reading the file or during the parsing process.
Implementation
Future<void> parse() async {
String fileContent = await file.readAsString();
parseImages(fileContent);
fileContent = changeImageTagToImg(fileContent);
fileContent =
fileContent.replaceAllMapped(RegExp(r'<empty-line\/>'), (match) {
return '<br/>';
});
/// for correct work with hyperlinks we need to replace all <a l:href="..."> to <a href="...">
fileContent =
fileContent.replaceAllMapped(RegExp(r'<a l:href="(.+?)">'), (match) {
return '<a href="${match.group(1)}">';
});
parseDescription(fileContent);
parseBody(fileContent);
}