Skip to content

Commit 8d870b3

Browse files
committed
move fix_image_links under fix_markdown
1 parent 9fcd45b commit 8d870b3

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

hooks.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,14 @@ def replace_heading(match: re.Match) -> str:
9191
def fix_markdown(source_md: str, page: Page, config: MkDocsConfig, files: Files) -> str:
9292
if page.file.src_uri in SKIP_FILES + MAN_INDEXES:
9393
return source_md
94+
if page.file.name.startswith("life_cycle-"):
95+
source_md = source_md.replace('<img src="', '<img src="../')
9496
source_md = LINKS_PATTERN.sub(replace_link, source_md)
9597
source_md = HEADINGS_PATTERN.sub(replace_heading, source_md)
9698
source_md = f"# {page.file.name}\n" + source_md
9799
return source_md
98100

99-
100-
def fix_img_links(source_md: str, page: Page, config: MkDocsConfig, files: Files) -> str:
101-
if not page.file.name.startswith("life_cycle-"):
102-
return source_md
103-
return source_md.replace('<img src="', '<img src="../')
104-
105-
106-
on_page_markdown = plugins.CombinedEvent(fix_markdown, fix_img_links, populate_index_content)
101+
on_page_markdown = plugins.CombinedEvent(fix_markdown, populate_index_content)
107102

108103

109104
def populate_nav(files: Files) -> dict[str, list[Link]]:

0 commit comments

Comments
 (0)