Skip to content

Commit

Permalink
fix #60: simple and rmarkdown formatted table cells should not be spl…
Browse files Browse the repository at this point in the history
…it automatically
  • Loading branch information
daroczig committed Nov 9, 2013
1 parent 6958ddd commit 3c287f0
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions R/pandoc.R
Original file line number Diff line number Diff line change
Expand Up @@ -551,29 +551,28 @@ pandoc.table.return <- function(t, caption, digits = panderOptions('digits'), de
split.large.cells <- function(cells)
sapply(cells, function(x) {

## escape pipes
if (style == 'rmarkdown')
x <- gsub('\\|', '\\\\|', x)

## split
if (nchar(x) == nchar(x, type = 'width')) {

x <- paste(strwrap(x, width = split.cells), collapse = '\n')

} else {

# dealing with CJK chars
split <- strsplit(x, '\\s')[[1]]
n <- nchar(split[1], type = 'width')
x <- split[1]
for (s in tail(split, -1)) {
nc <- nchar(s, type = 'width')
n <- n + nc + 1
if (n > split.cells) {
n <- nc
x <- paste(x, s, sep = '\n')
} else {
x <- paste(x, s, sep = ' ')
if (!style %in% c('simple', 'rmarkdown')) {

## split
if (nchar(x) == nchar(x, type = 'width')) {

x <- paste(strwrap(x, width = split.cells), collapse = '\n')

} else {

## dealing with CJK chars
split <- strsplit(x, '\\s')[[1]]
n <- nchar(split[1], type = 'width')
x <- split[1]
for (s in tail(split, -1)) {
nc <- nchar(s, type = 'width')
n <- n + nc + 1
if (n > split.cells) {
n <- nc
x <- paste(x, s, sep = '\n')
} else {
x <- paste(x, s, sep = ' ')
}
}
}

Expand All @@ -584,6 +583,7 @@ pandoc.table.return <- function(t, caption, digits = panderOptions('digits'), de
''
else
x

}, USE.NAMES = FALSE)
align.hdr <- function(t.width, justify) {
justify.vec <- rep(justify, length.out = length(t.width))
Expand Down

0 comments on commit 3c287f0

Please sign in to comment.