Skip to content

Commit

Permalink
add test includes map
Browse files Browse the repository at this point in the history
  • Loading branch information
TOsmanov committed Jul 25, 2024
1 parent d1673a1 commit 7e18b41
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion foliant/preprocessors/includes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Preprocessor(BasePreprocessor):
'cache_dir': Path('.includescache'),
'aliases': {},
'extensions': ['md'],
'includes_map': True
'includes_map': False
}

tags = 'include',
Expand Down
18 changes: 18 additions & 0 deletions test/test_includes.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,21 @@ def test_extensions(self):
'index.j2': '# My title\n\nIncluded content',
'sub/sub.md': 'Included content'
}

def test_includes_map(self):
self.ptf.options = {'includes_map': True }
input_map = {
'index.md': '# My title\n\n<include src="sub/sub-1.md"></include>\n\n<include src="sub/sub-2.md"></include>',
'sub/sub-1.md': 'Included content 1',
'sub/sub-2.md': 'Included content 2'
}
expected_map = {
'index.md': '# My title\n\nIncluded content 1\n\nIncluded content 2',
'static/includes_map.json': "[{\"file\": \"__src__/index.md\", \"includes\": [\"__src__/sub/sub-1.md\", \"__src__/sub/sub-2.md\"]}]",
'sub/sub-1.md': 'Included content 1',
'sub/sub-2.md': 'Included content 2'
}
self.ptf.test_preprocessor(
input_mapping=input_map,
expected_mapping=expected_map,
)

0 comments on commit 7e18b41

Please sign in to comment.