## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set(collapse = TRUE, comment = "#>") # Run every chunk inside a scratch directory so the example can use # plain relative file names, as you would in a real paper directory. paper_dir <- tempfile("jsslintr-demo-") dir.create(paper_dir) knitr::opts_knit$set(root.dir = paper_dir) ## ----------------------------------------------------------------------------- writeLines(c( "\\documentclass[nojss]{jss}", "\\author{Jane Doe\\\\University of Somewhere}", "\\title{A great package for doing things in R}", "\\Abstract{We present a package for R, e.g. for plotting.}", "\\Keywords{stuff, things}", "\\begin{document}", "\\section{introduction}", "We use R and the ggplot2 package for our p-values.", "\\end{document}" ), "paper.tex") writeLines(c( "@article{smith2020,", " author = {John Smith},", " title = {Some Methods for Data},", " journal = {Journal of Statistical Software},", " year = {2020},", " volume = {95},", " pages = {1--20}", "}" ), "refs.bib") ## ----------------------------------------------------------------------------- library("jsslintr") res <- jsslint(c("paper.tex", "refs.bib")) res ## ----------------------------------------------------------------------------- summary(res) ## ----------------------------------------------------------------------------- df <- as.data.frame(res) df[df$fixable, c("file", "line", "rule_id", "suggestion")] ## ----------------------------------------------------------------------------- jssfix(res, dry_run = TRUE) ## ----------------------------------------------------------------------------- jssfix(res) ## ----------------------------------------------------------------------------- jsslint(c("paper.tex", "refs.bib")) ## ----------------------------------------------------------------------------- cat(substr(render(c("paper.tex" = "\\documentclass{article}"), output = "json" ), 1, 300), "...\n")