diff --git a/doc/message_links.md b/doc/message_links.md index beb5243d8..5a09f3d52 100644 --- a/doc/message_links.md +++ b/doc/message_links.md @@ -21,9 +21,11 @@ Qt-клиент поддерживает `**жирный**`, `__курсив__`, обратную кавычку и саму себя. Внутри URL escapes и открывающие маркеры не обрабатываются. Открывающая строка кода содержит ровно три обратные кавычки и необязательное имя языка, -без пробелов, например `cpp`, `c`, `python`, `py`, `js`, `json`, `bash`, `sql`. -Закрывающая строка содержит только три обратные кавычки. Начало/конец сообщения также +например `cpp`, `c`, `python`, `py`, `js`, `json`, `bash`, `sql`. +До/после кавычек и вокруг имени языка допустимы пробелы и табуляции: ` ``` cpp ` тоже работает. +Закрывающая строка содержит три обратные кавычки с необязательными пробелами вокруг. Начало/конец сообщения также считаются границами строк; принимаются LF и CRLF. Несколько блоков в сообщении допустимы. +Пробелы внутри самого кода сохраняются. Кнопка `?` справа от Join открывает краткую подсказку по тегам и блокам кода. ````text **Пример:** diff --git a/tools/chatgui/tests/test_channel_list.cpp b/tools/chatgui/tests/test_channel_list.cpp index 789c10a0c..31347d560 100644 --- a/tools/chatgui/tests/test_channel_list.cpp +++ b/tools/chatgui/tests/test_channel_list.cpp @@ -10,6 +10,7 @@ #include #include #include +#include extern "C" { #include "utun_instance.h" #include "chat/chat_core.h" @@ -71,6 +72,22 @@ private slots: } } + void formattingHelpNextToJoin() { + ChannelList list; list.resize(400, 250); list.show(); QCoreApplication::processEvents(); + auto* join = list.findChild("joinGroupButton"); + auto* helpButton = list.findChild("messageFormattingHelpButton"); + QVERIFY(join && helpButton); QVERIFY(helpButton->isVisible()); + QVERIFY(helpButton->mapTo(&list, QPoint()).x() > join->mapTo(&list, QPoint()).x()); + QSignalSpy joined(&list, &ChannelList::joinRequested); + QTest::mouseClick(helpButton, Qt::LeftButton); + QPointer help = list.findChild("messageFormattingHelp"); + QVERIFY(help); QTRY_VERIFY(help->isVisible()); QCOMPARE(help->textFormat(), Qt::PlainText); + for (const QString& text : {"**text**", "__text__", "~~text~~", "```cpp\nint value = 42;\n```", "Spaces around ```"}) + QVERIFY2(help->text().contains(text), qPrintable(text)); + QVERIFY(joined.isEmpty()); QVERIFY(help->grab().save(QDir::tempPath() + "/message-formatting-help.png")); + help->accept(); QTRY_VERIFY(help.isNull()); + } + void reloadKeepsConnectionState() { ListCore core; QVERIFY(core.start()); ChannelList list(&core.db); list.loadChannels();