Skip to content

Commit cc7e995

Browse files
committed
fix: list index out of range
closes #6
1 parent 890a09c commit cc7e995

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

mkdocs_embed_file_plugins/src/search_quote.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ def search_in_file(citation_part: str, contents: str) -> str:
4747

4848

4949
def search_file_in_documentation(
50-
link: Union[Path, str], config_dir: Path, base: any
50+
link: Union[Path, str],
51+
config_dir: Path,
52+
base: any, # type: ignore
5153
) -> Union[Path, int]:
5254
file_name = os.path.basename(link)
5355
if not file_name.endswith(".md"):
@@ -58,7 +60,8 @@ def search_file_in_documentation(
5860
else:
5961
baseParent = Path(base).parents
6062
linksParent = Path(link).parents
61-
# find the common parent
63+
if (len(baseParent) == 0) or (len(linksParent) == 0):
64+
return 0
6265
linksBaseEquals = [i for i in linksParent if i in baseParent][0]
6366
relative = Path(str(link).replace(str(linksBaseEquals), ""))
6467
for p in Path(base).rglob(f"**{relative}"):

0 commit comments

Comments
 (0)