Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rendering tab characters in .Rmd #9

Closed
raredd opened this issue Dec 20, 2014 · 12 comments
Closed

rendering tab characters in .Rmd #9

raredd opened this issue Dec 20, 2014 · 12 comments

Comments

@raredd
Copy link
Contributor

raredd commented Dec 20, 2014

I've never had problems rendering tables in markdown documents until recently, and I can't quite figure out if this is happening due to a knitr, rmarkdown, or R3.1.2 update. Do you see anything like this as well?

If I have a .Rmd with

{r, results='asis'}
library("Gmisc")
htmlTable(head(mtcars))

I get the results

current cran version

github

github v1.0

Subbing out all the tab characters in table_str renders it properly

gsub("\t", " ", x)

but it wasn't an issue before. Can you reproduce this?

@gforge
Copy link
Owner

gforge commented Dec 20, 2014

The htmlTable() is now in a separate package called... htmlTable! It has been submitted to CRAN and should be available within short. Once it is published the Gmisc package will depend on htmlTable for that part of functionality.

It seems that the first examples contain valid code but that the print.htmlTable fails to use the viewer. I can't reproduce the first error using the htmlTable-package, could you try that package and see if you still get the error: devtools::install_github("gforge/htmlTable")

@raredd
Copy link
Contributor Author

raredd commented Dec 22, 2014

I still just get a pile of html code, but

library(htmlTable)
tmp <- htmlTable(mtcars)
gsub('\t','', tmp)

works as does gsub('\t',' ', tmp) (one space) but not gsub('\t',' ', tmp) (two or more spaces).

"test.Rmd"

{r, results='asis'}
library(htmlTable)
htmlTable(mtcars)

rmarkdown::render("test.Rmd") and knitr::knit2html("test.Rmd") both give blank results; however, knit2html does work if I run it in a non-interactive mode (render does not).

Bizarre.. but at least I have a couple work-arounds. (I'm running all the updated packages and rstudio and 3.1.2)

@gforge
Copy link
Owner

gforge commented Dec 22, 2014

I can't reproduce the bug :-( I've added a test-case that should reproduce your issue - try to run it and see if you still get the same error issues. It sounds like it could possibly be an issue related to iOS/Linux versions of RStudio/rmarkdown.

You can also try and force the non-interactive mode by options(interactive = FALSE) - I've noticed that this is necessary when building vignettes with devtools.

@gforge gforge closed this as completed Dec 29, 2014
@gforge
Copy link
Owner

gforge commented Jan 1, 2015

I recently got a bug report from another user with the same problem and it turned out that it was related to a bug in his pandoc installation. Please verify if this solves your issue as well.

@gforge gforge reopened this Jan 1, 2015
@raredd
Copy link
Contributor Author

raredd commented Jan 6, 2015

I still don't know.. It is definitely a pandoc issue. Possibly more of a pandoc/mac issue. I had already tried reinstalling it (using a package and from source), and that didn't work.

Finally, I went back to 1.12.3 (in hindsight, I suppose this started after I updated to 1.13 which has many warnings about behavioral changes that may break existing documents). Maybe I will look into this again when I don't have this pandoc migraine and some more free time.

So everything seems to be working as expected, but when rendering, now rstudio uses /Applications/RStudio.app/Contents/MacOS/pandoc/pandoc which is 1.12 but before it was using /Library/Haskell/bin/pandoc (v1.13); I still have this on my machine, and it still gives me the mess above when trying to render markdown with \t characters.

Do you know what platform the other user with this problem was using and which version of pandoc?

@gforge
Copy link
Owner

gforge commented Jan 6, 2015

It seems that the 1.13 was causing his issue as well, although he is using Windows. You may want to write a bug report to pandoc: https://github.com/jgm/pandoc/issues

@gforge gforge closed this as completed Jan 6, 2015
@willkjh
Copy link

willkjh commented Jan 6, 2015

The bug comes from version 1.13.1. I am using both Windows 8.1 and also 7.1

pandoc 1.13.1
Compiled with texmath 0.8, highlighting-kate 0.5.8.5.
Syntax highlighting is supported for the following languages:
actionscript, ada, apache, asn1, asp, awk, bash, bibtex, boo, c, changelog,
clojure, cmake, coffee, coldfusion, commonlisp, cpp, cs, css, curry, d,
diff, djangotemplate, doxygen, doxygenlua, dtd, eiffel, email, erlang,
fortran, fsharp, gcc, gnuassembler, go, haskell, haxe, html, ini, isocpp,
java, javadoc, javascript, json, jsp, julia, latex, lex, literatecurry,
literatehaskell, lua, makefile, mandoc, markdown, matlab, maxima, metafont,
mips, modelines, modula2, modula3, monobasic, nasm, noweb, objectivec,
objectivecpp, ocaml, octave, pascal, perl, php, pike, postscript, prolog,
pure, python, r, relaxngcompact, restructuredtext, rhtml, roff, ruby, rust,
scala, scheme, sci, sed, sgml, sql, sqlmysql, sqlpostgresql, tcl, texinfo,
verilog, vhdl, xml, xorg, xslt, xul, yacc, yaml

My ``quick'' fix on my side was to rename Pandoc folder to OldPandoc and everything revert back to normal as long as knitr was calling pandoc from within Rstudio/bin/pandoc/pandoc.

@gforge gforge reopened this Jan 6, 2015
@gforge
Copy link
Owner

gforge commented Jan 6, 2015

Since it will most likely take a while before the pandoc issue is properly addressed, could you check if the bugfix in the develop branch works:
devtools::install_github("gforge/htmlTable", ref="develop")

@willkjh
Copy link

willkjh commented Jan 7, 2015

It did not work on my side. I think the quick fix is the best bet for now. It does not change any of the knitr functionality etc (at least on my end).

@raredd
Copy link
Contributor Author

raredd commented Jan 7, 2015

Same results for me as well.

For some reason, pandoc 1.13 is adding an extra <code> tag right before the table begins on line 5.

@gforge
Copy link
Owner

gforge commented Jan 7, 2015

Ok, I think I've nailed it - pandoc (correctly) classifies the indentation as code blocks. There is a bug report here discussing possible solutions. Until we have a better solution I have fixed the issue by removing all the indentation in the develop branch. I will update the htmlTable-package as soon as the CRAN-policy allows.

@gforge gforge closed this as completed Jan 7, 2015
@raredd
Copy link
Contributor Author

raredd commented Jan 7, 2015

This does fix the problem in 1.13 using the develop branch, but I agree that the readability of the non-indented code suffers greatly. If/when the pandoc issue is resolved, it should not affect the functionality of your package, and it would be easy to add the indentation for aesthetic purposes as a patch. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants