[rkward] rkward/windows: Render preview now uses rmarkdown package (to allow rendering of v2). Includes check for pandoc.
Thomas Friedrichsmeier
null at kde.org
Fri Sep 28 21:28:38 BST 2018
Git commit 79a51159ccd44ac636d0ef9a87f8b9a42a19eb24 by Thomas Friedrichsmeier.
Committed on 28/09/2018 at 20:19.
Pushed by tfry into branch 'master'.
Render preview now uses rmarkdown package (to allow rendering of v2). Includes check for pandoc.
M +17 -6 rkward/windows/rkcommandeditorwindow.cpp
https://commits.kde.org/rkward/79a51159ccd44ac636d0ef9a87f8b9a42a19eb24
diff --git a/rkward/windows/rkcommandeditorwindow.cpp b/rkward/windows/rkcommandeditorwindow.cpp
index 95fcfc62..4ca22e4b 100644
--- a/rkward/windows/rkcommandeditorwindow.cpp
+++ b/rkward/windows/rkcommandeditorwindow.cpp
@@ -804,12 +804,22 @@ void RKCommandEditorWindow::doRenderPreview () {
save.close ();
save.setAutoRemove (false);
- QString command ("require(knitr)\n"
- "require(markdown)\n"
- "rk.show.html (knitr::knit2html(%1, quiet=TRUE))");
- command = command.arg (RObject::rQuote (save.fileName ()));
-
- RCommand *rcommand = new RCommand (".rk.with.window.hints ({\n" + command + QStringLiteral ("}, \"\", ") + RObject::rQuote (preview_manager->previewId ()) + ')', RCommand::App);
+ QString command ("if (!nzchar(Sys.which(\"pandoc\"))) {\n"
+ " output <- rk.set.output.html.file(%2)\n"
+ " rk.header (" + RObject::rQuote (i18n ("Pandoc is not installed")) + ")\n"
+ " rk.print (" + RObject::rQuote (i18n ("The software <tt>pandoc</tt>, required ot rendering R markdown files, is not installed, or not in the system path of "
+ "the running R session. You will need to install pandoc from <a href=\"https://pandoc.org/\">https://pandoc.org/</a>.</br>"
+ "If is installed, but cannot be found, try adding it to the system path of the running R session at "
+ "<a href=\"rkward://settings/rbackend\">Settings->Configure RKward->R-backend</a>.")) + ")\n"
+ " rk.set.output.html.file(output)\n"
+ "} else {\n"
+ " require(rmarkdown)\n"
+ " rmarkdown::render (%1, output_format=\"html_document\", output_file=%2, quiet=TRUE)\n"
+ "}\n"
+ "rk.show.html(%2)\n");
+ command = command.arg (RObject::rQuote (save.fileName ()), RObject::rQuote (save.fileName () + ".html"));
+
+ RCommand *rcommand = new RCommand (".rk.with.window.hints (local ({\n" + command + QStringLiteral ("}), \"\", ") + RObject::rQuote (preview_manager->previewId ()) + ')', RCommand::App);
preview_manager->setCommand (rcommand);
preview->wrapperWidget ()->show ();
}
@@ -1372,3 +1382,4 @@ void RKCommandHighlighter::copyLinesToOutput (KTextEditor::View *view, Highlight
}
}
+
More information about the rkward-tracker
mailing list