Skip to content

Commit 8a40007

Browse files
author
hornik
committed
Avoid generating HTML tables with too few columns.
git-svn-id: https://svn.r-project.org/R/trunk@89013 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 9152666 commit 8a40007

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/library/tools/R/Rd2HTML.R

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,19 +1001,21 @@ Rd2HTML <-
10011001
tags <- tags[-i]
10021002
}
10031003
}
1004+
len <- length(format)
1005+
col <- 0L
10041006
for (i in seq_along(tags)) {
10051007
if (concordance)
10061008
conc$saveSrcref(content[[i]])
10071009
if (newrow) {
10081010
of1("<tr>\n ")
10091011
newrow <- FALSE
1010-
col <- 0
1012+
col <- 0L
10111013
}
10121014
if (newcol) {
10131015
col <- col + 1L
1014-
if (col > length(format))
1016+
if (col > len)
10151017
stopRd(table, Rdfile,
1016-
"Only ", length(format),
1018+
"Only ", len,
10171019
" columns allowed in this table")
10181020
of0('<td style="text-align: ', format[col], ';">')
10191021
newcol <- FALSE
@@ -1024,14 +1026,16 @@ Rd2HTML <-
10241026
newcol <- TRUE
10251027
},
10261028
"\\cr" = {
1027-
if (!newcol) of1('</td>')
1029+
if (!newcol)
1030+
of1(paste0("</td>", strrep("<td></td>", len - col)))
10281031
of1('\n</tr>\n')
10291032
newrow <- TRUE
10301033
newcol <- TRUE
10311034
},
10321035
writeBlock(content[[i]], tags[i], "\\tabular"))
10331036
}
1034-
if (!newcol) of1('</td>')
1037+
if (!newcol)
1038+
of1(paste0("</td>", strrep("<td></td>", len - col)))
10351039
if (!newrow) of1('\n</tr>\n')
10361040
of1('\n</table>\n')
10371041
inPara <<- FALSE

src/library/tools/R/RdConv2.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ checkRd <- function(Rd, defines = .Platform$OS.type, stages = "render",
10481048
chk <- function(col) {
10491049
if(col != len) {
10501050
warnRd(table, Rdfile,
1051-
level = if(col > len) 7 else -1,
1051+
level = if(col > len) 7 else -2,
10521052
"Only ", len,
10531053
if(len == 1) " column " else " columns ",
10541054
"allowed in this table",

0 commit comments

Comments
 (0)