#' Add footnote
#'
#' @description Add footnote to your favorite kable output. So far this function
#' only works when you define \code{format} in your kable function or in the
#' global knitr option \code{knitr.table.format}. In latex, we are using the
#' \code{threeparttable} package so you need to import this package in your
#' \code{YAML} header.
#'
#' @param input The direct output of your \code{kable} function or your last
#' \code{kableExtra} function.
#' @param label A vector of footnotes you want to add. You don't need to add
#' notations in your notes.
#' @param notation You can select the format of your footnote notation from
#' "number", "alphabet" and "symbol".
#'
#' @export
add_footnote <- function(input, label = NULL, notation = "number",
                         threeparttable = FALSE) {
  if (is.null(label)){return(input)}

  # Define available id list
  if (!notation %in% c("number", "alphabet", "symbol")){
    warning('Please select your notation within "number", "alphabet" and ',
            '"symbol". Now add_footnote is using "alphabet" as default.')
  }
  if (notation == "symbol") {notation = paste0(notation, ".", attr(input, "format"))}
  ids.ops <- data.frame(
    number = as.character(1:20),
    alphabet = letters[1:20],
    symbol.latex = c(
      "*", "\\\\dag", "\\\\ddag", "\\\\S", "\\\\P",
      "**", "\\\\dag\\\\dag", "\\\\ddag\\\\ddag", "\\\\S\\\\S", "\\\\P\\\\P",
      "***", "\\\\dag\\\\dag\\\\dag", "\\\\ddag\\\\ddag\\\\ddag",
      "\\\\S\\\\S\\\\S", "\\\\P\\\\P\\\\P",
      "****", "\\\\dag\\\\dag\\\\dag\\\\dag", "\\\\ddag\\\\ddag\\\\ddag\\\\ddag",
      "\\\\S\\\\S\\\\S\\\\S", "\\\\P\\\\P\\\\P\\\\P"
    ),
    symbol.html = c(
      "*", "&dagger;", "&Dagger;", "&sect;", "&para;",
      "**", "&dagger;&dagger;", "&Dagger;&Dagger;", "&sect;&sect;", "&para;&para;",
      "***", "&dagger;&dagger;&dagger;", "&Dagger;&Dagger;&Dagger;",
      "&sect;&sect;&sect;", "&para;&para;&para;",
      "****", "&dagger;&dagger;&dagger;&dagger;", "&Dagger;&Dagger;&Dagger;&Dagger;",
      "&sect;&sect;&sect;&sect;", "&para;&para;&para;&para;"
    ),
    symbol.markdown = c(
      "\\*", "\u2020", "\u2021", "\u00A7", "\u00B6",
      "\\*\\*", "\u2020\u2020", "\u2021\u2021", "\u00A7\u00A7", "\u00B6\u00B6",
      "\\*\\*\\*", "\u2020\u2020\u2020", "\u2021\u2021\u2021",
      "\u00A7\u00A7\u00A7", "\u00B6\u00B6\u00B6",
      "\\*\\*\\*\\*", "\u2020\u2020\u2020\u2020", "\u2021\u2021\u2021\u2021",
      "\u00A7\u00A7\u00A7\u00A7", "\u00B6\u00B6\u00B6\u00B6"
    ),
    symbol.pandoc = c(
      "\\*", "\u2020", "\u2021", "\u00A7", "\u00B6",
      "\\*\\*", "\u2020\u2020", "\u2021\u2021", "\u00A7\u00A7", "\u00B6\u00B6",
      "\\*\\*\\*", "\u2020\u2020\u2020", "\u2021\u2021\u2021",
      "\u00A7\u00A7\u00A7", "\u00B6\u00B6\u00B6",
      "\\*\\*\\*\\*", "\u2020\u2020\u2020\u2020", "\u2021\u2021\u2021\u2021",
      "\u00A7\u00A7\u00A7\u00A7", "\u00B6\u00B6\u00B6\u00B6"
    )
  )
  ids <- ids.ops[,notation]
  # pandoc cannot recognize ^*^ as * is a special character. We have to use ^\*^
  ids.intable <- gsub("\\*", "\\\\*", ids)
  ids.simple <- c(
    "*", "\u2020", "\u2021", "\u00A7", "\u00B6",
    "**", "\u2020\u2020", "\u2021\u2021", "\u00A7\u00A7", "\u00B6\u00B6",
    "***", "\u2020\u2020\u2020", "\u2021\u2021\u2021",
    "\u00A7\u00A7\u00A7", "\u00B6\u00B6\u00B6",
    "****", "\u2020\u2020\u2020\u2020", "\u2021\u2021\u2021\u2021",
    "\u00A7\u00A7\u00A7\u00A7", "\u00B6\u00B6\u00B6\u00B6"
  )

  #count the number of items in label and intable notation
  count.label = length(label)
  count.intablenoot = sum(str_count(input, "\\[note\\]"))
  if (count.intablenoot != 0 & count.label != count.intablenoot){
    warning(paste("You entered", count.label, "labels but you put",
                  count.intablenoot, "[note] in your table."))
  }

  export <- input

  # Find out if there are any extra in-table notations needed to be corrected
  extra.notation <- unique(as.numeric(
    str_extract(
      str_extract_all(
        paste0(export, collapse = ""), "\\[note[0-9]{1,2}\\]"
      )[[1]],
      "[0-9]{1,2}")))



  # Footnote solution for markdown and pandoc. It is not perfect as
  # markdown doesn't support complex table formats but this solution
  # should be able to satisfy people who don't want to spend extra
  # time to define their `kable` output.
  if(!attr(input, "format") %in% c("html", "latex")){
    # In table notation
    if(count.intablenoot != 0){
      for(i in 1:count.intablenoot){
        export[which(str_detect(export, "\\[note\\]"))[1]] <-
          sub("\\[note\\]", paste0("^", ids.intable[i], "^",
            paste0(rep(" ", 4 - ceiling(i/5)),
              collapse = "")), export[which(str_detect(export, "\\[note\\]"))[1]])
      }
    }
    # Fix extra in table notation
    for(i in extra.notation){
      export <- gsub(paste0("\\[note", i, "\\]"),
                     paste0("^", ids.intable[i], "^",
                            paste0(rep(" ", 4 - ceiling(i/5)),
                            collapse = "")),
                     export)
    }

    export[length(export)+1] <- ""
    export[length(export)+1] <- "__Note:__"
    export[length(export)+1] <- paste0(
      paste0("^", ids[1:length(label)], "^ ", label), collapse = " "
      )
    }

  # Generate latex table footnote --------------------------------
  if(attr(input, "format")=="latex"){
    # Clean the entry for labels
      label <- knitr:::escape_latex(label)
      label <- gsub("\\\\", "\\\\\\\\", label)

    kable_info <- magic_mirror(input)
    if(kable_info$tabular == "longtable"){
      if(notation != "number"){
        warning("Currently, if you enabled longtable in kable, you can only use",
                " number as your footnote notations. ")
      }
      if(threeparttable == T){
        warning("Currently, threeparttable does not support longtable.")
      }
      # If longtable is used, then use page footnote instead of threeparttable
      # as it makes more sense to see the footnote at the bottom of page if
      # table is longer than one page.

      # Longtable doesn't support footnote in caption directly.
      # See http://tex.stackexchange.com/questions/50151/footnotes-in-longtable-captions
      count.in.caption.note <- str_count(kable_info$caption, "\\[note\\]")
      if (count.in.caption.note != 0){
        # Since caption is the first part of table, we can just start
        caption.footnote <- paste0("\\\\addtocounter{footnote}{-", count.in.caption.note, "}")
        for(i in 1:count.in.caption.note){
          export <- sub("\\[note\\]", "\\\\protect\\\\footnotemark ", export)
          caption.footnote <- paste0(
            caption.footnote, "\n\\\\stepcounter{footnote}\\\\footnotetext{", label[i], "}"
          )
        }

        if (str_detect(export, "\\\\toprule")){
          export <- sub("\\\\toprule",
                        paste0("\\\\toprule\n", caption.footnote), export)
        }else{
          export <- sub("\\\\hline",
                        paste0("\\\\hline\n", caption.footnote), export)
        }
      }
      for(i in (count.in.caption.note + 1):count.intablenoot){
        export <- sub("\\[note\\]",
                      paste0("\\\\footnote[", i, "]{", label[i], "}"), export)
      }
      for(i in extra.notation){
        export <- gsub(paste0("\\[note", i, "\\]"),
                       paste0("\\\\footnotemark[", i, "]"),
                       export)
      }
    }else{
      # Replace in-table notation with appropriate symbol
      for(i in 1:count.intablenoot){
        export <- sub("\\[note\\]", paste0("\\\\textsuperscript{", ids.intable[i], "}"), export)
      }

      # Fix extra in table notation
      for(i in extra.notation){
        export <- gsub(paste0("\\[note", i, "\\]"),
                       paste0("\\\\textsuperscript{", ids.intable[i], "}"),
                       export)
      }
      if(threeparttable == T){
        # generate footer with appropriate symbol
        footer <- ""
        for(i in 1:count.label){
          footer <- paste0(footer,"\\\\item [", ids[i], "] ", label[i], "\n")
        }

        if(grepl("\\\\caption\\{.*?\\}", export)){
          export <- sub("\\\\caption\\{", "\\\\begin{threeparttable}\n\\\\caption{", export)
        }else{
          export <- sub("\\\\begin\\{tabular\\}",
                        "\\\\begin{threeparttable}\n\\\\begin{tabular}", export)
        }
        export <- gsub(
          "\\\\end\\{tabular\\}",
          paste0(
            "\\\\end{tabular}\n\\\\begin{tablenotes}\n\\\\small\n",
            footer, "\\\\end{tablenotes}\n\\\\end{threeparttable}"
          ),
          export)
      }else{
          table.width <- max(nchar(
            str_replace_all(
              str_replace_all(kable_info$contents, "\\[note\\]", ""),
              "\\[note[0-9]{1,2}\\]", ""))) + 2 * (kable_info$ncol - 1)
          footer <- ""
          for (i in 1:count.label){
            label.wrap <- strwrap(label[i], table.width)
            footer <- paste0(footer, "\\\\multicolumn{", kable_info$ncol,
                             "}{l}{\\\\textsuperscript{", ids[i], "} ",
                             label.wrap[1], "}\\\\\\\\\n")
            if(length(label.wrap) > 1){
              for (j in 2:length(label.wrap)){
                footer <- paste0(footer, "\\\\multicolumn{", kable_info$ncol,
                                 "}{l}{", label.wrap[j], "}\\\\\\\\\n")
              }
            }
          }
          export <- gsub("\\\\end\\{tabular\\}",
                         paste0(footer, "\\\\end{tabular}"), export)
      }
    }
  }
  if(attr(input, "format")=="html"){
    # Clean the entry for labels
    label <- knitr:::escape_html(label)

    # Replace in-table notation with appropriate symbol
    for(i in 1:count.intablenoot){
      export <- sub("\\[note\\]", paste0("<sup>", ids.intable[i], "</sup>"), export)
    }

    # Fix extra in table notation
    for(i in extra.notation){
      export <- gsub(paste0("\\[note", i, "\\]"),
                     paste0("<sup>", ids.intable[i], "</sup>"),
                     export)
    }

    # Build footer
    footer <- "<tfoot>\n"
    for(i in 1:count.label){
      footer <- paste0(footer, "<tr>\n<td style = 'padding: 0; border:0;' ",
                       "colspan='100%'><sup>", ids[i],"</sup> ",
                       label[i], "</td>\n</tr>\n")
    }
    footer <- paste0(footer, "</tfoot>\n")

    # Paste footer to the table
    export[1] <- gsub("</tbody>\n", paste0("</tbody>\n", footer), export[1])
  }
  return(export)
}
