Repository navigation
Open
Description
This is something I noticed while looking at output on a blog post: https://tidyverse.org/blog/2025/11/two-new-tidymodels-packages/#important
Reproducible with
---
title: "testing"
output:
html_document:
keep_md: true
---
```{r}
library(tidymodels)
library(filtro)
set.seed(1)
yield_split <- initial_split(modeldata::chem_proc_yield)
yield_split
yield_train <- training(yield_split)
yield_test <- testing(yield_split)
```
```{r}
library(important)
library(desirability2)
goals <-
desirability(
maximize(cor_spearman, low = 0.25, high = 1),
maximize(imp_rf_oblique, scale = 2)
)
yield_rec <-
recipe(yield ~ ., data = yield_train) |>
step_impute_knn(all_predictors(), neighbors = 10) |>
step_predictor_desirability(
all_predictors(),
score = goals,
prop_terms = 1 / 10
)
yield_rec
```
Looking at recipes:::print.recipe(), it is using cli only
https://github.com/tidymodels/recipes/blob/810b5b55b912dcae8c57f6d0a8d4db75ca88f7cd/R/recipe.R#L875-L927
So we can reproduce using something like below
---
title: "testing"
output:
html_document:
keep_md: true
---
```{r}
print_cli <- function() {
cli::cli_div(theme = list(.pkg = list(`vec-trunc` = Inf,
`vec-last` = ", ")))
cli::cli_h1("Recipe")
cli::cli_h3("Inputs")
cli::cli_text("Number of variables by role")
tab <- c("X", "Y")
values <- 1:2
cli::cli_verbatim(glue::glue("{names(tab)}: {values}"))
cli::cli_end()
}
print_cli()
```
This is because we have this intermediate md
---
title: "testing"
output:
html_document:
keep_md: true
---
``` r
print_cli <- function() {
cli::cli_div(theme = list(.pkg = list(`vec-trunc` = Inf,
`vec-last` = ", ")))
cli::cli_h1("Recipe")
cli::cli_h3("Inputs")
cli::cli_text("Number of variables by role")
tab <- c("X", "Y")
values <- 1:2
cli::cli_verbatim(glue::glue("{names(tab)}: {values}"))
cli::cli_end()
}
print_cli()
```
```
##
```
```
## ── Recipe ──────────────────────────────────────────────────────────────────────
```
```
##
```
```
## ── Inputs
```
```
## Number of variables by role
```
```
##
```
Is this something we should try to improve in knitr or rmarkdown ? Or is this something related to cli usage ?
I'll look into cli logic to be sure, but maybe you gave ideas @yihui
Metadata
Metadata
Assignees
Labels
No labels
Activity
yihui commentedon Nov 25, 2025
I'm not sure where these newlines came from or why the text output was split into separate blocks. Personally I'd just disable cli's ANSI sequences for pure text output, e.g., https://github.com/yihui/xfun/blob/1188b7c/R/record.R#L244-L245 but it doesn't seem to help here (I just tried it).