OLD | NEW |
1 library markdown.util; | 1 library markdown.src.util; |
2 | 2 |
3 /// Replaces `<`, `&`, and `>`, with their HTML entity equivalents. | 3 /// Replaces `<`, `&`, and `>`, with their HTML entity equivalents. |
4 String escapeHtml(String html) { | 4 String escapeHtml(String html) { |
5 if (html == '' || html == null) return null; | |
6 return html | 5 return html |
7 .replaceAll('&', '&') | 6 .replaceAll('&', '&') |
8 .replaceAll('<', '<') | 7 .replaceAll('<', '<') |
9 .replaceAll('>', '>'); | 8 .replaceAll('>', '>'); |
10 } | 9 } |
11 | |
12 /// Removes null or empty values from [map]. | |
13 void cleanMap(Map map) { | |
14 map.keys.where((e) => isNullOrEmpty(map[e])).toList().forEach(map.remove); | |
15 } | |
16 | |
17 /// Returns true if an object is null or an empty string. | |
18 bool isNullOrEmpty(object) { | |
19 return object == null || object == ''; | |
20 } | |
OLD | NEW |