Skip to content

Instantly share code, notes, and snippets.

@MichaelChirico
Created May 6, 2025 06:26
Show Gist options
  • Save MichaelChirico/49f51edeecc288d7aabf6bc53cb1aa89 to your computer and use it in GitHub Desktop.
Save MichaelChirico/49f51edeecc288d7aabf6bc53cb1aa89 to your computer and use it in GitHub Desktop.
Demonstrate equivalence of h1/h2 and h2/h3 hierarchies for utils::news
news_fmt <- "%1$s My NEWS
%1$s# pkg 1.0.0 (2020-01-01)
%1$s## Categ 1
%1$s# pkg 0.4.0 (2019-01-01)
%1$s## Categ 1
%1$s## Categ 2"
writeLines(sprintf(news_fmt, ""), h1_tmp<-tempfile())
writeLines(sprintf(news_fmt, "#"), h2_tmp<-tempfile())
build_db_from_str <- function(s) {
tmp <- tempfile()
on.exit(unlink(tmp))
writeLines(s, tmp)
tools:::.build_news_db_from_package_NEWS_md(tmp)
}
all.equal(
build_db_from_str(sprintf(news_fmt, "")),
build_db_from_str(sprintf(news_fmt, "#"))
)
# [1] TRUE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment