From 0c3d46795b589d9dfb2e6caa7f94db77fd5371bd Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Tue, 31 Jan 2023 18:22:12 +0100 Subject: Make single newlines cause a
by default This should match what people expect from a chat application much better. The biggest reason not to do this, is because some people might paste markdown documents. For those people there is now a /cmark command, which disables most of our extensions to cmark, including the newline behaviour. There is a long discussion on the Fediverse and on Github linked below. Mastodon https://fosstodon.org/@deepbluev7/109771668066978726 fixes #757 --- src/timeline/InputBar.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/timeline/InputBar.cpp') diff --git a/src/timeline/InputBar.cpp b/src/timeline/InputBar.cpp index b6355418..94944337 100644 --- a/src/timeline/InputBar.cpp +++ b/src/timeline/InputBar.cpp @@ -465,6 +465,14 @@ InputBar::message(const QString &msg, MarkdownOverride useMarkdown, bool rainbow text.formatted_body = ""; else text.format = "org.matrix.custom.html"; + } else if (useMarkdown == MarkdownOverride::CMARK) { + // disable all markdown extensions + text.formatted_body = utils::markdownToHtml(msg, rainbowify, true).toStdString(); + // keep everything as it was + text.body = msg.trimmed().toStdString(); + + // always send formatted + text.format = "org.matrix.custom.html"; } text.relations = generateRelations(); @@ -802,6 +810,8 @@ InputBar::command(const QString &command, QString args) cache::dropOutboundMegolmSession(room->roomId().toStdString()); } else if (command == QLatin1String("md")) { message(args, MarkdownOverride::ON); + } else if (command == QLatin1String("cmark")) { + message(args, MarkdownOverride::CMARK); } else if (command == QLatin1String("plain")) { message(args, MarkdownOverride::OFF); } else if (command == QLatin1String("rainbow")) { -- cgit 1.5.1