Don't remove newline character after Pre entities.

This commit is contained in:
levlam 2023-11-06 01:51:51 +03:00
parent c24f62d70b
commit 4983b8e9a3
2 changed files with 3 additions and 6 deletions

View File

@ -2737,9 +2737,6 @@ static FormattedText parse_pre_entities_v3(Slice text) {
result.append(text.begin() + entity_begin, end_tag_begin - entity_begin); result.append(text.begin() + entity_begin, end_tag_begin - entity_begin);
utf16_offset += entity_length; utf16_offset += entity_length;
i = end_tag_end - 1; i = end_tag_end - 1;
if (end_tag_end < size && text[end_tag_end] == '\n') {
i++;
}
is_found = true; is_found = true;
break; break;
} else { } else {

View File

@ -1843,11 +1843,11 @@ TEST(MessageEntities, parse_markdown_v3) {
{{td::MessageEntity::Type::Pre, 4, 10}}); {{td::MessageEntity::Type::Pre, 4, 10}});
check_parse_markdown_v3("asd\naba```\nsome code\n```cabab", "asd\naba\nsome code\ncabab", check_parse_markdown_v3("asd\naba```\nsome code\n```cabab", "asd\naba\nsome code\ncabab",
{{td::MessageEntity::Type::Pre, 7, 11}}); {{td::MessageEntity::Type::Pre, 7, 11}});
check_parse_markdown_v3("asd\naba```\nsome code\n```\ncabab", "asd\naba\nsome code\ncabab", check_parse_markdown_v3("asd\naba```\nsome code\n```\ncabab", "asd\naba\nsome code\n\ncabab",
{{td::MessageEntity::Type::Pre, 7, 11}}); {{td::MessageEntity::Type::Pre, 7, 11}});
check_parse_markdown_v3("asd\naba```a b\nsome code\n```\ncabab", "asd\nabaa b\nsome code\ncabab", check_parse_markdown_v3("asd\naba```a b\nsome code\n```\ncabab", "asd\nabaa b\nsome code\n\ncabab",
{{td::MessageEntity::Type::Pre, 7, 14}}); {{td::MessageEntity::Type::Pre, 7, 14}});
check_parse_markdown_v3("asd\naba```a!@#$%^&*(b\nsome code\n```\ncabab", "asd\nabasome code\ncabab", check_parse_markdown_v3("asd\naba```a!@#$%^&*(b\nsome code\n```\ncabab", "asd\nabasome code\n\ncabab",
{{td::MessageEntity::Type::PreCode, 7, 10, "a!@#$%^&*(b"}}); {{td::MessageEntity::Type::PreCode, 7, 10, "a!@#$%^&*(b"}});
check_parse_markdown_v3("```aba\n```", "aba\n", {{td::MessageEntity::Type::Pre, 0, 4}}); check_parse_markdown_v3("```aba\n```", "aba\n", {{td::MessageEntity::Type::Pre, 0, 4}});
check_parse_markdown_v3("```\n```", "\n", {{td::MessageEntity::Type::Pre, 0, 1}}); check_parse_markdown_v3("```\n```", "\n", {{td::MessageEntity::Type::Pre, 0, 1}});