diff --git a/src/components/builder.cpp b/src/components/builder.cpp index 798a08b1..4bab278f 100644 --- a/src/components/builder.cpp +++ b/src/components/builder.cpp @@ -511,7 +511,11 @@ void builder::underline_close() { */ void builder::cmd(mousebtn index, string action, bool condition) { if (condition && !action.empty()) { - action = string_util::replace_all(action, ":", "\\:"); + size_t p{0}; + while ((p = action.find(':', p)) != string::npos && action[p - 1] != '\\') { + action.insert(p, 1, '\\'); + p++; + } tag_open(syntaxtag::A, to_string(static_cast(index)) + ":" + action + ":"); } } @@ -520,9 +524,8 @@ void builder::cmd(mousebtn index, string action, bool condition) { * Wrap label in command block */ void builder::cmd(mousebtn index, string action, const label_t& label) { - if (!action.empty() && label && *label) { - action = string_util::replace_all(action, ":", "\\:"); - tag_open(syntaxtag::A, to_string(static_cast(index)) + ":" + action + ":"); + if (label && *label) { + cmd(index, action, true); node(label); tag_close(syntaxtag::A); } diff --git a/src/components/renderer.cpp b/src/components/renderer.cpp index 6cde36b3..964e8826 100644 --- a/src/components/renderer.cpp +++ b/src/components/renderer.cpp @@ -731,7 +731,7 @@ bool renderer::on(const signals::parser::action_begin& evt) { action.button = a.button == mousebtn::NONE ? mousebtn::LEFT : a.button; action.align = m_align; action.start_x = m_blocks.at(m_align).x; - action.command = string_util::replace_all(a.command, ":", "\\:"); + action.command = string_util::replace_all(a.command, "\\:", ":"); action.active = true; m_actions.emplace_back(action); return true;