diff options
Diffstat (limited to '')
-rw-r--r-- | src/md4cpp.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/md4cpp.cc b/src/md4cpp.cc index 04ca900..24cb8e6 100644 --- a/src/md4cpp.cc +++ b/src/md4cpp.cc @@ -120,6 +120,38 @@ get_emoji_map() return retval; } +std::string +escape_html(const std::string& content) +{ + std::string retval; + + retval.reserve(content.size()); + for (auto ch : content) { + switch (ch) { + case '"': + retval.append("""); + break; + case '\'': + retval.append("'"); + break; + case '<': + retval.append("<"); + break; + case '>': + retval.append(">"); + break; + case '&': + retval.append("&"); + break; + default: + retval.push_back(ch); + break; + } + } + + return retval; +} + struct parse_userdata { event_handler& pu_handler; std::string pu_error_msg; |