Skip to content

Commit 59b1e5a

Browse files
committed
split long lines in docs
1 parent b43ddd3 commit 59b1e5a

9 files changed

+131
-63
lines changed

R/brew.R

+16-6
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828
#' \item John MacFarlane (2012): _Pandoc User's Guide_. \url{http://johnmacfarlane.net/pandoc/README.html}
2929
#' }
3030
#' @examples \dontrun{
31-
#' text <- paste('# Header', '', 'What a lovely list:\n<%=as.list(runif(10))%>', 'A wide table:\n<%=mtcars[1:3, ]%>', 'And a nice chart:\n\n<%=plot(1:10)%>', sep = '\n')
31+
#' text <- paste('# Header', '',
32+
#' 'What a lovely list:\n<%=as.list(runif(10))%>',
33+
#' 'A wide table:\n<%=mtcars[1:3, ]%>',
34+
#' 'And a nice chart:\n\n<%=plot(1:10)%>', sep = '\n')
3235
#' Pandoc.brew(text = text)
3336
#' Pandoc.brew(text = text, output = tempfile(), convert = 'html')
3437
#' Pandoc.brew(text = text, output = tempfile(), convert = 'pdf')
@@ -38,14 +41,21 @@
3841
#'
3942
#' ## package bundled examples
4043
#' Pandoc.brew(system.file('examples/minimal.brew', package='pander'))
41-
#' Pandoc.brew(system.file('examples/minimal.brew', package='pander'), output = tempfile(), convert = 'html')
44+
#' Pandoc.brew(system.file('examples/minimal.brew', package='pander'),
45+
#' output = tempfile(), convert = 'html')
4246
#' Pandoc.brew(system.file('examples/short-code-long-report.brew', package='pander'))
43-
#' Pandoc.brew(system.file('examples/short-code-long-report.brew', package='pander'), output = tempfile(), convert = 'html')
47+
#' Pandoc.brew(system.file('examples/short-code-long-report.brew', package='pander'),
48+
#' output = tempfile(), convert = 'html')
4449
#'
4550
#' ## brew returning R objects
46-
#' str(Pandoc.brew(text='Pi equals to <%=pi%>.\nAnd here are some random data:\n<%=runif(10)%>'))
47-
#' str(Pandoc.brew(text='# Header <%=1%>\nPi is <%=pi%> which is smaller then <%=2%>.\nfoo\nbar\n <%=3%>\n<%=mtcars[1:2,]%>'))
48-
#' str(Pandoc.brew(text='<%for (i in 1:5) {%>\n Pi has a lot (<%=i%>) of power: <%=pi^i%><%}%>'))
51+
#' str(Pandoc.brew(text='Pi equals to <%=pi%>.
52+
#' And here are some random data:\n<%=runif(10)%>'))
53+
#'
54+
#' str(Pandoc.brew(text='# Header <%=1%>\nPi is <%=pi%> which is smaller then <%=2%>.
55+
#' foo\nbar\n <%=3%>\n<%=mtcars[1:2,]%>'))
56+
#'
57+
#' str(Pandoc.brew(text='<%for (i in 1:5) {%>
58+
#' Pi has a lot (<%=i%>) of power: <%=pi^i%><%}%>'))
4959
#' }
5060
Pandoc.brew <- function(file = stdin(), output = stdout(), convert = FALSE, open = TRUE, graph.name, graph.dir, graph.hi.res = FALSE, text = NULL, envir = parent.frame()) {
5161

R/convert.R

+4-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ openFileInOS <- function(f) {
4343
#' @examples \dontrun{
4444
#' Pandoc.convert(text = c('# Demo', 'with a paragraph'))
4545
#' Pandoc.convert('http://rapporter.github.com/pander/minimal.md')
46-
#' ## Note: the generated HTML is not showing images with relative path from the above file. Based on that `pdf`, `docx` etc. formats would not work! If you want to convert an online markdown file to other formats with this function, please pre-process the file to have absolute paths instead.
46+
#' ## Note: the generated HTML is not showing images with relative path from the above file.
47+
#' ## Based on that `pdf`, `docx` etc. formats would not work! If you want to convert an
48+
#' ## online markdown file to other formats with this function, please pre-process the file
49+
#' ## to have absolute paths instead.
4750
#' }
4851
Pandoc.convert <- function(f, text, format = 'html', open = TRUE, options = '', footer = TRUE, proc.time, portable.html = TRUE) {
4952

R/evals.R

+35-21
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,8 @@ eval.msgs <- function(src, env = NULL, showInvisible = FALSE, graph.unify = eval
447447
#' 'ggplot(mtcars) + geom_point(aes(x = hp, y = mpg))')
448448
#' evals(txt)
449449
#'
450-
#' ## the same commands in one string but also evaluating the `plot` with `text` (note the leading "+" on the beginning of `text...` line)
450+
#' ## the same commands in one string but also evaluating the `plot` with `text`
451+
#' ## (note the leading "+" on the beginning of `text...` line)
451452
#' txt <- 'df <- mtcars
452453
#' plot(mtcars$hp, pch = 19)
453454
#' +text(mtcars$hp, label = rownames(mtcars), pos = 4)
@@ -462,51 +463,58 @@ eval.msgs <- function(src, env = NULL, showInvisible = FALSE, graph.unify = eval
462463
#'
463464
#' ## adding a caption to a plot
464465
#' evals('set.caption("FOO"); plot(1:10)')
465-
#' ## `plot` is started with a `+` to eval the codes in the same chunk (no extra chunk with NULL result)
466+
#' ## `plot` is started with a `+` to eval the codes in the same chunk
467+
#' ## (no extra chunk with NULL result)
466468
#' evals('set.caption("FOO"); +plot(1:10)')
467469
#'
468470
#' ## handling warnings
469471
#' evals('chisq.test(mtcars$gear, mtcars$hp)')
470-
#' evals(list(c('chisq.test(mtcars$gear, mtcars$am)', 'pi', 'chisq.test(mtcars$gear, mtcars$hp)')), parse = F)
471-
#' evals(c('chisq.test(mtcars$gear, mtcars$am)', 'pi', 'chisq.test(mtcars$gear, mtcars$hp)'))
472+
#' evals(list(c('chisq.test(mtcars$gear, mtcars$am)', 'pi',
473+
#' 'chisq.test(mtcars$gear, mtcars$hp)')), parse = FALSE)
474+
#' evals(c('chisq.test(mtcars$gear, mtcars$am)',
475+
#' 'pi',
476+
#' 'chisq.test(mtcars$gear, mtcars$hp)'))
472477
#'
473478
#' ## handling errors
474479
#' evals('runiff(20)')
475480
#' evals('Old MacDonald had a farm\\dots')
476481
#' evals('## Some comment')
477482
#' evals(c('runiff(20)', 'Old MacDonald had a farm?'))
478-
#' evals(list(c('runiff(20)', 'Old MacDonald had a farm?')), parse = F)
483+
#' evals(list(c('runiff(20)', 'Old MacDonald had a farm?')), parse = FALSE)
479484
#' evals(c('mean(1:10)', 'no.R.function()'))
480-
#' evals(list(c('mean(1:10)', 'no.R.function()')), parse = F)
485+
#' evals(list(c('mean(1:10)', 'no.R.function()')), parse = FALSE)
481486
#' evals(c('no.R.object', 'no.R.function()', 'very.mixed.up(stuff)'))
482-
#' evals(list(c('no.R.object', 'no.R.function()', 'very.mixed.up(stuff)')), parse = F)
487+
#' evals(list(c('no.R.object', 'no.R.function()', 'very.mixed.up(stuff)')), parse = FALSE)
483488
#' evals(c('no.R.object', 'Old MacDonald had a farm\\dots', 'pi'))
484-
#' evals('no.R.object;Old MacDonald had a farm\\dots;pi', parse = F)
485-
#' evals(list(c('no.R.object', 'Old MacDonald had a farm\\dots', 'pi')), parse = F)
489+
#' evals('no.R.object;Old MacDonald had a farm\\dots;pi', parse = FALSE)
490+
#' evals(list(c('no.R.object', 'Old MacDonald had a farm\\dots', 'pi')), parse = FALSE)
486491
#'
487492
#' ## graph options
488493
#' evals('plot(1:10)')
489494
#' evals('plot(1:10);plot(2:20)')
490495
#' evals('plot(1:10)', graph.output = 'jpg')
491496
#' evals('plot(1:10)', height = 800)
492-
#' evals('plot(1:10)', height = 800, hi.res = T)
493-
#' evals('plot(1:10)', graph.output = 'pdf', hi.res = T)
497+
#' evals('plot(1:10)', height = 800, hi.res = TRUE)
498+
#' evals('plot(1:10)', graph.output = 'pdf', hi.res = TRUE)
494499
#' evals('plot(1:10)', res = 30)
495500
#' evals('plot(1:10)', graph.name = 'myplot')
496501
#' evals(list('plot(1:10)', 'plot(2:20)'), graph.name = 'myplots-%d')
497502
#' evals('plot(1:10)', graph.env = TRUE)
498503
#' evals('x <- runif(100);plot(x)', graph.env = TRUE)
499504
#' evals(c('plot(1:10)', 'plot(2:20)'), graph.env = TRUE)
500505
#' evals(c('x <- runif(100)', 'plot(x)','y <- runif(100)', 'plot(y)'), graph.env = TRUE)
501-
#' evals(list(c('x <- runif(100)', 'plot(x)'), c('y <- runif(100)', 'plot(y)')), graph.env = TRUE, parse = F)
506+
#' evals(list(
507+
#' c('x <- runif(100)', 'plot(x)'),
508+
#' c('y <- runif(100)', 'plot(y)')),
509+
#' graph.env = TRUE, parse = FALSE)
502510
#' evals('plot(1:10)', graph.recordplot = TRUE)
503511
#' ## unprinted lattice plot
504512
#' evals('histogram(mtcars$hp)', graph.recordplot = TRUE)
505513
#'
506514
#' ## caching
507515
#' system.time(evals('plot(mtcars)'))
508-
#' system.time(evals('plot(mtcars)')) # running again to see the speed-up :)
509-
#' system.time(evals('plot(mtcars)', cache = FALSE)) # cache disabled
516+
#' system.time(evals('plot(mtcars)')) # running again to see the speed-up :)
517+
#' system.time(evals('plot(mtcars)', cache = FALSE)) # cache disabled
510518
#'
511519
#' ## caching mechanism does check what's inside a variable:
512520
#' x <- mtcars
@@ -517,12 +525,13 @@ eval.msgs <- function(src, env = NULL, showInvisible = FALSE, graph.unify = eval
517525
#' system.time(evals('plot(x)'))
518526
#'
519527
#' ## stress your CPU - only once!
520-
#' evals('x <- sapply(rep(mtcars$hp, 1e3), mean)') # run it again!
528+
#' evals('x <- sapply(rep(mtcars$hp, 1e3), mean)') # run it again!
521529
#'
522530
#' ## play with cache
523531
#' require(lattice)
524532
#' evals('histogram(rep(mtcars$hp, 1e5))')
525-
#' ## nor run the below call - which would return the cached version of the above call :)
533+
#' ## nor run the below call
534+
#' ## that would return the cached version of the above call :)
526535
#' f <- histogram
527536
#' g <- rep
528537
#' A <- mtcars$hp
@@ -552,9 +561,11 @@ eval.msgs <- function(src, env = NULL, showInvisible = FALSE, graph.unify = eval
552561
#' evals('matrix(runif(25), 5, 5)', hooks = list('matrix' = round))
553562
#'
554563
#' ## setting default hook
555-
#' evals(c('runif(10)', 'matrix(runif(9), 3, 3)'), hooks = list('default'=round))
564+
#' evals(c('runif(10)', 'matrix(runif(9), 3, 3)'),
565+
#' hooks = list('default'=round))
556566
#' ## round all values except for matrices
557-
#' evals(c('runif(10)', 'matrix(runif(9), 3, 3)'), hooks = list(matrix = 'print', 'default' = round))
567+
#' evals(c('runif(10)', 'matrix(runif(9), 3, 3)'),
568+
#' hooks = list(matrix = 'print', 'default' = round))
558569
#'
559570
#' # advanced hooks
560571
#' hooks <- list('numeric' = list(round, 2), 'matrix' = list(round, 1))
@@ -572,11 +583,14 @@ eval.msgs <- function(src, env = NULL, showInvisible = FALSE, graph.unify = eval
572583
#' # note the following will not be filtered!
573584
#' evals('matrix(1,1,1)', length = 1)
574585
#'
575-
#' # if you do not want to let such things be eval-ed in the middle of a string use it with other filters :)
586+
#' # if you do not want to let such things be eval-ed in the middle of a string
587+
#' # use it with other filters :)
576588
#' evals('matrix(1,1,1)', length = 1, classes = 'numeric')
577589
#'
578-
#'# hooks & filtering
579-
#' evals('matrix(5,5,5)', hooks = list('matrix' = pander.return), output = 'result')
590+
#' # hooks & filtering
591+
#' evals('matrix(5,5,5)',
592+
#' hooks = list('matrix' = pander.return),
593+
#' output = 'result')
580594
#'
581595
#' # eval-ing chunks in given environment
582596
#' myenv <- new.env()

R/pandoc.R

+11-4
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,10 @@ pandoc.title <- function(...)
374374
#' pandoc.list(letters[1:5], loose = TRUE)
375375
#'
376376
#' ## nested lists
377-
#' l <- list("First list element", rep.int('sub element', 5), "Second element", list('F', 'B', 'I', c('phone', 'pad', 'talics')))
377+
#' l <- list("First list element",
378+
#' rep.int('sub element', 5),
379+
#' "Second element",
380+
#' list('F', 'B', 'I', c('phone', 'pad', 'talics')))
378381
#' pandoc.list(l)
379382
#' pandoc.list(l, loose = TRUE)
380383
#' pandoc.list(l, 'roman')
@@ -474,7 +477,9 @@ pandoc.list <- function(...)
474477
#' pandoc.table(table(state.division, state.region))
475478
#' pandoc.table(table(state.division, state.region), justify = 'centre')
476479
#'
477-
#' m <- data.frame(a=c(1, -500, 10320, 23, 77), b=runif(5), c=c('a', 'bb', 'ccc', 'dddd', 'eeeee'))
480+
#' m <- data.frame(a = c(1, -500, 10320, 23, 77),
481+
#' b = runif(5),
482+
#' c = c('a', 'bb', 'ccc', 'dddd', 'eeeee'))
478483
#' pandoc.table(m)
479484
#' pandoc.table(m, justify = c('right', 'left', 'centre'))
480485
#'
@@ -483,7 +488,8 @@ pandoc.list <- function(...)
483488
#' pandoc.table(mtcars, caption = 'Only once after the first part!')
484489
#'
485490
#' ## tables with line breaks in cells
486-
#' ## Note: line breaks are removed from table content and added automatically based on "split.cells" parameter!
491+
#' ## NOTE: line breaks are removed from table content
492+
#' ## and added automatically based on "split.cells" parameter!
487493
#' t <- data.frame(a = c('hundreds\nof\nmouses', '3 cats'), b=c('FOO is nice', 'BAR\nBAR2'))
488494
#' pandoc.table(t)
489495
#' pandoc.table(t, split.cells = 5)
@@ -495,7 +501,8 @@ pandoc.list <- function(...)
495501
#' pandoc.table(t, style = "grid")
496502
#' pandoc.table(t, style = "grid", split.cells = 5)
497503
#' pandoc.table(t, style = "simple")
498-
#' tryCatch(pandoc.table(t, style = "simple", split.cells = 5), error = function(e) 'Yeah, no newline support in simple tables')
504+
#' tryCatch(pandoc.table(t, style = "simple", split.cells = 5),
505+
#' error = function(e) 'Yeah, no newline support in simple tables')
499506
#' pandoc.table(t, style = "rmarkdown")
500507
#'
501508
#' ## highlight cells

man/Pandoc.brew.Rd

+16-6
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@
8484
}
8585
\examples{
8686
\dontrun{
87-
text <- paste('# Header', '', 'What a lovely list:\\n<\%=as.list(runif(10))\%>', 'A wide table:\\n<\%=mtcars[1:3, ]\%>', 'And a nice chart:\\n\\n<\%=plot(1:10)\%>', sep = '\\n')
87+
text <- paste('# Header', '',
88+
'What a lovely list:\\n<\%=as.list(runif(10))\%>',
89+
'A wide table:\\n<\%=mtcars[1:3, ]\%>',
90+
'And a nice chart:\\n\\n<\%=plot(1:10)\%>', sep = '\\n')
8891
Pandoc.brew(text = text)
8992
Pandoc.brew(text = text, output = tempfile(), convert = 'html')
9093
Pandoc.brew(text = text, output = tempfile(), convert = 'pdf')
@@ -94,14 +97,21 @@ Pandoc.brew(text='<\%for (i in 1:5) {\%>\\n Pi has a lot (<\%=i\%>) of power: <\
9497

9598
## package bundled examples
9699
Pandoc.brew(system.file('examples/minimal.brew', package='pander'))
97-
Pandoc.brew(system.file('examples/minimal.brew', package='pander'), output = tempfile(), convert = 'html')
100+
Pandoc.brew(system.file('examples/minimal.brew', package='pander'),
101+
output = tempfile(), convert = 'html')
98102
Pandoc.brew(system.file('examples/short-code-long-report.brew', package='pander'))
99-
Pandoc.brew(system.file('examples/short-code-long-report.brew', package='pander'), output = tempfile(), convert = 'html')
103+
Pandoc.brew(system.file('examples/short-code-long-report.brew', package='pander'),
104+
output = tempfile(), convert = 'html')
100105

101106
## brew returning R objects
102-
str(Pandoc.brew(text='Pi equals to <\%=pi\%>.\\nAnd here are some random data:\\n<\%=runif(10)\%>'))
103-
str(Pandoc.brew(text='# Header <\%=1\%>\\nPi is <\%=pi\%> which is smaller then <\%=2\%>.\\nfoo\\nbar\\n <\%=3\%>\\n<\%=mtcars[1:2,]\%>'))
104-
str(Pandoc.brew(text='<\%for (i in 1:5) {\%>\\n Pi has a lot (<\%=i\%>) of power: <\%=pi^i\%><\%}\%>'))
107+
str(Pandoc.brew(text='Pi equals to <\%=pi\%>.
108+
And here are some random data:\\n<\%=runif(10)\%>'))
109+
110+
str(Pandoc.brew(text='# Header <\%=1\%>\\nPi is <\%=pi\%> which is smaller then <\%=2\%>.
111+
foo\\nbar\\n <\%=3\%>\\n<\%=mtcars[1:2,]\%>'))
112+
113+
str(Pandoc.brew(text='<\%for (i in 1:5) {\%>
114+
Pi has a lot (<\%=i\%>) of power: <\%=pi^i\%><\%}\%>'))
105115
}
106116
}
107117
\references{

man/Pandoc.convert.Rd

+4-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@
5757
\dontrun{
5858
Pandoc.convert(text = c('# Demo', 'with a paragraph'))
5959
Pandoc.convert('http://rapporter.github.com/pander/minimal.md')
60-
## Note: the generated HTML is not showing images with relative path from the above file. Based on that `pdf`, `docx` etc. formats would not work! If you want to convert an online markdown file to other formats with this function, please pre-process the file to have absolute paths instead.
60+
## Note: the generated HTML is not showing images with relative path from the above file.
61+
## Based on that `pdf`, `docx` etc. formats would not work! If you want to convert an
62+
## online markdown file to other formats with this function, please pre-process the file
63+
## to have absolute paths instead.
6164
}
6265
}
6366
\references{

0 commit comments

Comments
 (0)