File tree Expand file tree Collapse file tree 4 files changed +37
-0
lines changed
fixtures/projects/mkdocs_material_tags Expand file tree Collapse file tree 4 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,16 @@ def get_html_from_items(
102
102
item_html = f"<h1 id=\" { to_snake_case (item .title )} \" >{ item .title } </h1>{ item_html } "
103
103
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 } '" )
104
104
105
+ # Support mkdocs-material tags
106
+ # See https://squidfunk.github.io/mkdocs-material/plugins/tags
107
+ if "tags" in item .meta :
108
+ tags = item .meta ["tags" ]
109
+ tags_html = "<nav class='md-tags'>"
110
+ for tag in tags :
111
+ tags_html += f"<span class='md-tag'>{ tag } </span>"
112
+ tags_html += "</nav>"
113
+ item_html = tags_html + item_html
114
+
105
115
# Update internal anchor links, image urls, etc
106
116
items_html += fix_internal_links (
107
117
item_html , item .url , directory_urls = dir_urls
Original file line number Diff line number Diff line change
1
+ ---
2
+ tags :
3
+ - HTML5
4
+ - JavaScript
5
+ - CSS
6
+ ---
7
+
8
+ # Hello there
9
+
10
+ Testing [ tags] ( https://squidfunk.github.io/mkdocs-material/plugins/tags/?h=tags#usage ) plugin.
Original file line number Diff line number Diff line change
1
+ site_name : Test
2
+
3
+ theme :
4
+ name : material
5
+
6
+ plugins :
7
+ - tags
8
+ - print-site :
9
+ add_to_navigation : true
10
+
11
+ markdown_extensions :
12
+ - attr_list
Original file line number Diff line number Diff line change @@ -275,6 +275,11 @@ def test_basic_build7(tmp_path):
275
275
"""
276
276
check_build (tmp_path , "bad_headings/mkdocs.yml" , exit_code = 0 )
277
277
278
+ def test_build_with_material_tags (tmp_path ):
279
+ """
280
+ Test support with tags.
281
+ """
282
+ check_build (tmp_path , "mkdocs_material_tags/mkdocs.yml" , exit_code = 0 )
278
283
279
284
def test_basic_disable_plugin (tmp_path ):
280
285
"""
You can’t perform that action at this time.
0 commit comments