Rapporter/pander — pull request #108 by RomanTsegelskyi (2014-07-22 14:53:15+00:00)
Title: S3 method for function class

I have added basic method for `function` class.
For now it just renders the body and adds function name if specified by `add.name` param.
For example,

```
> pander(splitLine)
function (x, max.width = panderOptions("table.split.cells"),
use.hyphening = FALSE)
{
if (!is.character(x) || !is.null(dim(x)) || length(x) !=
1)
return(x)
if (suppressWarnings(!is.na(as.numeric(x))))
return(x)
if (is.infinite(max.width))
max.width <- .Machine$integer.max
if (use.hyphening && !require(koRpus))
use.hyphening <- FALSE
hyphen_f <- function(s) hyphen(s, hyph.pattern = "en.us",
quiet = TRUE)@hyphen[1, 2]
.Call("pander_splitLine_cpp", PACKAGE = "pander", x, max.width,
use.hyphening, hyphen_f)
}
```
Name added by `add.name` param.
```
> pander(splitLine, add.name = T)
splitLine <- function (x, max.width = panderOptions("table.split.cells"),
use.hyphening = FALSE)
{
if (!is.character(x) || !is.null(dim(x)) || length(x) !=
1)
return(x)
if (suppressWarnings(!is.na(as.numeric(x))))
return(x)
if (is.infinite(max.width))
max.width <- .Machine$integer.max
if (use.hyphening && !require(koRpus))
use.hyphening <- FALSE
hyphen_f <- function(s) hyphen(s, hyph.pattern = "en.us",
quiet = TRUE)@hyphen[1, 2]
.Call("pander_splitLine_cpp", PACKAGE = "pander", x, max.width,
use.hyphening, hyphen_f)
}
```

What do you think?
One problem that I realized though. When converting to pdf using pandoc all tabulations are being discarded. How can that be avoided?