diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 061b9992..a6967787 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2575,7 +2575,8 @@ deepLinkInfo text:formattedText need_update_application:Bool = DeepLinkInfo; //@class TextParseMode @description Describes the way the text should be parsed for TextEntities //@description The text should be parsed in markdown-style -textParseModeMarkdown = TextParseMode; +//@version Version of the parser, 0 - Bot API 1.0 parser, 1 - Bot API 4.5 rules with underline, strikethrough and nested entities support +textParseModeMarkdown version:int32 = TextParseMode; //@description The text should be parsed in HTML-style textParseModeHTML = TextParseMode; diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 4bdb117d..66eee5b9 100644 Binary files a/td/generate/scheme/td_api.tlo and b/td/generate/scheme/td_api.tlo differ diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 93b6b177..3086c09c 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -7656,8 +7656,16 @@ td_api::object_ptr Td::do_static_request(td_api::parseTextEntiti switch (request.parse_mode_->get_id()) { case td_api::textParseModeHTML::ID: return parse_html(request.text_); - case td_api::textParseModeMarkdown::ID: - return parse_markdown(request.text_); + case td_api::textParseModeMarkdown::ID: { + auto version = static_cast(request.parse_mode_.get())->version_; + if (version == 0) { + return parse_markdown(request.text_); + } + if (version == 1) { + return parse_markdown_v2(request.text_); + } + return Status::Error("Wrong Markdown version specified"); + } default: UNREACHABLE(); return Status::Error(500, "Unknown parse mode"); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 7f0c421a..00ca58e5 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -901,7 +901,7 @@ class CliClient final : public Actor { string text, vector> entities = {}) { if (entities.empty() && !text.empty()) { auto parsed_text = execute( - td_api::make_object(text, td_api::make_object())); + td_api::make_object(text, td_api::make_object(1))); if (parsed_text->get_id() == td_api::formattedText::ID) { return td_api::move_object_as(parsed_text); } @@ -2563,13 +2563,13 @@ class CliClient final : public Actor { execute(td_api::make_object(args)); } else if (op == "pte") { send_request( - td_api::make_object(args, td_api::make_object())); + td_api::make_object(args, td_api::make_object(1))); } else if (op == "pteh") { send_request( td_api::make_object(args, td_api::make_object())); } else if (op == "ptes") { execute( - td_api::make_object(args, td_api::make_object())); + td_api::make_object(args, td_api::make_object(1))); } else if (op == "ptehs") { execute(td_api::make_object(args, td_api::make_object())); } else if (op == "gfmt") {