From ccdaa1bea9291bdf035181245c6df044a41e8ede Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 3 Jul 2020 21:02:55 +0200 Subject: [PATCH] LibWeb: Insert newlines at
and block boundaries in copied text :^) To make the plain text we copy out from LibWeb look at least somewhat like its original form, let's insert newlines at
elements and when we exit a block-level element. This is far from perfect, but seems to work pretty okay. --- Libraries/LibWeb/PageView.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Libraries/LibWeb/PageView.cpp b/Libraries/LibWeb/PageView.cpp index 0bce94c408..84c24bc2b1 100644 --- a/Libraries/LibWeb/PageView.cpp +++ b/Libraries/LibWeb/PageView.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -141,6 +142,9 @@ String PageView::selected_text() const while (layout_node && layout_node != selection.end().layout_node) { if (is(*layout_node)) builder.append(to(*layout_node).text_for_rendering()); + else if (is(*layout_node) || is(*layout_node)) + builder.append('\n'); + layout_node = layout_node->next_in_pre_order(); }