def on_page_content(self, html: str, page: Page, config: MkDocsConfig, files: Files): if str(page.file.abs_src_path).endswith("ipynb") and not ( "markdown.extensions.md_in_html" in config["markdown_extensions"] or "markdown.extensions.extra" in config["markdown_extensions"]): log.debug(f"Re-rendering page with markdown in divs: {page}") extensions = [ _RelativePathExtension(page.file, files), "markdown.extensions.md_in_html", ] + config["markdown_extensions"] md = markdown.Markdown(extensions=extensions, extension_configs=config["mdx_configs"] or {}) html = md.convert(page.markdown) page.toc = get_toc(getattr(md, "toc_tokens", [])) return html
def test_page(title, filename, config): test_page = Page( title, File(filename, config['docs_dir'], config['site_dir'], config['use_directory_urls']), config) test_page.content = """ <h1 id="heading-1">Heading 1</h1> <p>Content 1</p> <h2 id="heading-2">Heading 2</h1> <p>Content 2</p> <h3 id="heading-3">Heading 3</h1> <p>Content 3</p>""" test_page.markdown = dedent(""" # Heading 1 ## Heading 2 ### Heading 3""") test_page.toc = get_toc(get_markdown_toc(test_page.markdown)) return test_page