From e7be328fd19e1a6f2e03f2d3498cd6375363404a Mon Sep 17 00:00:00 2001 From: Valentin Berlier <berlier.v@gmail.com> Date: Tue, 24 Oct 2023 02:14:56 +0200 Subject: [PATCH] fix: extract overlay with relative path --- lectern/extract.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lectern/extract.py b/lectern/extract.py index bf4e6e7..72ece61 100644 --- a/lectern/extract.py +++ b/lectern/extract.py @@ -39,7 +39,9 @@ FragmentLoader = Callable[[Fragment, Mapping[str, Directive]], Optional[Fragment]] -RELATIVE_PATH_REGEX = re.compile(r"^(?:assets|data)(?:/[a-zA-Z0-9_.]+)+$") +RELATIVE_PATH_REGEX = re.compile( + r"^(?:[a-zA-Z0-9_.]+/)?(assets|data)(?:/[a-zA-Z0-9_.]+)+$" +) class Extractor: @@ -332,10 +334,10 @@ def parse_fragments( and ( match := regex.match(inline := inline.children[0].content) or ( - RELATIVE_PATH_REGEX.match(inline) + (directory := RELATIVE_PATH_REGEX.match(inline)) and ( directive := "@resource_pack" - if inline.startswith("assets") + if directory[0] == "assets" else "@data_pack" ) and regex.match(f"{directive} {inline}")