Skip to content

Commit 35c39d9

Browse files
committed
chore: add a default title for unnamed cards
1 parent e00ca50 commit 35c39d9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

R/Reporter.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,13 @@ Reporter <- R6::R6Class( # nolint: object_name_linter.
212212
if (idx != length(cards)) blocks <- append(blocks, sep)
213213
next # Easier to remove when ReportCard is fully deprecated
214214
}
215-
card_with_title <- if (length(metadata(card, "title")) > 0) {
216-
c(report_document(sprintf("# %s", metadata(card, "title"))), card)
215+
title <- trimws(metadata(card, "title"))
216+
card_title <- if (length(title) > 0 && nzchar(title)) {
217+
report_document(sprintf("# %s", title))
217218
} else {
218-
card
219+
report_document(sprintf("# _Unnamed Card (%d)_", idx))
219220
}
220-
221+
card_with_title <- c(card_title, card)
221222
blocks <- append(blocks, unclass(card_with_title))
222223
if (idx != length(cards)) blocks <- append(blocks, trimws(sep))
223224
}

0 commit comments

Comments
 (0)