# Value blocks ------------------------------------------------------------
test_that("leading text parsed as paragraph", {
expected <- c(
"
text
",
"", "- x
", "y
", "
"
)
expect_equal(value2html("\ntext\n\\item{x}{y}"), expected)
expect_equal(value2html("text\\item{x}{y}"), expected)
})
test_that("leading text is optional", {
expect_equal(
value2html("\\item{x}{y}"),
c("", "- x
", "y
", "
")
)
})
test_that("can process empty string", {
expect_equal(value2html(""), character())
})
test_that("leading text is optional", {
expect_equal( value2html("text"),"text
")
})
test_that("items are optional", {
value <- rd_text("\\value{text}", fragment = FALSE)
expect_equal(as_data(value[[1]])$contents, "text
")
})
test_that("whitespace between items doesn't affect grouping", {
expect_equal(
value2html("\\item{a}{b}\n\n\\item{c}{d}\n\n\\item{e}{f}"),
c(
"",
"- a
", "b
", "", "",
"- c
", "d
", "", "",
"- e
", "f
",
"
"
)
)
})
test_that("leading whitespace doesn't break items", {
expect_equal(
value2html("\n\\item{a}{b}\n\n\\item{c}{d}\n\n\\item{e}{f}"),
c(
"",
"",
"- a
", "b
", "", "",
"- c
", "d
", "", "",
"- e
", "f
",
"
"
)
)
})
test_that("whitespace between text is preserved", {
expect_equal(
value2html("a\n\nb\n\nc"),
c(
"a
", "", "",
"b
", "", "",
"c
"
)
)
})
test_that("can have multiple interleaved blocks", {
expect_equal(
value2html("text1\\item{a}{b}\\item{c}{d}text2\\item{e}{f}"),
c(
"text1
",
"",
"- a
", "b
",
"- c
", "d
",
"
",
"text2
",
"", "- e
", "f
", "
"
)
)
})