Skip to content

Commit d101522

Browse files
authored
Exclude Markdown files and READMEs from theme.
Account for capitalization differences and all supported Markdown extensions. Fixes mkdocs#1766.
1 parent 32d2ed3 commit d101522

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

docs/about/release-notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ your global navigation uses more than one level, things will likely be broken.
5656

5757
### Other Changes and Additions to Version 1.1
5858

59+
* Bugfix: Exclude Markdown files and READMEs from theme. (#1766).
5960
* Bugfix: Account for encoded URLs (#1670).
6061
* Bugfix: Ensure theme files do not override `docs_dir` files (#1671).
6162
* Bugfix: Do not normalize URL fragments (#1655).

mkdocs/structure/files.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ def css_files(self):
6666
def add_files_from_theme(self, env, config):
6767
""" Retrieve static files from Jinja environment and add to collection. """
6868
def filter(name):
69-
patterns = ['.*', '*.py', '*.pyc', '*.html', 'mkdocs_theme.yml']
69+
patterns = ['.*', '*.py', '*.pyc', '*.html', '*readme*', 'mkdocs_theme.yml']
70+
patterns.extend('*{0}'.format(x) for x in utils.markdown_extensions)
7071
patterns.extend(config['theme'].static_templates)
7172
for pattern in patterns:
72-
if fnmatch.fnmatch(name, pattern):
73+
if fnmatch.fnmatch(name.lower(), pattern):
7374
return False
7475
return True
7576
for path in env.list_templates(filter_func=filter):

mkdocs/tests/structure/file_tests.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,9 @@ def test_files(self):
322322
@tempdir(files=[
323323
'base.html',
324324
'favicon.ico',
325-
'style.css'
325+
'style.css',
326+
'foo.md',
327+
'README'
326328
])
327329
def test_add_files_from_theme(self, tdir, ddir):
328330
config = load_config(docs_dir=ddir, theme={'name': None, 'custom_dir': tdir})

0 commit comments

Comments
 (0)