add gui.escape_markup
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
#include "markdown.hpp"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "graphics/core/Font.hpp"
|
||||
|
||||
using namespace markdown;
|
||||
@@ -66,6 +64,7 @@ Result<CharT> process_markdown(
|
||||
pos++;
|
||||
continue;
|
||||
}
|
||||
pos--;
|
||||
}
|
||||
} else if (first == '*') {
|
||||
if (pos + 1 < source.size() && source[pos+1] == '*') {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
|
||||
struct FontStylesScheme;
|
||||
|
||||
@@ -19,4 +20,24 @@ namespace markdown {
|
||||
|
||||
Result<char> process(std::string_view source, bool eraseMarkdown);
|
||||
Result<wchar_t> process(std::wstring_view source, bool eraseMarkdown);
|
||||
|
||||
template <typename CharT>
|
||||
inline std::basic_string<CharT> escape(std::string_view source) {
|
||||
std::basic_stringstream<CharT> 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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user