Skip to content

Strip ANSI from the target of {.url} hyperlinks - #845

Merged
gaborcsardi merged 2 commits into
r-lib:mainfrom
taekop:fix/url-interpolation-ansi
Oct 5, 2026
Merged

gaborcsardi merged 2 commits into
r-lib:mainfrom
taekop:fix/url-interpolation-ansi

Conversation

@taekop

@taekop taekop commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

With hyperlinks enabled, {.url} containing a substitution puts ANSI escapes into the link target:

options(cli.hyperlink = TRUE, cli.ansi = TRUE)
test <- "path"
cli::format_inline("{.url https://example.com/{test}}")

The target was https://example.com/\033[3mpath\033[3m, because the substituted value is italicised by the .url style before the whole string is passed to the link builder. Clicking it opens https://example.com/%1B%5B3mpath%1B%5B3m.

make_link_url() now strips ANSI from the target. The displayed text is unchanged, and so is the output for {.url} without substitutions, vectors, already-linked values, and with hyperlinks off.

Closes #757

@gaborcsardi
gaborcsardi merged commit e27cbd2 into r-lib:main Oct 5, 2026
11 checks passed
@gaborcsardi

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

inline markup urls contain invisible invalid characters

2 participants