add escape to footnote; add function documentation
diff --git a/R/footnote.R b/R/footnote.R
index 9999be7..8863327 100644
--- a/R/footnote.R
+++ b/R/footnote.R
@@ -1,5 +1,31 @@
 #' Add footnote (new)
 #'
+#' @description `footnote` provides a more flexible way to add footnote. You
+#' can add mutiple sets of footnote using differeny notation system. It is
+#' also possible to specify footnote section header one by one and print
+#' footnotes as a chunk of texts.
+#'
+#' @param kable_input HTML or LaTeX table generated by `knitr::kable`
+#' @param general Text for general footnote comments. Footnotes in this section
+#' won't be labeled with any notations
+#' @param number A vector of footnote texts. Footnotes here will be numbered.
+#' There is no upper cap for the number of footnotes here
+#' @param alphabet A vector of footnote texts, Footnotes here will be labeled
+#' with abc. The vector here should not have more than 26 elements.
+#' @param symbol A vector of footnote texts, Footnotes here will be labeled
+#' with special symbols. The vector here should not have more than 20 elements.
+#' @param footnote_order The order of how to arrange `general`, `number`,
+#' `alphabet` and `symbol`.
+#' @param footnote_as_chunk T/F value. Default is FALSE. It controls whether
+#' the footnotes should be printed in a chunk (without line break).
+#' @param escape T/F value. It controls whether the contents and titles should
+#' be escaped against HTML or LaTeX. Default is TRUE.
+#' @param general_title Section header for general footnotes. Default is
+#' "Note: ".
+#' @param number_title Section header for number footnotes. Default is "".
+#' @param alphabet_title Section header for alphabet footnotes. Default is "".
+#' @param symbol_title Section header for symbol footnotes. Default is "".
+#'
 #' @export
 footnote <- function(kable_input,
                      general = NULL,
@@ -9,6 +35,7 @@
                      footnote_order = c("general", "number",
                                         "alphabet", "symbol"),
                      footnote_as_chunk = FALSE,
+                     escape = TRUE,
                      general_title = "Note: ",
                      number_title = "",
                      alphabet_title = "",
@@ -19,15 +46,6 @@
     message("Currently generic markdown table using pandoc is not supported.")
     return(kable_input)
   }
-  footnote_titles <- list(
-    general = general_title, number = number_title,
-    alphabet = alphabet_title, symbol = symbol_title
-  )
-  footnote_contents <- list(
-    general = general, number = number, alphabet = alphabet, symbol = symbol
-  )
-  notnull <- names(footnote_contents)[!sapply(footnote_contents, is.null)]
-  if (length(notnull) == 0) {return(kable_input)}
   if (length(alphabet) > 26) {
     alphabet <- alphabet[1:26]
     warning("Please don't use more than 26 footnotes in table_footnote ",
@@ -38,9 +56,28 @@
     warning("Please don't use more than 20 footnotes in table_footnote ",
             "symbol. Use number instead.")
   }
+  footnote_titles <- list(
+    general = general_title, number = number_title,
+    alphabet = alphabet_title, symbol = symbol_title
+  )
+  footnote_contents <- list(
+    general = general, number = number, alphabet = alphabet, symbol = symbol
+  )
+  notnull <- names(footnote_contents)[!sapply(footnote_contents, is.null)]
+  if (length(notnull) == 0) {return(kable_input)}
   footnote_order <- footnote_order[footnote_order %in% notnull]
   footnote_titles <- footnote_titles[footnote_order]
   footnote_contents <- footnote_contents[footnote_order]
+  footnote_contents <- lapply(footnote_contents, esca)
+  if (escape) {
+    if (kable_format == "html") {
+      footnote_contents <- lapply(footnote_contents, escape_html)
+      footnote_titles <- lapply(footnote_titles, escape_html)
+    } else {
+      footnote_contents <- lapply(footnote_contents, escape_latex)
+      footnote_titles <- lapply(footnote_titles, escape_latex)
+    }
+  }
   footnote_table <- footnote_table_maker(
     kable_format, footnote_titles, footnote_contents
   )
diff --git a/R/footnote_marker.R b/R/footnote_marker.R
index 45ffafb..df54339 100644
--- a/R/footnote_marker.R
+++ b/R/footnote_marker.R
@@ -1,4 +1,16 @@
 #' Footnote marker
+#'
+#' @description Put footnote mark in superscription in table. Unless you are
+#' using it in the `caption` of `kable`, you will need to put `escape = F`
+#' in `kable` (similar with `cell_spec`). Again, similar with `cell_spec`, the
+#' `format` option here can read default value from global option
+#' `knitr.table.format`.
+#'
+#' @param x a number. For example, for `footnote_marker_alphabet(2)` will
+#' return "b" in HTML.
+#' @param format Either `html` or `latex`. All functions here can read
+#' default value from global option `knitr.table.format`.
+#'
 #' @export
 footnote_marker_number <- function(x, format) {
   if (missing(format) || is.null(format)) {
@@ -15,6 +27,7 @@
   }
 }
 
+#' @rdname footnote_marker_number
 #' @export
 footnote_marker_alphabet <- function(x, format) {
   if (missing(format) || is.null(format)) {
@@ -32,6 +45,7 @@
   }
 }
 
+#' @rdname footnote_marker_number
 #' @export
 footnote_marker_symbol <- function(x, format) {
   if (missing(format) || is.null(format)) {
diff --git a/man/footnote.Rd b/man/footnote.Rd
index 1dddc7d..b2cc29c 100644
--- a/man/footnote.Rd
+++ b/man/footnote.Rd
@@ -6,9 +6,46 @@
 \usage{
 footnote(kable_input, general = NULL, number = NULL, alphabet = NULL,
   symbol = NULL, footnote_order = c("general", "number", "alphabet",
-  "symbol"), footnote_as_chunk = FALSE, general_title = "Note: ",
-  number_title = "", alphabet_title = "", symbol_title = "")
+  "symbol"), footnote_as_chunk = FALSE, escape = TRUE,
+  general_title = "Note: ", number_title = "", alphabet_title = "",
+  symbol_title = "")
+}
+\arguments{
+\item{kable_input}{HTML or LaTeX table generated by \code{knitr::kable}}
+
+\item{general}{Text for general footnote comments. Footnotes in this section
+won't be labeled with any notations}
+
+\item{number}{A vector of footnote texts. Footnotes here will be numbered.
+There is no upper cap for the number of footnotes here}
+
+\item{alphabet}{A vector of footnote texts, Footnotes here will be labeled
+with abc. The vector here should not have more than 26 elements.}
+
+\item{symbol}{A vector of footnote texts, Footnotes here will be labeled
+with special symbols. The vector here should not have more than 20 elements.}
+
+\item{footnote_order}{The order of how to arrange \code{general}, \code{number},
+\code{alphabet} and \code{symbol}.}
+
+\item{footnote_as_chunk}{T/F value. Default is FALSE. It controls whether
+the footnotes should be printed in a chunk (without line break).}
+
+\item{escape}{T/F value. It controls whether the contents and titles should
+be escaped against HTML or LaTeX. Default is TRUE.}
+
+\item{general_title}{Section header for general footnotes. Default is
+"Note: ".}
+
+\item{number_title}{Section header for number footnotes. Default is "".}
+
+\item{alphabet_title}{Section header for alphabet footnotes. Default is "".}
+
+\item{symbol_title}{Section header for symbol footnotes. Default is "".}
 }
 \description{
-Add footnote (new)
+\code{footnote} provides a more flexible way to add footnote. You
+can add mutiple sets of footnote using differeny notation system. It is
+also possible to specify footnote section header one by one and print
+footnotes as a chunk of texts.
 }
diff --git a/man/footnote_marker_number.Rd b/man/footnote_marker_number.Rd
index cfa0c16..c16664c 100644
--- a/man/footnote_marker_number.Rd
+++ b/man/footnote_marker_number.Rd
@@ -2,10 +2,27 @@
 % Please edit documentation in R/footnote_marker.R
 \name{footnote_marker_number}
 \alias{footnote_marker_number}
+\alias{footnote_marker_alphabet}
+\alias{footnote_marker_symbol}
 \title{Footnote marker}
 \usage{
 footnote_marker_number(x, format)
+
+footnote_marker_alphabet(x, format)
+
+footnote_marker_symbol(x, format)
+}
+\arguments{
+\item{x}{a number. For example, for \code{footnote_marker_alphabet(2)} will
+return "b" in HTML.}
+
+\item{format}{Either \code{html} or \code{latex}. All functions here can read
+default value from global option \code{knitr.table.format}.}
 }
 \description{
-Footnote marker
+Put footnote mark in superscription in table. Unless you are
+using it in the \code{caption} of \code{kable}, you will need to put \code{escape = F}
+in \code{kable} (similar with \code{cell_spec}). Again, similar with \code{cell_spec}, the
+\code{format} option here can read default value from global option
+\code{knitr.table.format}.
 }