test_that("integration test for convert_md()", { skip_if_no_pandoc() path <- withr::local_tempfile(pattern = "pkgdown-llm") convert_md(test_path("assets", "llm.html"), path) expect_snapshot(write_lines(read_lines(path), stdout())) }) test_that("simplifies page header", { html <- xml2::read_html( r"(
)" ) simplify_page_header(xml2::xml_find_first(html, ".//main")) expect_equal(xpath_contents(html, ".//main"), "

Package index

") }) test_that("replaces lifecycle badges with strong text", { html <- xml2::read_html( r"( deprecated [Experimental] )" ) simplify_lifecycle_badges(html) expect_equal( xpath_text(html, ".//strong"), c("[deprecated]", "[experimental]") ) }) test_that("converts internal urls to absolute with .md ending", { html <- xml2::read_html( r"( link link link )" ) create_absolute_links(html, "https://pkgdown.r-lib.org") expect_equal( xpath_attr(html, ".//a", "href"), c( "https://pkgdown.r-lib.org/llm.md", "#fragment", "https://example.org" ) ) }) test_that("adjusts extension even without url", { html <- xml2::read_html(r"(link)") create_absolute_links(html) expect_equal(xpath_attr(html, ".//a", "href"), "llm.md") }) test_that("strip extra classes from pre", { html <- xml2::read_html(r"(
1+1
)") simplify_code(html) expect_equal(xpath_attr(html, ".//pre", "class"), "r") })