blob: 2da80da2966fee0fd3d580da59bed622c9e942de [file] [log] [blame]
library markdown.util;
/// Replaces `<`, `&`, and `>`, with their HTML entity equivalents.
String escapeHtml(String html) {
if (html == '' || html == null) return null;
return html.replaceAll('&', '&amp;')
.replaceAll('<', '&lt;')
.replaceAll('>', '&gt;');
}
/// Removes null or empty values from [map].
void cleanMap(Map map) {
map.keys
.where((e) => isNullOrEmpty(map[e]))
.toList()
.forEach(map.remove);
}
/// Returns true if an object is null or an empty string.
bool isNullOrEmpty(object) {
return object == null || object == '';
}