Skip to content

Commit 1ea65a5

Browse files
author
smeyer
committed
fix processing multi-line Rd \Sexpr code
git-svn-id: https://svn.r-project.org/R/trunk@88493 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent bb8e4fa commit 1ea65a5

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

src/library/tools/R/RdConv2.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# File src/library/tools/R/RdConv2.R
22
# Part of the R package, https://www.R-project.org
33
#
4-
# Copyright (C) 1995-2024 The R Core Team
4+
# Copyright (C) 1995-2025 The R Core Team
55
#
66
# This program is free software; you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by
@@ -221,7 +221,8 @@ processRdChunk <- function(code, stage, options, env, macros)
221221
code <- structure(code[tags != "COMMENT"],
222222
srcref = codesrcref) # retain for error locations
223223
chunkexps <- tryCatch(
224-
parse(text = as.character(code), keep.source = options$keep.source),
224+
parse(text = sub("\n$", "", as.character(code)),
225+
keep.source = options$keep.source),
225226
error = function (e) stopRd(code, Rdfile, conditionMessage(e))
226227
)
227228

src/library/tools/R/RdHelpers.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ function(key, field, value)
321321
{
322322
Rd_expr_bibinfo_data_store(list(trimws(key),
323323
trimws(field),
324-
gsub("\n\n", "\n", trimws(value))),
324+
trimws(value)),
325325
add = TRUE)
326326
}
327327

tests/testit.html.save

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ a
110110
<p>c
111111
</p>
112112
<p><code style="white-space: pre;">&#8288;
113-
[1] "a\n\n b\n c"
113+
[1] "a\n b\n c"
114114
&#8288;</code>
115115
</p>
116116

tests/testit.tex.save

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ b
8181
c
8282

8383
\AsIs{\texttt{
84-
[1] "a\bsl{}n\bsl{}n b\bsl{}n c"
84+
[1] "a\bsl{}n b\bsl{}n c"
8585
}}
8686
\end{Section}
8787
%

tests/testit.txt.save

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ _V_a_l_u_e:
6868

6969
c
7070

71-
[1] "a\n\n b\n c"
71+
[1] "a\n b\n c"
7272

7373
\_t_a_b_u_l_a_r:
7474

0 commit comments

Comments
 (0)