From bba3ecc818b309040b98067c0d97a794e9f5ffaa Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sun, 5 May 2024 16:08:30 +0300 Subject: [PATCH 1/2] gh-101137: Add `text/x-rst` and `text/markdown` to `mimetypes` --- Lib/mimetypes.py | 2 ++ Lib/test/test_mimetypes.py | 2 ++ .../next/Library/2024-05-05-16-08-03.gh-issue-101137.71ECXu.rst | 2 ++ 3 files changed, 6 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2024-05-05-16-08-03.gh-issue-101137.71ECXu.rst diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py index dad3813e39dbae..ab93a7743f10b2 100644 --- a/Lib/mimetypes.py +++ b/Lib/mimetypes.py @@ -553,6 +553,7 @@ def _default_mime_types(): '.html' : 'text/html', '.htm' : 'text/html', '.n3' : 'text/n3', + '.md' : 'text/markdown', '.txt' : 'text/plain', '.bat' : 'text/plain', '.c' : 'text/plain', @@ -565,6 +566,7 @@ def _default_mime_types(): '.tsv' : 'text/tab-separated-values', '.vtt' : 'text/vtt', '.py' : 'text/x-python', + '.rst' : 'text/x-rst', '.etx' : 'text/x-setext', '.sgm' : 'text/x-sgml', '.sgml' : 'text/x-sgml', diff --git a/Lib/test/test_mimetypes.py b/Lib/test/test_mimetypes.py index 30e1c56bf0bc52..8cb0adb8291708 100644 --- a/Lib/test/test_mimetypes.py +++ b/Lib/test/test_mimetypes.py @@ -214,6 +214,8 @@ def check_extensions(): self.assertEqual(mimetypes.guess_extension('text/html'), '.html') self.assertEqual(mimetypes.guess_extension('text/plain'), '.txt') self.assertEqual(mimetypes.guess_extension('text/rtf'), '.rtf') + self.assertEqual(mimetypes.guess_extension('text/x-rst'), '.rst') + self.assertEqual(mimetypes.guess_extension('text/markdown'), '.md') self.assertEqual(mimetypes.guess_extension('video/mpeg'), '.mpeg') self.assertEqual(mimetypes.guess_extension('video/quicktime'), '.mov') diff --git a/Misc/NEWS.d/next/Library/2024-05-05-16-08-03.gh-issue-101137.71ECXu.rst b/Misc/NEWS.d/next/Library/2024-05-05-16-08-03.gh-issue-101137.71ECXu.rst new file mode 100644 index 00000000000000..c3d1775628bae9 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-05-05-16-08-03.gh-issue-101137.71ECXu.rst @@ -0,0 +1,2 @@ +Mime type ``text/x-rst`` and ``text/markdown`` are now supported by +:mod:`mimetypes`. From 779c7bd71747eca99a83ebb3c5c6c5b06c753d59 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sun, 5 May 2024 16:15:28 +0300 Subject: [PATCH 2/2] Remove `.md` part --- Lib/mimetypes.py | 1 - Lib/test/test_mimetypes.py | 1 - .../Library/2024-05-05-16-08-03.gh-issue-101137.71ECXu.rst | 3 +-- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py index ab93a7743f10b2..722d66e3849952 100644 --- a/Lib/mimetypes.py +++ b/Lib/mimetypes.py @@ -553,7 +553,6 @@ def _default_mime_types(): '.html' : 'text/html', '.htm' : 'text/html', '.n3' : 'text/n3', - '.md' : 'text/markdown', '.txt' : 'text/plain', '.bat' : 'text/plain', '.c' : 'text/plain', diff --git a/Lib/test/test_mimetypes.py b/Lib/test/test_mimetypes.py index 8cb0adb8291708..bf6eae7d0ac9c6 100644 --- a/Lib/test/test_mimetypes.py +++ b/Lib/test/test_mimetypes.py @@ -215,7 +215,6 @@ def check_extensions(): self.assertEqual(mimetypes.guess_extension('text/plain'), '.txt') self.assertEqual(mimetypes.guess_extension('text/rtf'), '.rtf') self.assertEqual(mimetypes.guess_extension('text/x-rst'), '.rst') - self.assertEqual(mimetypes.guess_extension('text/markdown'), '.md') self.assertEqual(mimetypes.guess_extension('video/mpeg'), '.mpeg') self.assertEqual(mimetypes.guess_extension('video/quicktime'), '.mov') diff --git a/Misc/NEWS.d/next/Library/2024-05-05-16-08-03.gh-issue-101137.71ECXu.rst b/Misc/NEWS.d/next/Library/2024-05-05-16-08-03.gh-issue-101137.71ECXu.rst index c3d1775628bae9..3df689b2f03866 100644 --- a/Misc/NEWS.d/next/Library/2024-05-05-16-08-03.gh-issue-101137.71ECXu.rst +++ b/Misc/NEWS.d/next/Library/2024-05-05-16-08-03.gh-issue-101137.71ECXu.rst @@ -1,2 +1 @@ -Mime type ``text/x-rst`` and ``text/markdown`` are now supported by -:mod:`mimetypes`. +Mime type ``text/x-rst`` is now supported by :mod:`mimetypes`.