#pragma once #include #include #include struct FontStylesScheme; // VoxelCore Markdown dialect namespace markdown { template struct Result { /// @brief Text with erased markdown std::basic_string text; /// @brief Text styles scheme std::unique_ptr styles; }; Result process(std::string_view source, bool eraseMarkdown); Result process(std::wstring_view source, bool eraseMarkdown); template inline std::basic_string escape(std::string_view source) { std::basic_stringstream ss; int pos = 0; while (pos < source.size()) { CharT first = source[pos]; if (first == '\\' && pos + 1 < source.size()) { CharT second = source[++pos]; ss << first << second; pos++; continue; } else if (first == '*' || first == '~' || first == '_') { ss << '\\'; } ss << first; pos++; } return ss.str(); } }