OLD | NEW |
1 library markdown.util; | 1 library markdown.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; |
5 return html.replaceAll('&', '&') | 6 return html.replaceAll('&', '&') |
6 .replaceAll('<', '<') | 7 .replaceAll('<', '<') |
7 .replaceAll('>', '>'); | 8 .replaceAll('>', '>'); |
8 } | 9 } |
| 10 |
| 11 /// Removes null or empty values from [map]. |
| 12 void cleanMap(Map map) { |
| 13 map.keys |
| 14 .where((e) => isNullOrEmpty(map[e])) |
| 15 .toList() |
| 16 .forEach(map.remove); |
| 17 } |
| 18 |
| 19 /// Returns true if an object is null or an empty string. |
| 20 bool isNullOrEmpty(object) { |
| 21 return object == null || object == ''; |
| 22 } |
OLD | NEW |