Skip to content

Commit

Permalink
update regex and make sure things work in Hyperlinky environments
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed Aug 9, 2024
1 parent 86cfda0 commit 305f7bc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions R/outline.R
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ construct_outline_link <- function(.data) {
dir_common <- get_dir_common_outline(path = .data$file)
is_saved_doc <- !any(.data$file == "unsaved-doc.R")
is_active_doc <- length(unique(.data$file)) == 1L
rs_avail_file_link <- is_rstudio("2023.09.0.375") # better handling after
rs_avail_file_link <- is_rstudio("2023.09.0.375") || (cli::ansi_has_hyperlink_support() && !is_rstudio()) # better handling after
.data <- define_important_element(.data)

if (is.null(dir_common) || !nzchar(dir_common)) {
Expand Down Expand Up @@ -642,7 +642,7 @@ display_outline_element <- function(.data) {
is_tab_or_plot_title ~ stringr::str_extract(outline_el, "title =[^\"']*[\"']([^\"]{5,})[\"']", group = 1),
is_chunk_cap_next & !is_chunk_cap ~ stringr::str_remove_all(outline_el, "\\s?\\#\\|\\s+"),
is_chunk_cap ~ stringr::str_remove_all(stringr::str_extract(outline_el, "(cap|title)\\:\\s*(.+)", group = 2), "\"|'"),
is_cross_ref ~ stringr::str_remove_all(outline_el, "^(i.stat\\:\\:)?.cdocs_lin.s\\(|[\"']\\)$|\""),
is_cross_ref ~ stringr::str_remove_all(outline_el, "^(i.stat\\:\\:)?.cdocs_(lin.s|a.d..er...n)\\(|[\"']\\)$|\""),
is_doc_title ~ stringr::str_remove_all(outline_el, "subtitle\\:\\s?|title\\:\\s?|\"|\\#\\|\\s?"),
is_section_title & !is_md ~ stringr::str_remove(outline_el, "^\\s{0,4}\\#+\\s+|^\\#'\\s\\#+\\s+"), # Keep inline markup
is_section_title & is_md ~ stringr::str_remove_all(outline_el, "^\\#+\\s+|\\{.+\\}|<(a href|img src).+$"), # strip cross-refs.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ bench::mark(
#> # A tibble: 1 × 6
#> expression min median `itr/sec` mem_alloc `gc/sec`
#> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl>
#> 1 outline <- proj_outline() 656ms 656ms 1.52 22.4MB 3.05
#> 1 outline <- proj_outline() 463ms 476ms 2.10 22.4MB 4.21
```

<details>
Expand Down

0 comments on commit 305f7bc

Please sign in to comment.