Browse Source

Improved newline support for markdown annotated tooltips: two spaces followed by newline will now produce newline within a paragraph

merge-requests/413/head
eidheim 3 years ago
parent
commit
f212fa5936
  1. 5
      src/tooltips.cpp
  2. 4
      tests/tooltips_test.cpp

5
src/tooltips.cpp

@ -741,6 +741,11 @@ void Tooltip::insert_markdown(const std::string &input) {
i += 5; i += 5;
continue; continue;
} }
else if(starts_with(input, i, " \n")) {
partial += '\n';
i += 2;
continue;
}
else if(insert_code() || insert_emphasis() || insert_strikethrough() || insert_link()) else if(insert_code() || insert_emphasis() || insert_strikethrough() || insert_link())
continue; continue;
if(input[i] == '\n' && i + 1 < to) if(input[i] == '\n' && i + 1 < to)

4
tests/tooltips_test.cpp

@ -65,6 +65,10 @@ int main() {
auto tooltip = get_markdown_tooltip("test&nbsp;&nbsp;test"); auto tooltip = get_markdown_tooltip("test&nbsp;&nbsp;test");
g_assert(tooltip->buffer->get_text() == "test test"); g_assert(tooltip->buffer->get_text() == "test test");
} }
{
auto tooltip = get_markdown_tooltip("test \ntest");
g_assert(tooltip->buffer->get_text() == "test\ntest");
}
{ {
auto tooltip = get_markdown_tooltip("test\n\n---\ntest"); auto tooltip = get_markdown_tooltip("test\n\n---\ntest");
g_assert(tooltip->buffer->get_text() == "test\n\n---\ntest"); g_assert(tooltip->buffer->get_text() == "test\n\n---\ntest");

Loading…
Cancel
Save