Don't ignore article categories when CATEGORY_SAVE_AS is false

Fixes: #3596

Signed-off-by: Aurélien Bompard <aurelien@bompard.org>
This commit is contained in:
Aurélien Bompard 2026-04-22 11:19:10 +02:00
commit 4b8ea9497b
No known key found for this signature in database
GPG key ID: 31584CFEB9BF64AD
2 changed files with 13 additions and 1 deletions

View file

@ -811,7 +811,7 @@ def parse_path_metadata(source_path, settings=None, process=None):
checks = []
for key, data in [("FILENAME_METADATA", base), ("PATH_METADATA", source_path)]:
checks.append((settings.get(key, None), data))
if settings.get("USE_FOLDER_AS_CATEGORY") and settings.get("CATEGORY_SAVE_AS"):
if settings.get("USE_FOLDER_AS_CATEGORY"):
checks.append(("(?P<category>.*)", subdir))
for regexp, data in checks:
if regexp and data:

View file

@ -139,6 +139,18 @@ class DefaultReaderTest(ReaderTest):
extra={"limit_msg": "Other images have empty alt attributes"},
)
def test_path_metadata_categories(self):
nested_content_path = os.path.join(CUR_DIR, "nested_content")
r = readers.Readers(
settings=get_settings(USE_FOLDER_AS_CATEGORY=True, CATEGORY_SAVE_AS=None)
)
mainpage = r.read_file(base_path=nested_content_path, path="maindir/maindir.md")
self.assertDictHasSubset(mainpage.metadata, {"category": "maindir"})
subpage = r.read_file(
base_path=nested_content_path, path="maindir/subdir/subdir.md"
)
self.assertDictHasSubset(subpage.metadata, {"category": "subdir"})
class RstReaderTest(ReaderTest):
def test_article_with_metadata(self):