mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 06:21:50 +00:00
fixed engine hang when using other special characters
This commit is contained in:
parent
6d9771bc32
commit
9ce34080f7
1 changed files with 23 additions and 9 deletions
|
|
@ -56,7 +56,22 @@ static inline void apply_color(const std::basic_string_view<CharT>& color_code,
|
||||||
styles.palette.push_back(style);
|
styles.palette.push_back(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Refactor md code processing
|
template <typename CharT>
|
||||||
|
static inline void restyle(
|
||||||
|
CharT c,
|
||||||
|
FontStyle& style,
|
||||||
|
FontStylesScheme& styles,
|
||||||
|
std::basic_stringstream<CharT>& ss,
|
||||||
|
int& pos,
|
||||||
|
bool eraseMarkdown
|
||||||
|
) {
|
||||||
|
styles.palette.push_back(style);
|
||||||
|
if (!eraseMarkdown) {
|
||||||
|
emit_md(c, styles, ss);
|
||||||
|
}
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename CharT>
|
template <typename CharT>
|
||||||
Result<CharT> process_markdown(
|
Result<CharT> process_markdown(
|
||||||
std::basic_string_view<CharT> source, bool eraseMarkdown
|
std::basic_string_view<CharT> source, bool eraseMarkdown
|
||||||
|
|
@ -101,33 +116,32 @@ Result<CharT> process_markdown(
|
||||||
pos--;
|
pos--;
|
||||||
}
|
}
|
||||||
} else if (first == '*') {
|
} else if (first == '*') {
|
||||||
if (pos + 1 < source.size() && source[pos + 1] == '*') {
|
if (pos + 1 < source.size() && source[pos+1] == '*') {
|
||||||
pos++;
|
pos++;
|
||||||
if (!eraseMarkdown)
|
if (!eraseMarkdown)
|
||||||
emit_md(first, styles, ss);
|
emit_md(first, styles, ss);
|
||||||
style.bold = !style.bold;
|
style.bold = !style.bold;
|
||||||
styles.palette.push_back(style);
|
restyle(first, style, styles, ss, pos, eraseMarkdown);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
style.italic = !style.italic;
|
style.italic = !style.italic;
|
||||||
styles.palette.push_back(style);
|
restyle(first, style, styles, ss, pos, eraseMarkdown);
|
||||||
continue;
|
continue;
|
||||||
} else if (first == '_' && pos + 1 < source.size() && source[pos + 1] == '_') {
|
} else if (first == '_' && pos + 1 < source.size() && source[pos+1] == '_') {
|
||||||
pos++;
|
pos++;
|
||||||
if (!eraseMarkdown)
|
if (!eraseMarkdown)
|
||||||
emit_md(first, styles, ss);
|
emit_md(first, styles, ss);
|
||||||
style.underline = !style.underline;
|
style.underline = !style.underline;
|
||||||
styles.palette.push_back(style);
|
restyle(first, style, styles, ss, pos, eraseMarkdown);
|
||||||
continue;
|
continue;
|
||||||
} else if (first == '~' && pos + 1 < source.size() && source[pos + 1] == '~') {
|
} else if (first == '~' && pos + 1 < source.size() && source[pos+1] == '~') {
|
||||||
pos++;
|
pos++;
|
||||||
if (!eraseMarkdown)
|
if (!eraseMarkdown)
|
||||||
emit_md(first, styles, ss);
|
emit_md(first, styles, ss);
|
||||||
style.strikethrough = !style.strikethrough;
|
style.strikethrough = !style.strikethrough;
|
||||||
styles.palette.push_back(style);
|
restyle(first, style, styles, ss, pos, eraseMarkdown);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (first == '\n') {
|
if (first == '\n') {
|
||||||
styles.palette.push_back(styles.palette.at(1));
|
styles.palette.push_back(styles.palette.at(1));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue