custom theme styles ignored when all styled content is interpolated

Open
#748 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
r
Domain
cli

Research direction

Reproduce the three cli::cli_div and cli::cli_text examples in the issue, comparing raw text with fully interpolated and nested styled content. Trace the theme and rendering entry points involved in those calls; done means background-color, transform, and fmt apply consistently when all styled content is interpolated, while existing font-weight and emphasis behavior remains intact.

Written by the indexing model from the issue text.

Description

bug

some custom theme properties seem to only take effect if there is some raw text in the rendered content, ignored otherwise.

cli::cli_div(theme = list(
  ".example" = list(
    "background-color" = "red",                           # BUG?
    "font-weight" = "bold",                               # GOOD
    fmt = \(x) { cat("formatting:", x, "\n"); x },        # BUG?
    transform = \(x) { cat("transforming:", x, "\n"); x } # BUG?
  )
))
# GOOD: bold, background, transform, fmt
cli::cli_text("{.example abc}")
#> transforming: abc
#> formatting: abc
#> abc

# GOOD: bold, italics; BUG?: no background, transform, fmt
cli::cli_text("{.example {.emph abc}}")
#> abc

# GOOD: bold, italics, background, transform, fmt
cli::cli_text("{.example abc{.emph def}}")
#> transforming: abcdef
#> formatting: abcdef
#> abcdef

font-weight applies regardless, while the background-color, transform and fmt only apply if there exists some non-interpolated text in the span.

Dominant language
R
Stars
726
Forks
94
Avg merge
3h 35m
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from r-lib/cli

All issues in r-lib/cli

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.