Read rmarkdown format from metadata: rmd_format
diff --git a/DESCRIPTION b/DESCRIPTION
index 252622c..03f43bd 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -15,7 +15,8 @@
knitr (>= 1.10),
magrittr,
stringr (>= 1.0),
- XML
+ XML,
+ rmarkdown (>= 0.2.64)
Suggests:
testthat
RoxygenNote: 5.0.1
diff --git a/NAMESPACE b/NAMESPACE
index ace2ce4..582b8d5 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -3,6 +3,8 @@
export("%>%")
export(add_footnote)
export(magic_mirror)
+export(rmd_format)
import(stringr)
importFrom(XML,readHTMLTable)
importFrom(knitr,kable)
+importFrom(rmarkdown,metadata)
diff --git a/R/footnote.R b/R/footnote.R
index d849779..7b0c4ec 100644
--- a/R/footnote.R
+++ b/R/footnote.R
@@ -38,9 +38,9 @@
symbol.html = c(
"*", "†", "‡", "§", "¶",
"**", "††", "‡‡", "§§", "¶¶",
- "*", "†††", "‡‡‡",
+ "***", "†††", "‡‡‡",
"§§§", "¶¶¶",
- "**", "††††", "‡‡‡‡",
+ "****", "††††", "‡‡‡‡",
"§§§§", "¶¶¶¶"
),
symbol.markdown = c(
diff --git a/R/util.R b/R/util.R
new file mode 100644
index 0000000..9c29ddb
--- /dev/null
+++ b/R/util.R
@@ -0,0 +1,20 @@
+#' Rmarkdown Format
+#'
+#' @description If the export format of the Rmarkdown document exist,
+#'
+#' @importFrom rmarkdown metadata
+#'
+#' @export
+
+rmd_format <- function(){
+ rmd_output_metadata <- metadata$output
+ rmd_fmt <- ifelse(
+ is.null(rmd_output_metadata),
+ "markdown", ifelse(
+ rmd_output_metadata %in% c("html_document", "rmarkdown::html_vignette"),
+ "html",ifelse(
+ rmd_output_metadata %in% c("pdf_document", "rmarkdown::tufte_handout"),
+ "latex", "markdown"
+ )))
+ return(rmd_fmt)
+}
diff --git a/man/rmd_format.Rd b/man/rmd_format.Rd
new file mode 100644
index 0000000..f456093
--- /dev/null
+++ b/man/rmd_format.Rd
@@ -0,0 +1,12 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/util.R
+\name{rmd_format}
+\alias{rmd_format}
+\title{Rmarkdown Format}
+\usage{
+rmd_format()
+}
+\description{
+If the export format of the Rmarkdown document exist,
+}
+
diff --git a/tests/testthat/test-add_footnote.r b/tests/testthat/test-add_footnote.r
index 32783c9..fc33204 100644
--- a/tests/testthat/test-add_footnote.r
+++ b/tests/testthat/test-add_footnote.r
@@ -2,6 +2,7 @@
#####
rtable <- data.frame(variable = c("mpg", "wt"), mean = c(20.091, 3.217), sd = c(6.027, 0.978))
+mdtable <- kable(rtable)
htmltable_1 <- kable(rtable, format = "html")
htmltable_2 <- kable(rtable, format = "html", caption = "Table", table.attr = "class = 'table table-striped table-hover'")
htmltable_3 <- kable(rtable, row.names = T, format = "html", caption = "Table", table.attr = "class = 'table table-striped table-hover'")