Skip to content

Escaped quote not parsed correctly #873

@espinielli

Description

@espinielli

Examples with strings containing quoted quotation marks (char ", ASCII 34) are not parsed correctly and do not show up in the output .Rd file.
A simplified reproducible example is shown at the bottom.

A realistic one from my code (containing strings with both quotation mark character (" or ASCII 34) and apostrophe character (' or ASCII 39)) is the following:

#' Convert  Degree Minute Seconds (DMS) format to Decimal Degrees (DD)
#'
#' @param value a string representation of an angle (i.e. longitude) in
#'              Degree Minute Second (DMS)), i.e. "51° 43' 34.00\" N"
#'              Note the escaping of double quote.
#'
#' @return a decimal degrees value
#' @export
#'
#' @examples
#' \dontrun{
#' tribble(
#'             ~latitude,           ~longitude,   ~id,
#'   "51° 43' 34.00\" N", "000° 32' 59.00\" W", "BNN",
#'   "51° 19' 51.15\" N", "000° 02' 05.32\" E", "BIG",
#'   "51° 38' 46.00\" N", "000° 09' 06.00\" E", "LAM",
#'   "51° 18' 18.00\" N", "000° 26' 50.00\" W", "OCL"
#' ) %>% mutate(latitude  = ddm2dd(latitude),
#'              longitude = ddm2dd(longitude))
#' }
dms2dd <- function(value) {
  # ...
}

Here is a reprex for a simplified case:

library(roxygen2)
lines <- c("#' with escaped quotation mark",
           "#' @examples",
           "#' \"34.00\\\"\"",
           "h <- function() {}")

writeLines(lines)
#> #' with escaped quotation mark
#> #' @examples
#> #' "34.00\""
#> h <- function() {}

roc_proc_text(rd_roclet(), lines)
#> Warning: @examples [C:/Users/spi/Documents/R/win-library/3.5/
#> temp\RtmpuEYWhL\filec5870af65b9e#3]: mismatched braces or quotes
#> $h.Rd
#> % Generated by roxygen2: do not edit by hand
#> % Please edit documentation in RtmpuEYWhL/filec5870af65b9e
#> \name{h}
#> \alias{h}
#> \title{with escaped quotation mark}
#> \usage{
#> h()
#> }
#> \description{
#> with escaped quotation mark
#> }

Created on 2019-06-19 by the reprex package (v0.3.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorrd ✍️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions