[education/rkward/snippets] rkward: YAML transfered to RKWardRMd.xml
Stefan Rödiger
null at kde.org
Sun Jun 19 13:06:41 BST 2022
Git commit 209f7cab3dd6535620409544cc1946981e0deaf7 by Stefan Rödiger.
Committed on 19/06/2022 at 12:05.
Pushed by srodiger into branch 'snippets'.
YAML transfered to RKWardRMd.xml
M +25 -0 rkward/RKWardRMd.xml
D +0 -53 rkward/RKWardYAML.xml
https://invent.kde.org/education/rkward/commit/209f7cab3dd6535620409544cc1946981e0deaf7
diff --git a/rkward/RKWardRMd.xml b/rkward/RKWardRMd.xml
index 4e50221e..e58b3f9a 100644
--- a/rkward/RKWardRMd.xml
+++ b/rkward/RKWardRMd.xml
@@ -146,4 +146,29 @@ knitr::kable(data, caption = "Table caption text.")
```
</fillin>
</item>
+ <item>
+ <match>YAML header</match>
+ <fillin>
+---
+title: "Document title"
+author: "Author Name"
+date: "`r Sys.Date()`"
+output:
+ html_document:
+ fig_caption: yes
+ highlight: kate
+ number_sections: yes
+ toc: yes
+---
+
+```{r, echo=TRUE}
+# Defaults to suppress warnings and messages
+# Figure height and width are set to 7 inches
+knitr::opts_chunk$set(
+ echo = FALSE, warnings = FALSE, message = FALSE,
+ fig.width = 7, fig.height = 7
+)
+```
+ </fillin>
+ </item>
</snippets>
diff --git a/rkward/RKWardYAML.xml b/rkward/RKWardYAML.xml
deleted file mode 100644
index 76ac95ef..00000000
--- a/rkward/RKWardYAML.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-<snippets name="YAML R Markdown (RKWard)" filetypes="R Markdown" authors="RKWard Team" namespace="SnippetsYAML" license="BSD">
- <script>require("range.js")
-require("cursor.js")
-require("document.js")
-require("view.js")
-
-function fileName() { return document.fileName(); }
-function encoding() { return document.encoding(); }
-function year() { return new Date().getFullYear(); }
-function upper(x) { return x.toUpperCase(); }
-function lower(x) { return x.toLowerCase(); }
-function braces(text) { return "{" + text + "}"; }
-function lineCommand(command, replaces="", label_if_empty="Heading") {
- let c = view.cursorPosition();
- // NOTE: snippet scripts work by 1. inserting the raw snippet as a raw "template" 2. evaluating any commands inside the template 3. replacing the template with the evaluated template. As a result, when this function gets called, it contains the call to itself...
- let line = document.line(c.line).replace(/\$\{lineCommand\s*\([^\}]*\}/g, "");
- line = line.replace(new RegExp(replaces), "");
- if (line == "") line = label_if_empty;
- else document.removeLine(c.line);
- return command + " " + line + "\n";
-}
-
-function rangeCommand(command, def) {
- if (view.selectedText().length > 0) {
- return command.replace("%%1", view.selectedText());
- } else {
- return command.replace("%%1", def);
- }
-}
-</script>
- <item>
- <match>YAML header</match>
- <fillin>
----
-title: "Document title"
-author: "Author Name"
-date: "`r Sys.Date()`"
-output:
- html_document:
- fig_caption: yes
- highlight: kate
- number_sections: yes
- toc: yes
----
- </fillin>
- </item>
- <item>
- <match>YAML header</match>
- <fillin>
-
- </fillin>
- </item>
-</snippets>
More information about the rkward-tracker
mailing list