@@ -1033,32 +1033,44 @@ checkRd <- function(Rd, defines = .Platform$OS.type, stages = "render",
10331033 " Unrecognized \\ tabular format: " , table [[1L ]][[1L ]])
10341034 tags <- RdTags(content )
10351035
1036- newrow <- TRUE
1037- for (i in seq_along(tags )) {
1038- if (newrow ) {
1039- newrow <- FALSE
1040- col <- 0
1041- newcol <- TRUE
1036+ # # Remove trailing \cr as we do in Rd2HTML():
1037+ if (any(ind <- (tags == " \\ cr" ))) {
1038+ i <- max(which(ind ))
1039+ j <- seq.int(i + 1L , length.out = length(content ) - i )
1040+ if (all(grepl(" ^[[:space:]]*$" ,
1041+ vapply(content [j ], .Rd_deparse , " " )))) {
1042+ content <- content [- i ]
1043+ tags <- tags [- i ]
10421044 }
1043- if (newcol ) {
1044- col <- col + 1
1045- if (col > length(format ))
1046- warnRd(table , Rdfile , level = 7 ,
1047- " Only " , length(format ),
1048- if (length(format ) == 1 ) " column " else " columns " ,
1049- " allowed in this table" )
1050- newcol <- FALSE
1045+ }
1046+
1047+ len <- length(format )
1048+ chk <- function (col ) {
1049+ if (col != len ) {
1050+ warnRd(table , Rdfile ,
1051+ level = if (col > len ) 7 else - 1 ,
1052+ " Only " , len ,
1053+ if (len == 1 ) " column " else " columns " ,
1054+ " allowed in this table" ,
1055+ " (row " , row , " has " , col , " )" )
10511056 }
1057+ }
1058+ col <- 1L
1059+ row <- 1L
1060+ for (i in seq_along(tags )) {
10521061 switch (tags [i ],
1053- " \\ tab" = {
1054- newcol <- TRUE
1055- },
1056- " \\ cr" = {
1057- newrow <- TRUE
1058- },
1059- checkBlock(content [[i ]], tags [i ], " \\ tabular" ,
1060- content [seq_len(i - 1L )]))
1062+ " \\ cr" = {
1063+ chk(col )
1064+ row <- row + 1L
1065+ col <- 1L
1066+ },
1067+ " \\ tab" = {
1068+ col <- col + 1L
1069+ },
1070+ checkBlock(content [[i ]], tags [i ], " \\ tabular" ,
1071+ content [seq_len(i - 1L )]))
10611072 }
1073+ chk(col )
10621074 }
10631075
10641076 checkContent <- function (blocks , blocktag ) {
0 commit comments