Skip to content

Commit

Permalink
fixes #4348 (NewStory: табуляция в режиме просмотра съедается, а в ре…
Browse files Browse the repository at this point in the history
…жиме редактирования нет)
  • Loading branch information
georgehazan committed Apr 17, 2024
1 parent 3693cff commit 654fd5f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
9 changes: 9 additions & 0 deletions plugins/NewStory/src/templates.cpp
Expand Up @@ -175,6 +175,15 @@ static void AppendString(CMStringW &buf, const wchar_t *p, ItemData *pItem)
p = p1 + 5;
}
}
else if (!wcsncmp(p, L"code]", 5)) {
p += 5;

if (auto *p1 = wcsstr(p, L"[/code]")) {
CMStringW wszUrl(p, int(p1 - p));
buf.AppendFormat(L"<pre>%s</pre>", wszUrl.c_str());
p = p1 + 6;
}
}
else {
buf.AppendChar('[');
if (*pEnd == '/')
Expand Down
15 changes: 9 additions & 6 deletions protocols/Telegram/src/utils.cpp
Expand Up @@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

enum class BBCODE
{
BOLD, ITALIC, STRIKE, UNDERLINE, URL
BOLD, ITALIC, STRIKE, UNDERLINE, URL, CODE
};

struct
Expand All @@ -30,11 +30,12 @@ struct
}
static bbCodes[] =
{
{ BBCODE::BOLD, L"[b]", L"[/b]", 3, 4 },
{ BBCODE::ITALIC, L"[i]", L"[/i]", 3, 4 },
{ BBCODE::STRIKE, L"[s]", L"[/s]", 3, 4 },
{ BBCODE::UNDERLINE, L"[u]", L"[/u]", 3, 4 },
{ BBCODE::URL, L"[url]", L"[/url]", 5, 6 },
{ BBCODE::BOLD, L"[b]", L"[/b]", 3, 4 },
{ BBCODE::ITALIC, L"[i]", L"[/i]", 3, 4 },
{ BBCODE::STRIKE, L"[s]", L"[/s]", 3, 4 },
{ BBCODE::UNDERLINE, L"[u]", L"[/u]", 3, 4 },
{ BBCODE::URL, L"[url]", L"[/url]", 5, 6 },
{ BBCODE::CODE, L"[code]", L"[/code]", 6, 7 },
};

TD::object_ptr<TD::formattedText> formatBbcodes(const char *pszText)
Expand Down Expand Up @@ -65,6 +66,7 @@ TD::object_ptr<TD::formattedText> formatBbcodes(const char *pszText)
TD::object_ptr<TD::TextEntityType> pNew;
switch (it.type) {
case BBCODE::URL: pNew = TD::make_object<TD::textEntityTypeUrl>(); break;
case BBCODE::CODE: pNew = TD::make_object<TD::textEntityTypeCode>(); break;
case BBCODE::BOLD: pNew = TD::make_object<TD::textEntityTypeBold>(); break;
case BBCODE::ITALIC: pNew = TD::make_object<TD::textEntityTypeItalic>(); break;
case BBCODE::STRIKE: pNew = TD::make_object<TD::textEntityTypeStrikethrough>(); break;
Expand Down Expand Up @@ -94,6 +96,7 @@ static CMStringA getFormattedText(TD::object_ptr<TD::formattedText> &pText)
case TD::textEntityTypeStrikethrough::ID: iCode = 2; break;
case TD::textEntityTypeUnderline::ID: iCode = 3; break;
case TD::textEntityTypeUrl::ID: iCode = 4; break;
case TD::textEntityTypeCode::ID: iCode = 5; break;
default:
continue;
}
Expand Down

0 comments on commit 654fd5f

Please sign in to comment.