diff --git a/jupyter_book_to_htmlbook/file_processing.py b/jupyter_book_to_htmlbook/file_processing.py index 05a00e2..62b0709 100644 --- a/jupyter_book_to_htmlbook/file_processing.py +++ b/jupyter_book_to_htmlbook/file_processing.py @@ -127,6 +127,8 @@ def process_chapter_single_file(toc_element): chapter['data-type'] = ch_stub.lower() # type: ignore else: chapter['data-type'] = "afterword" # type: ignore + elif ch_stub.lower()[:4] == "appx": + chapter['data-type'] = "appendix" else: chapter['data-type'] = 'chapter' # type: ignore del chapter['class'] # type: ignore diff --git a/tests/test_file_processing.py b/tests/test_file_processing.py index 451db95..b545c69 100644 --- a/tests/test_file_processing.py +++ b/tests/test_file_processing.py @@ -312,3 +312,21 @@ def test_process_chapter_guessing_datatypes_inferred( with open(test_out / f'{datatype[0]}.html') as f: text = f.read() assert text.find(f'data-type="{datatype[1]}') > -1 + + def test_process_chapter_appendix_datatypes(self, tmp_path): + """ + Filenames that begin with "appx*" should have the "appendix" + data-type applied. + """ + test_env = tmp_path / 'tmp' + test_out = test_env / 'build' + test_env.mkdir() + test_out.mkdir() + test_file_path = test_env / 'appx_a.html' + shutil.copy('tests/example_book/_build/html/intro.html', + test_file_path) + process_chapter(test_file_path, test_env, test_out) + # the resulting section should have a data-type of "datatype" + with open(test_out / 'appx_a.html') as f: + text = f.read() + assert text.find('data-type="appendix"') > -1