suggestFilename static method
Suggest a filename from the markdown content.
Implementation
static String suggestFilename(String content, {String prefix = 'neom'}) {
final headingMatch = RegExp(r'^#{1,3}\s+(.+)', multiLine: true).firstMatch(content);
if (headingMatch != null) {
final title = headingMatch.group(1)!.trim().toLowerCase()
.replaceAll(RegExp(r'[^\w\s]'), '')
.replaceAll(RegExp(r'\s+'), '_');
if (title.length > 3 && title.length < 40) {
return '${prefix}_$title.docx';
}
}
final timestamp = DateTime.now().millisecondsSinceEpoch ~/ 1000;
return '${prefix}_documento_$timestamp.docx';
}