Repository navigation
Don't double-escape an already-escaped % in Rd output - #33
Merged
Merged
Conversation
escape_rd() and the three examples paths escaped % unconditionally, so a pre-escaped \% from roxygen2-style sources became \\%, which Rd reads as a literal backslash plus a comment start and mangles the generated file with warnings that never mention %. Centralize the escape in escape_percent(), which uses a negative lookbehind so bare % is escaped exactly once and \% passes through untouched. Both the bare % tinyrox always accepted and the pre-escaped \% a roxygen2 author brings along now produce identical, valid Rd.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #31.
Problem
escape_rd()and the three examples paths escaped%unconditionally, so a pre-escaped\%(what roxygen2 authors write, since roxygen2 makes you escape%yourself) became\\%in the generated Rd. Rd reads that as a literal backslash followed by a comment start, which swallows the rest of the line and malforms the file, withR CMD buildwarnings that never mention%. Hit while preparing compost for CRAN.Fix
The five escape sites now go through one helper,
escape_percent(), using the negative lookbehind from the issue:gsub("(?<!\\\\)%", "\\\\%", text, perl = TRUE). Bare%is escaped exactly once; pre-escaped\%passes through untouched. Only the already-escaped case changes; everything else stays byte-identical:frame_%04d.pngframe_\%04d.pngframe_\%04d.pngframe_\%04d.pngframe_\\%04d.pngframe_\%04d.pngx %in% yx \%in\% yx \%in\% ytrailing \%trailing \\%trailing \%Verification
All 230 tinytest results pass, including new regression cases covering the full behavior table, the markup-passthrough branch of
escape_rd(), mixed bare and pre-escaped%in one string, and the\examplespath viagenerate_rd(). Version bumped to 0.4.0.2.