diff --git a/mkdocs_print_site_plugin/renderer.py b/mkdocs_print_site_plugin/renderer.py index fa8eff9..75d5940 100644 --- a/mkdocs_print_site_plugin/renderer.py +++ b/mkdocs_print_site_plugin/renderer.py @@ -102,6 +102,16 @@ def get_html_from_items( item_html = f"

{item.title}

{item_html}" logger.warning(f"[mkdocs-print-site] '{item.file.src_path}' file is missing a leading h1 tag. Added to the print-page with title '{item.title}'") + # Support mkdocs-material tags + # See https://squidfunk.github.io/mkdocs-material/plugins/tags + if "tags" in item.meta: + tags = item.meta["tags"] + tags_html = "" + item_html = tags_html + item_html + # Update internal anchor links, image urls, etc items_html += fix_internal_links( item_html, item.url, directory_urls=dir_urls diff --git a/tests/fixtures/projects/mkdocs_material_tags/docs/index.md b/tests/fixtures/projects/mkdocs_material_tags/docs/index.md new file mode 100644 index 0000000..8903870 --- /dev/null +++ b/tests/fixtures/projects/mkdocs_material_tags/docs/index.md @@ -0,0 +1,10 @@ +--- +tags: + - HTML5 + - JavaScript + - CSS +--- + +# Hello there + +Testing [tags](https://squidfunk.github.io/mkdocs-material/plugins/tags/?h=tags#usage) plugin. \ No newline at end of file diff --git a/tests/fixtures/projects/mkdocs_material_tags/mkdocs.yml b/tests/fixtures/projects/mkdocs_material_tags/mkdocs.yml new file mode 100644 index 0000000..939d653 --- /dev/null +++ b/tests/fixtures/projects/mkdocs_material_tags/mkdocs.yml @@ -0,0 +1,12 @@ +site_name: Test + +theme: + name: material + +plugins: + - tags + - print-site: + add_to_navigation: true + +markdown_extensions: + - attr_list \ No newline at end of file diff --git a/tests/test_building.py b/tests/test_building.py index d2c4247..4c1b7bf 100644 --- a/tests/test_building.py +++ b/tests/test_building.py @@ -275,6 +275,11 @@ def test_basic_build7(tmp_path): """ check_build(tmp_path, "bad_headings/mkdocs.yml", exit_code=0) +def test_build_with_material_tags(tmp_path): + """ + Test support with tags. + """ + check_build(tmp_path, "mkdocs_material_tags/mkdocs.yml", exit_code=0) def test_basic_disable_plugin(tmp_path): """