diff --git a/.isort.cfg b/.isort.cfg index fc0db9b93d..263016922f 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -1,7 +1,7 @@ [settings] src_paths = . multi_line_output = 3 -known_third_party = decorator, jinja2, stripe, tornado, zulip +known_third_party = decorator, jinja2, markdown, stripe, tornado, zulip include_trailing_comma = True use_parentheses = True line_length = 100 diff --git a/docs/THIRDPARTY b/docs/THIRDPARTY index af203235f1..b44ff3b525 100644 --- a/docs/THIRDPARTY +++ b/docs/THIRDPARTY @@ -117,7 +117,7 @@ Copyright: 2017 Fonticons, Inc. License: CC-BY-4.0 Comment: This icon is picked from Version 5.13.0 of Fontawesome -Files: zerver/lib/bugdown/fenced_code.py +Files: zerver/lib/markdown/fenced_code.py Copyright: 2006-2008 Waylan Limberg License: BSD-3-Clause Comment: https://pypi.python.org/pypi/Markdown diff --git a/docs/documentation/api.md b/docs/documentation/api.md index 43045c061c..0d0c9f6bb2 100644 --- a/docs/documentation/api.md +++ b/docs/documentation/api.md @@ -170,7 +170,7 @@ We have a separate Markdown extension to document the parameters that an API endpoint supports. You'll see this in files like `templates/zerver/api/render-message.md` via the following Markdown directive (implemented in -`zerver/lib/bugdown/api_arguments_table_generator.py`): +`zerver/lib/markdown/api_arguments_table_generator.py`): ``` {generate_api_arguments_table|zulip.yaml|/messages/render:post} diff --git a/docs/documentation/user.md b/docs/documentation/user.md index e89247d398..9c4e990a0e 100644 --- a/docs/documentation/user.md +++ b/docs/documentation/user.md @@ -248,9 +248,9 @@ languages in API docs, etc. To create a tab switcher, write: The tab identifiers (e.g. `desktop-web` above) and their mappings to the tabs' labels are declared in -[zerver/lib/bugdown/tabbed_sections.py][tabbed-sections-code]. +[zerver/lib/markdown/tabbed_sections.py][tabbed-sections-code]. -[tabbed-sections-code]: https://github.com/zulip/zulip/blob/master/zerver/lib/bugdown/tabbed_sections.py#L37 +[tabbed-sections-code]: https://github.com/zulip/zulip/blob/master/zerver/lib/markdown/tabbed_sections.py#L37 This widget can also be used just to create a nice box around a set of instructions diff --git a/docs/overview/directory-structure.md b/docs/overview/directory-structure.md index 7cf870004a..31989759e9 100644 --- a/docs/overview/directory-structure.md +++ b/docs/overview/directory-structure.md @@ -37,7 +37,7 @@ paths will be familiar to Django developers. * `zerver/worker/queue_processors.py` [Queue workers](../subsystems/queuing.md). -* `zerver/lib/bugdown/` [Backend Markdown processor](../subsystems/markdown.md). +* `zerver/lib/markdown/` [Backend Markdown processor](../subsystems/markdown.md). * `zproject/backends.py` [Authentication backends](https://docs.djangoproject.com/en/1.8/topics/auth/customizing/). diff --git a/docs/subsystems/markdown.md b/docs/subsystems/markdown.md index 08d92c3321..08873ccb29 100644 --- a/docs/subsystems/markdown.md +++ b/docs/subsystems/markdown.md @@ -5,7 +5,7 @@ after Zulip's original name of "humbug". End users are using Bugdown within the client, not original Markdown. Zulip has two implementations of Bugdown. The backend implementation -at `zerver/lib/bugdown/` is based on +at `zerver/lib/markdown/` is based on [Python-Markdown](https://pypi.python.org/pypi/Markdown) and is used to authoritatively render messages to HTML (and implements slow/expensive/complex features like querying the Twitter API to @@ -94,7 +94,7 @@ First, you will likely find these third-party resources helpful: When changing Zulip's markdown syntax, you need to update several places: -* The backend markdown processor (`zerver/lib/bugdown/__init__.py`). +* The backend markdown processor (`zerver/lib/markdown/__init__.py`). * The frontend markdown processor (`static/js/markdown.js` and sometimes `static/third/marked/lib/marked.js`), or `markdown.contains_backend_only_syntax` if your changes won't be supported in the frontend processor. diff --git a/mypy.ini b/mypy.ini index 4cedc08c21..c523d92ba2 100644 --- a/mypy.ini +++ b/mypy.ini @@ -110,7 +110,7 @@ strict_optional = False strict_optional = False [mypy-zerver.lib.outgoing_webhook] strict_optional = False -[mypy-zerver.lib.bugdown] # for __init__.py +[mypy-zerver.lib.markdown] # for __init__.py strict_optional = False [mypy-zerver.lib.push_notifications] strict_optional = False diff --git a/tools/test-backend b/tools/test-backend index 8c8fc3b157..3513243a99 100755 --- a/tools/test-backend +++ b/tools/test-backend @@ -62,7 +62,7 @@ not_yet_fully_covered = {path for target in [ 'analytics/views.py', # Major lib files should have 100% coverage 'zerver/lib/addressee.py', - 'zerver/lib/bugdown/__init__.py', + 'zerver/lib/markdown/__init__.py', 'zerver/lib/cache.py', 'zerver/lib/cache_helpers.py', 'zerver/lib/i18n.py', @@ -71,10 +71,10 @@ not_yet_fully_covered = {path for target in [ 'zerver/lib/url_preview/preview.py', 'zerver/worker/queue_processors.py', # Bugdown sub-libs should have full coverage too; a lot are really close - 'zerver/lib/bugdown/api_arguments_table_generator.py', - 'zerver/lib/bugdown/fenced_code.py', - 'zerver/lib/bugdown/help_relative_links.py', - 'zerver/lib/bugdown/nested_code_blocks.py', + 'zerver/lib/markdown/api_arguments_table_generator.py', + 'zerver/lib/markdown/fenced_code.py', + 'zerver/lib/markdown/help_relative_links.py', + 'zerver/lib/markdown/nested_code_blocks.py', # Other lib files that ideally would coverage, but aren't sorted 'zerver/__init__.py', 'zerver/filters.py', diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index 2fde7f3031..5da6079fe3 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -49,7 +49,7 @@ from confirmation.models import ( generate_key, ) from zerver.decorator import statsd_increment -from zerver.lib import bugdown +from zerver.lib import markdown as bugdown from zerver.lib import retention as retention from zerver.lib.addressee import Addressee from zerver.lib.alert_words import ( @@ -59,7 +59,6 @@ from zerver.lib.alert_words import ( ) from zerver.lib.avatar import avatar_url, avatar_url_from_dict from zerver.lib.bot_config import ConfigError, get_bot_config, get_bot_configs, set_bot_config -from zerver.lib.bugdown import version as bugdown_version from zerver.lib.bulk_create import bulk_create_users from zerver.lib.cache import ( bot_dict_fields, @@ -97,6 +96,7 @@ from zerver.lib.export import get_realm_exports_serialized from zerver.lib.external_accounts import DEFAULT_EXTERNAL_ACCOUNTS from zerver.lib.hotspots import get_next_hotspots from zerver.lib.i18n import get_language_name +from zerver.lib.markdown import version as bugdown_version from zerver.lib.message import ( MessageDict, access_message, diff --git a/zerver/lib/import_realm.py b/zerver/lib/import_realm.py index 1f6fc1f978..65d21d1d81 100644 --- a/zerver/lib/import_realm.py +++ b/zerver/lib/import_realm.py @@ -15,7 +15,7 @@ from psycopg2.extras import execute_values from psycopg2.sql import SQL, Identifier from analytics.models import RealmCount, StreamCount, UserCount -from zerver.lib import bugdown +from zerver.lib import markdown as bugdown from zerver.lib.actions import ( UserMessageLite, bulk_insert_ums, @@ -23,9 +23,9 @@ from zerver.lib.actions import ( do_change_plan_type, ) from zerver.lib.avatar_hash import user_avatar_path_from_ids -from zerver.lib.bugdown import version as bugdown_version from zerver.lib.bulk_create import bulk_create_users, bulk_set_users_or_streams_recipient_fields from zerver.lib.export import DATE_FIELDS, Field, Path, Record, TableData, TableName +from zerver.lib.markdown import version as bugdown_version from zerver.lib.parallel import run_parallel from zerver.lib.server_initialization import create_internal_realm, server_initialized from zerver.lib.streams import render_stream_description diff --git a/zerver/lib/bugdown/__init__.py b/zerver/lib/markdown/__init__.py similarity index 99% rename from zerver/lib/bugdown/__init__.py rename to zerver/lib/markdown/__init__.py index 9654abe851..1a4ade5779 100644 --- a/zerver/lib/bugdown/__init__.py +++ b/zerver/lib/markdown/__init__.py @@ -41,8 +41,6 @@ from markdown.extensions import codehilite, nl2br, sane_lists, tables from typing_extensions import TypedDict from zerver.lib import mention as mention -from zerver.lib.bugdown import fenced_code -from zerver.lib.bugdown.fenced_code import FENCE_RE from zerver.lib.cache import NotFoundInCache, cache_with_key from zerver.lib.camo import get_camo_url from zerver.lib.emoji import ( @@ -52,6 +50,8 @@ from zerver.lib.emoji import ( translate_emoticons, ) from zerver.lib.exceptions import BugdownRenderingException +from zerver.lib.markdown import fenced_code +from zerver.lib.markdown.fenced_code import FENCE_RE from zerver.lib.mention import extract_user_group, possible_mentions, possible_user_group_mentions from zerver.lib.tex import render_tex from zerver.lib.thumbnail import user_uploads_or_external diff --git a/zerver/lib/bugdown/api_arguments_table_generator.py b/zerver/lib/markdown/api_arguments_table_generator.py similarity index 100% rename from zerver/lib/bugdown/api_arguments_table_generator.py rename to zerver/lib/markdown/api_arguments_table_generator.py diff --git a/zerver/lib/bugdown/api_return_values_table_generator.py b/zerver/lib/markdown/api_return_values_table_generator.py similarity index 100% rename from zerver/lib/bugdown/api_return_values_table_generator.py rename to zerver/lib/markdown/api_return_values_table_generator.py diff --git a/zerver/lib/bugdown/fenced_code.py b/zerver/lib/markdown/fenced_code.py similarity index 100% rename from zerver/lib/bugdown/fenced_code.py rename to zerver/lib/markdown/fenced_code.py diff --git a/zerver/lib/bugdown/help_emoticon_translations_table.py b/zerver/lib/markdown/help_emoticon_translations_table.py similarity index 100% rename from zerver/lib/bugdown/help_emoticon_translations_table.py rename to zerver/lib/markdown/help_emoticon_translations_table.py diff --git a/zerver/lib/bugdown/help_relative_links.py b/zerver/lib/markdown/help_relative_links.py similarity index 100% rename from zerver/lib/bugdown/help_relative_links.py rename to zerver/lib/markdown/help_relative_links.py diff --git a/zerver/lib/bugdown/help_settings_links.py b/zerver/lib/markdown/help_settings_links.py similarity index 100% rename from zerver/lib/bugdown/help_settings_links.py rename to zerver/lib/markdown/help_settings_links.py diff --git a/zerver/lib/bugdown/include.py b/zerver/lib/markdown/include.py similarity index 100% rename from zerver/lib/bugdown/include.py rename to zerver/lib/markdown/include.py diff --git a/zerver/lib/bugdown/nested_code_blocks.py b/zerver/lib/markdown/nested_code_blocks.py similarity index 97% rename from zerver/lib/bugdown/nested_code_blocks.py rename to zerver/lib/markdown/nested_code_blocks.py index 02f16dd05d..cbd4a502cd 100644 --- a/zerver/lib/bugdown/nested_code_blocks.py +++ b/zerver/lib/markdown/nested_code_blocks.py @@ -4,7 +4,7 @@ from xml.etree.ElementTree import Element, SubElement import markdown from markdown.extensions import Extension -from zerver.lib.bugdown import ResultWithFamily, walk_tree_with_family +from zerver.lib.markdown import ResultWithFamily, walk_tree_with_family class NestedCodeBlocksRenderer(Extension): diff --git a/zerver/lib/bugdown/tabbed_sections.py b/zerver/lib/markdown/tabbed_sections.py similarity index 100% rename from zerver/lib/bugdown/tabbed_sections.py rename to zerver/lib/markdown/tabbed_sections.py diff --git a/zerver/lib/bugdown/testing_mocks.py b/zerver/lib/markdown/testing_mocks.py similarity index 100% rename from zerver/lib/bugdown/testing_mocks.py rename to zerver/lib/markdown/testing_mocks.py diff --git a/zerver/lib/bugdown/tlds-alpha-by-domain.txt b/zerver/lib/markdown/tlds-alpha-by-domain.txt similarity index 100% rename from zerver/lib/bugdown/tlds-alpha-by-domain.txt rename to zerver/lib/markdown/tlds-alpha-by-domain.txt diff --git a/zerver/lib/message.py b/zerver/lib/message.py index c76caa751c..9706d53a97 100644 --- a/zerver/lib/message.py +++ b/zerver/lib/message.py @@ -13,7 +13,7 @@ from psycopg2.sql import SQL from typing_extensions import TypedDict from analytics.lib.counts import COUNT_STATS, RealmCount -from zerver.lib import bugdown as bugdown +from zerver.lib import markdown as bugdown from zerver.lib.avatar import get_avatar_field from zerver.lib.cache import ( cache_with_key, diff --git a/zerver/lib/realm_description.py b/zerver/lib/realm_description.py index 409a4d3fbd..83bf29ebc4 100644 --- a/zerver/lib/realm_description.py +++ b/zerver/lib/realm_description.py @@ -1,10 +1,10 @@ -from zerver.lib.bugdown import convert as bugdown_convert from zerver.lib.cache import ( cache_with_key, realm_rendered_description_cache_key, realm_text_description_cache_key, ) from zerver.lib.html_to_text import html_to_text +from zerver.lib.markdown import convert as bugdown_convert from zerver.models import Realm diff --git a/zerver/lib/streams.py b/zerver/lib/streams.py index f74d618ffd..9b9b8f0c9d 100644 --- a/zerver/lib/streams.py +++ b/zerver/lib/streams.py @@ -4,7 +4,7 @@ from django.conf import settings from django.db.models.query import QuerySet from django.utils.translation import ugettext as _ -from zerver.lib.bugdown import convert as bugdown_convert +from zerver.lib.markdown import convert as bugdown_convert from zerver.lib.request import JsonableError from zerver.models import ( DefaultStreamGroup, diff --git a/zerver/lib/test_classes.py b/zerver/lib/test_classes.py index 63b7d29436..a4265ddf1c 100644 --- a/zerver/lib/test_classes.py +++ b/zerver/lib/test_classes.py @@ -823,8 +823,8 @@ class ZulipTestCase(TestCase): ''' with \ self.settings(ERROR_BOT=None), \ - mock.patch('zerver.lib.bugdown.timeout', side_effect=KeyError('foo')), \ - mock.patch('zerver.lib.bugdown.bugdown_logger'): + mock.patch('zerver.lib.markdown.timeout', side_effect=KeyError('foo')), \ + mock.patch('zerver.lib.markdown.bugdown_logger'): yield def create_default_device(self, user_profile: UserProfile, diff --git a/zerver/middleware.py b/zerver/middleware.py index 2dd90c1fbc..9b90af5bf6 100644 --- a/zerver/middleware.py +++ b/zerver/middleware.py @@ -14,12 +14,12 @@ from django.utils.deprecation import MiddlewareMixin from django.utils.translation import ugettext as _ from django.views.csrf import csrf_failure as html_csrf_failure -from zerver.lib.bugdown import get_bugdown_requests, get_bugdown_time from zerver.lib.cache import get_remote_cache_requests, get_remote_cache_time from zerver.lib.db import reset_queries from zerver.lib.debug import maybe_tracemalloc_listen from zerver.lib.exceptions import ErrorCode, JsonableError, RateLimited from zerver.lib.html_to_text import get_content_description +from zerver.lib.markdown import get_bugdown_requests, get_bugdown_time from zerver.lib.rate_limiter import RateLimitResult from zerver.lib.response import json_error, json_response_from_error from zerver.lib.subdomains import get_subdomain diff --git a/zerver/templatetags/app_filters.py b/zerver/templatetags/app_filters.py index 00bd47cf2b..88e179c051 100644 --- a/zerver/templatetags/app_filters.py +++ b/zerver/templatetags/app_filters.py @@ -9,15 +9,15 @@ from django.template import Library, engines from django.utils.safestring import mark_safe from jinja2.exceptions import TemplateNotFound -import zerver.lib.bugdown.api_arguments_table_generator -import zerver.lib.bugdown.api_return_values_table_generator -import zerver.lib.bugdown.fenced_code -import zerver.lib.bugdown.help_emoticon_translations_table -import zerver.lib.bugdown.help_relative_links -import zerver.lib.bugdown.help_settings_links -import zerver.lib.bugdown.include -import zerver.lib.bugdown.nested_code_blocks -import zerver.lib.bugdown.tabbed_sections +import zerver.lib.markdown.api_arguments_table_generator +import zerver.lib.markdown.api_return_values_table_generator +import zerver.lib.markdown.fenced_code +import zerver.lib.markdown.help_emoticon_translations_table +import zerver.lib.markdown.help_relative_links +import zerver.lib.markdown.help_settings_links +import zerver.lib.markdown.include +import zerver.lib.markdown.nested_code_blocks +import zerver.lib.markdown.tabbed_sections import zerver.openapi.markdown_extension from zerver.lib.cache import dict_to_items_tuple, ignore_unhashable_lru_cache, items_tuple_to_dict @@ -85,9 +85,9 @@ def render_markdown_path(markdown_file_path: str, data.""" # We set this global hackishly - from zerver.lib.bugdown.help_settings_links import set_relative_settings_links + from zerver.lib.markdown.help_settings_links import set_relative_settings_links set_relative_settings_links(bool(context.get('html_settings_links'))) - from zerver.lib.bugdown.help_relative_links import set_relative_help_links + from zerver.lib.markdown.help_relative_links import set_relative_help_links set_relative_help_links(bool(context.get('html_settings_links'))) global md_extensions @@ -101,21 +101,21 @@ def render_markdown_path(markdown_file_path: str, linenums=False, guess_lang=False, ), - zerver.lib.bugdown.fenced_code.makeExtension( + zerver.lib.markdown.fenced_code.makeExtension( run_content_validators=context.get('run_content_validators', False), ), - zerver.lib.bugdown.api_arguments_table_generator.makeExtension( + zerver.lib.markdown.api_arguments_table_generator.makeExtension( base_path='templates/zerver/api/'), - zerver.lib.bugdown.api_return_values_table_generator.makeExtension( + zerver.lib.markdown.api_return_values_table_generator.makeExtension( base_path='templates/zerver/api/'), - zerver.lib.bugdown.nested_code_blocks.makeExtension(), - zerver.lib.bugdown.tabbed_sections.makeExtension(), - zerver.lib.bugdown.help_settings_links.makeExtension(), - zerver.lib.bugdown.help_relative_links.makeExtension(), - zerver.lib.bugdown.help_emoticon_translations_table.makeExtension(), + zerver.lib.markdown.nested_code_blocks.makeExtension(), + zerver.lib.markdown.tabbed_sections.makeExtension(), + zerver.lib.markdown.help_settings_links.makeExtension(), + zerver.lib.markdown.help_relative_links.makeExtension(), + zerver.lib.markdown.help_emoticon_translations_table.makeExtension(), ] if md_macro_extension is None: - md_macro_extension = zerver.lib.bugdown.include.makeExtension( + md_macro_extension = zerver.lib.markdown.include.makeExtension( base_path='templates/zerver/help/include/') extensions = md_extensions if 'api_url' in context: diff --git a/zerver/tests/test_bugdown.py b/zerver/tests/test_bugdown.py index 1dbf6da417..7a7dfb2452 100644 --- a/zerver/tests/test_bugdown.py +++ b/zerver/tests/test_bugdown.py @@ -9,7 +9,8 @@ import ujson from django.conf import settings from django.test import TestCase, override_settings -from zerver.lib import bugdown, mdiff +from zerver.lib import markdown as bugdown +from zerver.lib import mdiff from zerver.lib.actions import ( do_add_alert_words, do_remove_realm_emoji, @@ -657,14 +658,14 @@ class BugdownTest(ZulipTestCase): def test_inline_dropbox(self) -> None: msg = 'Look at how hilarious our old office was: https://www.dropbox.com/s/ymdijjcg67hv2ta/IMG_0923.JPG' image_info = {'image': 'https://photos-4.dropbox.com/t/2/AABIre1oReJgPYuc_53iv0IHq1vUzRaDg2rrCfTpiWMccQ/12/129/jpeg/1024x1024/2/_/0/4/IMG_0923.JPG/CIEBIAEgAiAHKAIoBw/ymdijjcg67hv2ta/AABz2uuED1ox3vpWWvMpBxu6a/IMG_0923.JPG', 'desc': 'Shared with Dropbox', 'title': 'IMG_0923.JPG'} - with mock.patch('zerver.lib.bugdown.fetch_open_graph_image', return_value=image_info): + with mock.patch('zerver.lib.markdown.fetch_open_graph_image', return_value=image_info): converted = bugdown_convert(msg) self.assertEqual(converted, '
Look at how hilarious our old office was: https://www.dropbox.com/s/ymdijjcg67hv2ta/IMG_0923.JPG
\n ') msg = 'Look at my hilarious drawing folder: https://www.dropbox.com/sh/cm39k9e04z7fhim/AAAII5NK-9daee3FcF41anEua?dl=' image_info = {'image': 'https://cf.dropboxstatic.com/static/images/icons128/folder_dropbox.png', 'desc': 'Shared with Dropbox', 'title': 'Saves'} - with mock.patch('zerver.lib.bugdown.fetch_open_graph_image', return_value=image_info): + with mock.patch('zerver.lib.markdown.fetch_open_graph_image', return_value=image_info): converted = bugdown_convert(msg) self.assertEqual(converted, 'Look at my hilarious drawing folder: https://www.dropbox.com/sh/cm39k9e04z7fhim/AAAII5NK-9daee3FcF41anEua?dl=
\n ') @@ -673,7 +674,7 @@ class BugdownTest(ZulipTestCase): # Test photo album previews msg = 'https://www.dropbox.com/sc/tditp9nitko60n5/03rEiZldy5' image_info = {'image': 'https://photos-6.dropbox.com/t/2/AAAlawaeD61TyNewO5vVi-DGf2ZeuayfyHFdNTNzpGq-QA/12/271544745/jpeg/1024x1024/2/_/0/5/baby-piglet.jpg/CKnjvYEBIAIgBygCKAc/tditp9nitko60n5/AADX03VAIrQlTl28CtujDcMla/0', 'desc': 'Shared with Dropbox', 'title': '1 photo'} - with mock.patch('zerver.lib.bugdown.fetch_open_graph_image', return_value=image_info): + with mock.patch('zerver.lib.markdown.fetch_open_graph_image', return_value=image_info): converted = bugdown_convert(msg) self.assertEqual(converted, 'https://www.dropbox.com/sc/tditp9nitko60n5/03rEiZldy5
\n ') @@ -681,7 +682,7 @@ class BugdownTest(ZulipTestCase): def test_inline_dropbox_negative(self) -> None: # Make sure we're not overzealous in our conversion: msg = 'Look at the new dropbox logo: https://www.dropbox.com/static/images/home_logo.png' - with mock.patch('zerver.lib.bugdown.fetch_open_graph_image', return_value=None): + with mock.patch('zerver.lib.markdown.fetch_open_graph_image', return_value=None): converted = bugdown_convert(msg) self.assertEqual(converted, 'Look at the new dropbox logo: https://www.dropbox.com/static/images/home_logo.png
\n ') @@ -689,7 +690,7 @@ class BugdownTest(ZulipTestCase): def test_inline_dropbox_bad(self) -> None: # Don't fail on bad dropbox links msg = "https://zulip-test.dropbox.com/photos/cl/ROmr9K1XYtmpneM" - with mock.patch('zerver.lib.bugdown.fetch_open_graph_image', return_value=None): + with mock.patch('zerver.lib.markdown.fetch_open_graph_image', return_value=None): converted = bugdown_convert(msg) self.assertEqual(converted, '') @@ -2106,8 +2107,8 @@ class BugdownErrorTests(ZulipTestCase): throws an exception""" msg = 'mock rendered message\n' * MAX_MESSAGE_LENGTH - with mock.patch('zerver.lib.bugdown.timeout', return_value=msg), \ - mock.patch('zerver.lib.bugdown.bugdown_logger'): + with mock.patch('zerver.lib.markdown.timeout', return_value=msg), \ + mock.patch('zerver.lib.markdown.bugdown_logger'): with self.assertRaises(BugdownRenderingException): bugdown_convert(msg) diff --git a/zerver/tests/test_custom_profile_data.py b/zerver/tests/test_custom_profile_data.py index 701703e00f..022a44db50 100644 --- a/zerver/tests/test_custom_profile_data.py +++ b/zerver/tests/test_custom_profile_data.py @@ -9,8 +9,8 @@ from zerver.lib.actions import ( try_add_realm_custom_profile_field, try_reorder_realm_custom_profile_fields, ) -from zerver.lib.bugdown import convert as bugdown_convert from zerver.lib.external_accounts import DEFAULT_EXTERNAL_ACCOUNTS +from zerver.lib.markdown import convert as bugdown_convert from zerver.lib.test_classes import ZulipTestCase from zerver.lib.test_helpers import queries_captured from zerver.models import ( diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py index 1178d21733..ff5079508f 100644 --- a/zerver/tests/test_events.py +++ b/zerver/tests/test_events.py @@ -98,13 +98,13 @@ from zerver.lib.actions import ( remove_members_from_user_group, try_update_realm_custom_profile_field, ) -from zerver.lib.bugdown import MentionData from zerver.lib.events import ( apply_events, fetch_initial_state_data, get_raw_user_data, post_process_state, ) +from zerver.lib.markdown import MentionData from zerver.lib.message import ( MessageDict, UnreadMessagesResult, diff --git a/zerver/tests/test_link_embed.py b/zerver/tests/test_link_embed.py index 2dfaf0798e..72994c75cc 100644 --- a/zerver/tests/test_link_embed.py +++ b/zerver/tests/test_link_embed.py @@ -691,7 +691,7 @@ class PreviewTestCase(ZulipTestCase): mocked_response = mock.Mock(side_effect=self.create_mock_response(url)) with self.settings(TEST_SUITE=False, CACHES=TEST_CACHES): with mock.patch('requests.get', mocked_response): - with mock.patch('zerver.lib.bugdown.link_preview.link_embed_data_from_cache', + with mock.patch('zerver.lib.markdown.link_preview.link_embed_data_from_cache', lambda *args, **kwargs: mocked_data): FetchLinksEmbedData().consume(event) diff --git a/zerver/tests/test_messages.py b/zerver/tests/test_messages.py index 55d95dcec6..035bf477bc 100644 --- a/zerver/tests/test_messages.py +++ b/zerver/tests/test_messages.py @@ -16,7 +16,7 @@ from django.utils.timezone import now as timezone_now from analytics.lib.counts import COUNT_STATS from analytics.models import RealmCount from zerver.decorator import JsonableError -from zerver.lib import bugdown +from zerver.lib import markdown as bugdown from zerver.lib.actions import ( check_message, check_send_stream_message, diff --git a/zerver/views/message_edit.py b/zerver/views/message_edit.py index 073fa68602..5e46ee02bb 100644 --- a/zerver/views/message_edit.py +++ b/zerver/views/message_edit.py @@ -8,7 +8,7 @@ from django.utils.timezone import now as timezone_now from django.utils.translation import ugettext as _ from zerver.decorator import REQ, has_request_variables -from zerver.lib import bugdown +from zerver.lib import markdown as bugdown from zerver.lib.actions import ( do_delete_messages, do_update_message, diff --git a/zerver/views/report.py b/zerver/views/report.py index 7fc43daf0b..4fc05cc0d0 100644 --- a/zerver/views/report.py +++ b/zerver/views/report.py @@ -9,7 +9,7 @@ from django.views.decorators.csrf import csrf_exempt from django.views.decorators.http import require_POST from zerver.decorator import human_users_only -from zerver.lib.bugdown import privacy_clean_markdown +from zerver.lib.markdown import privacy_clean_markdown from zerver.lib.queue import queue_json_publish from zerver.lib.request import REQ, has_request_variables from zerver.lib.response import json_success