Skip to content

Commit

Permalink
Merge pull request #114 from ropensci/no-warn-no-newline
Browse files Browse the repository at this point in the history
do not issue warning for missing trailing newline
  • Loading branch information
zkamvar authored May 22, 2024
2 parents 4c0c6be + 0ff517f commit a50aaba
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
fix: #103, @maelle)
* Special control characters are now filtered out before processing XML (issue:
#96, fix: #111, @zkamvar)
* Documents with no trailing newline will no longer throw a warning (issue: #65;
fix: #114, @zkamvar)

## MISC

Expand Down
2 changes: 1 addition & 1 deletion R/to_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#' post_list2 <- to_xml(path2)
#' post_list2
to_xml <- function(path, encoding = "UTF-8", sourcepos = FALSE, anchor_links = TRUE, unescaped = TRUE){
content <- readLines(path, encoding = encoding)
content <- readLines(path, encoding = encoding, warn = FALSE)

splitted_content <- split_yaml_body(content)

Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/test-to_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ test_that("to_xml works", {
expect_s3_class(post_list[[2]], "xml_document")
})


test_that("#65 to_xml does not throw a warning for no newline", {
path <- withr::local_tempfile()
# cat writes without a newline
cat("tada!", file = path)
expect_no_warning(res <- to_xml(path))
expect_equal(xml2::xml_text(res$body), "tada!")
})


test_that("to_xml works for Rmd", {
path <- system.file("extdata", "example2.Rmd", package = "tinkr")
post_list <- to_xml(path)
Expand Down

0 comments on commit a50aaba

Please sign in to comment.