svmiller / steveproj

An R package for getting academic projects/papers started.
http://svmiller.com/steveproj
30 stars 3 forks source link

Make pandoc.to detection more robust #10

Closed andrewheiss closed 3 years ago

andrewheiss commented 3 years ago

knitr::opts_knit$get("rmarkdown.pandoc.to") works fine when knitting, but when running interactively, it returns logical(0) and breaks lots of the logic that depends on is_docx or is_latex being true or false. The pandoc_to() function in knitr always returns true or false, though, so it works both when knitting and when working interactively

is_latex <- knitr::opts_knit$get("rmarkdown.pandoc.to") == "latex"
is_latex
#> logical(0)

is_latex <- knitr::pandoc_to("latex")
is_latex
#> [1] FALSE
svmiller commented 3 years ago

This is good. I'll admit there were occasions of debugging in Rstudio where I had to manually enter that and it was kind of dumb that's what I had to do. I'll also incorporate some of the other things you mentioned in your tweet.