diff --git a/readthedocs/misc/v2-migration-guide.rst b/readthedocs/misc/v2-migration-guide.rst index e4e111a4..0b6a7c01 100644 --- a/readthedocs/misc/v2-migration-guide.rst +++ b/readthedocs/misc/v2-migration-guide.rst @@ -207,8 +207,10 @@ The ``telethon.errors`` module continues to provide custom errors used by the li // TODO provide a way to see which errors are known in the docs or at tl.telethon.dev -The default markdown parse mode now conforms to the commonmark specification ----------------------------------------------------------------------------- +Changes to the default parse mode +--------------------------------- + +The default markdown parse mode now conforms to the commonmark specification. The old markdown parser (which was used as the default ``client.parse_mode``) used to emulate Telegram Desktop's behaviour. Now ``__ @@ -224,6 +226,8 @@ Because now there's proper parsing, you also gain: * Inline links should no longer behave in a strange manner. * Pre-blocks can now have a language. Official clients don't syntax highlight code yet, though. +Furthermore, the parse mode is no longer client-dependant. It is now configured through ``Message``. + // TODO provide a way to get back the old behaviour? diff --git a/telethon/_client/messageparse.py b/telethon/_client/messageparse.py index b7e76e8d..f545a2f3 100644 --- a/telethon/_client/messageparse.py +++ b/telethon/_client/messageparse.py @@ -10,16 +10,6 @@ if typing.TYPE_CHECKING: from .telegramclient import TelegramClient -def get_parse_mode(self: 'TelegramClient'): - return self._parse_mode - -def set_parse_mode(self: 'TelegramClient', mode: str): - self._parse_mode = utils.sanitize_parse_mode(mode) - -# endregion - -# region Private methods - async def _replace_with_mention(self: 'TelegramClient', entities, i, user): """ Helper method to replace ``entities[i]`` to mention ``user``, diff --git a/telethon/_client/telegramclient.py b/telethon/_client/telegramclient.py index 034b0a30..e9ea9ca9 100644 --- a/telethon/_client/telegramclient.py +++ b/telethon/_client/telegramclient.py @@ -1817,50 +1817,6 @@ class TelegramClient: # endregion Downloads - # region Message parse - - @property - def parse_mode(self: 'TelegramClient'): - """ - This property is the default parse mode used when sending messages. - Defaults to `telethon.extensions.markdown`. It will always - be either `None` or an object with ``parse`` and ``unparse`` - methods. - - When setting a different value it should be one of: - - * Object with ``parse`` and ``unparse`` methods. - * A ``callable`` to act as the parse method. - * A `str` indicating the ``parse_mode``. For Markdown ``'md'`` - or ``'markdown'`` may be used. For HTML, ``'htm'`` or ``'html'`` - may be used. - - The ``parse`` method should be a function accepting a single - parameter, the text to parse, and returning a tuple consisting - of ``(parsed message str, [MessageEntity instances])``. - - The ``unparse`` method should be the inverse of ``parse`` such - that ``assert text == unparse(*parse(text))``. - - See :tl:`MessageEntity` for allowed message entities. - - Example - .. code-block:: python - - # Disabling default formatting - client.parse_mode = None - - # Enabling HTML as the default format - client.parse_mode = 'html' - """ - return messageparse.get_parse_mode(**locals()) - - @parse_mode.setter - def parse_mode(self: 'TelegramClient', mode: str): - return messageparse.set_parse_mode(**locals()) - - # endregion Message parse - # region Messages @forward_call(messages.get_messages)