From 9cf53aa9d89986139c5ea4b7a9447281b882d981 Mon Sep 17 00:00:00 2001 From: Bob Date: Sun, 2 Feb 2020 16:34:19 +1100 Subject: [PATCH] Only return formatted text when necessary (for escaped chars) Signed-off-by: Bob Rao --- src/editor/serialize.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/editor/serialize.js b/src/editor/serialize.js index 075c462b37..03f3759ea0 100644 --- a/src/editor/serialize.js +++ b/src/editor/serialize.js @@ -44,7 +44,11 @@ export function htmlSerializeIfNeeded(model, {forceHTML = false} = {}) { // Format "plain" text to ensure removal of backslash escapes // https://github.com/vector-im/riot-web/issues/11230 // https://github.com/vector-im/riot-web/issues/2870 - return parser.toPlaintext(); + const postParsePlaintext = parser.toPlaintext(); + if (postParsePlaintext !== md) { + // only return "formatted" text if it differs from the source text + return postParsePlaintext; + } } export function textSerialize(model) {