Skip to content

Struggling with {{ links #1259

@lionel-

Description

@lionel-

I'd like to hyperlink mentions of the {{ operator in the rlang doc because it is not easily searchable.

Here is a counter example with !! that works well:

gen <- function(body) {
  header <- "
#' Foo
#' @md
#' @name foo
#' @description
#'"
  text <- paste0(c(header, body, "NULL"), collapse = "\n")
  roxygen2::roc_proc_text(roxygen2::rd_roclet(), text)
}

gen("#' [`!!`][op-inject]")
#> $foo.Rd
#> % Generated by roxygen2: do not edit by hand
#> % Please edit documentation in ./<text>
#> \name{foo}
#> \alias{foo}
#> \title{Foo}
#> \description{
#> \code{\link[=op-inject]{!!}}
#> }

I would like to generate a similar link for {{, properly escaped:

#> \code{\link[=op-inject]{\{\{}}

Ideally [`{{`][foo] would work but here is what we get:

gen("#' [`{{`][op-embrace]")
#> Warning: [<text>:5] @description mismatched braces or quotes
#> $foo.Rd
#> % Generated by roxygen2: do not edit by hand
#> % Please edit documentation in ./<text>
#> \name{foo}
#> \alias{foo}
#> \title{Foo}
#> \description{
#>
#> }

Escaping { does not work (same result with \\\\{\\\\}):

gen("#' [`\\{\\{`][op-embrace]")
#> Warning: [<text>:5] @description mismatched braces or quotes
#> $foo.Rd
#> % Generated by roxygen2: do not edit by hand
#> % Please edit documentation in ./<text>
#> \name{foo}
#> \alias{foo}
#> \title{Foo}
#> \description{
#>
#> }

And unfortunately, trying to insert Rd manually does not work either

gen("#' \\code{\\link[=foo]{\\{\\{}}}}")
#> Warning: [<text>:5] @description mismatched braces or quotes
#> $foo.Rd
#> % Generated by roxygen2: do not edit by hand
#> % Please edit documentation in ./<text>
#> \name{foo}
#> \alias{foo}
#> \title{Foo}
#> \description{
#>
#> }

gen("#' \\code{\\link[=foo]{\\\\{\\\\{}}}}")
#> $foo.Rd
#> % Generated by roxygen2: do not edit by hand
#> % Please edit documentation in ./<text>
#> \name{foo}
#> \alias{foo}
#> \title{Foo}
#> \description{
#> \code{\link[=foo]{\\{\\{}}}}
#> }

Fixing [`{{`][foo] so that it works as expected would be great. But I'd appreciate pointers to a workaround as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorrd ✍️wipwork in progress

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions