Repository navigation
Support ansi hyperlinks - #10416
Support ansi hyperlinks#10416
Conversation
…ed on build sessions
Co-authored-by: Kevin Ushey <[email protected]>
Co-authored-by: Kevin Ushey <[email protected]>
gtritchie
left a comment
There was a problem hiding this comment.
Minor comment on the NEWS entry, but otherwise looks great!
| ".xtermHyperlink { cursor: pointer; }", | ||
| ".xtermHyperlink:hover { text-decoration: underline; }", |
There was a problem hiding this comment.
Minor edge case; if a user had previously imported a theme into RStudio (.tmtheme), then upgraded to RStudio with this new feature, the saved .rstheme won't have these two lines. I think they'd have to delete the theme and reimport it to correct that. Don't think we need to do anything about that, just mentioning it.
There was a problem hiding this comment.
I think it's a minor issue, because the link already get added xtermUnderline and xtermColor5 so they do stand out.
The :hover bit could be removed I suppose, it's only useful if the xtermUnderline style was cancelled.
I had to add the cursor: pointer because it would only be inherited from <a> when there is an href= attribute, but then the linked page opened in the same tab in addition to triggering the rpc.
There was a problem hiding this comment.
We could add anchor.setAttribute("style", "cursor: pointer;"); to be on the safe side.
|
Rebasing to |
|
@romainfrancois, is this ready for merge now? |
|
Yes, I think it can be merged. |
|
It looks like unfortunately there's a merge conflict now -- @romainfrancois are you able to take a look? |
…on-test * 'main' of github.com:rstudio/rstudio: Fix duplicate menu separators (#10533) use RSTUDIO_CLI_HYPERLIKNS env var Mention issue number in NEWS. stamp version into Electron app (macOS) fix NEWS fix NEWS year produce separate UTF-8 rsession binary for ucrt builds (#10524) Check if load from base is masked before calling load workspace alternate mechanism for R_ResetConsole on Windows (#10510) rotate news files (#10528) Move old NEWS versions in version/news subdirectory Change name back to NEWS.md Add RSW section Add version numbering to NEWS file to avoid further conflicts/overwrites Remove GO NEWS files NEWS for Spotted Wakerobin only Support ansi hyperlinks (#10416) Update to Quarto v0.3.114
|
I can confirm this does not work on a desktop build ( .rs.api.viewer("https://dplyr.tidyverse.org/reference/summarise.html")Because the viewer is not meant to open these links anyway: It is my misunderstanding that it would work. Problem is it does work when using server, e.g. rendering on chrome. I'll open a follow up issue. |
|
Ah okay thanks! In that case I think we can consider this issue verified, will update the issue |


Intent
Adresses #1941 (replaces #10299)
Approach
The hyperlink escape code described in https://iterm2.com/documentation-escape-codes.html are recognized, and the text between an opening anchor code (with a url) and a closing one (w/o) is displayed as a clickable link.
The action when such a link is clicked depends on its 3 components
url,text,params:rstudio:viewer:then the remaining is used as an url to open in the viewer:rstudio:viewer:http://example.comfile://the file is navigated to,paramsmay containline=3:col=4to navigate to line 3 and column 4 of the file.rstudio:helpthenparams$topicand (optionally)params$packageare used to open the relevant help page in the help pane.rstudio:vignette, same thing but for vignettes.rstudio:runthen the text is sent to the console, params may contain parameters supported by.rs.api.sendToConsolerstudio:run:then the remaining is sent to the console, e.g.rstudio:run:head(mtcars)For ease, the url may be generated by
cli::style_hyperlink()(>= 3.1.1)Automated Tests
This has unit tests to assert that the right thing is written in the Dom:
QA Notes
This should display links:
clicking on these links will:
open the webpage in a browser
open the webpage in the viewer pane
navigate to the file
navigate to the 2nd line of the file
navigate to the 2nd line on column 6 of the file
open the help page for
stats::rnorm()open the help for
mean()open the type size vignette
put the code
head(mtcars)in the console w/o executing itput the code
head(mtcars)in the console one character at a time, and then execute it.Checklist
NEWS.md