diff --git a/DESCRIPTION b/DESCRIPTION index ec8de38..aaf020f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -18,17 +18,19 @@ Imports: jsonlite, lifecycle, magrittr, + markdown, + methods, mime, - rematch2 + rematch2, + stats Suggests: covr, + graphics, knitr, - methods, - sodium, rmarkdown, testthat VignetteBuilder: knitr Encoding: UTF-8 -RoxygenNote: 7.1.1 Roxygen: list(markdown = TRUE) +RoxygenNote: 7.1.1 diff --git a/NAMESPACE b/NAMESPACE index 3de3552..2c9170f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -82,6 +82,7 @@ export(gm_insert_message) export(gm_label) export(gm_labels) export(gm_last_response) +export(gm_markdown_body) export(gm_message) export(gm_messages) export(gm_mime) @@ -140,3 +141,4 @@ import(base64enc) import(httr) importFrom(lifecycle,deprecate_soft) importFrom(magrittr,"%>%") +importFrom(markdown,markdownToHTML) diff --git a/R/mime.R b/R/mime.R index 0d4a877..f348aab 100644 --- a/R/mime.R +++ b/R/mime.R @@ -126,6 +126,25 @@ gm_html_body <- function(mime, mime } +#' @rdname gm_mime +#' @importFrom markdown markdownToHTML +#' @export +gm_markdown_body <- function(mime, + body, + content_type = "text/html", + charset = "utf-8", + encoding = "base64", + ...) { + + gm_html_body( + body = markdownToHTML(text = body, fragment.only = TRUE), + content_type = content_type, + charset = charset, + encoding = encoding, + ... + ) +} + HTML_PART <- 2L #' @param part Message part to attach diff --git a/man/gm_auth.Rd b/man/gm_auth.Rd index 608badc..7964258 100644 --- a/man/gm_auth.Rd +++ b/man/gm_auth.Rd @@ -26,7 +26,7 @@ always determined from the token itself, never from this argument. Use \code{NA} or \code{FALSE} to match nothing and force the OAuth dance in the browser. Use \code{TRUE} to allow email auto-discovery, if exactly one matching token is found in the cache. Defaults to the option named "gargle_oauth_email", -retrieved by \code{\link[gargle:gargle_options]{gargle::gargle_oauth_email()}}.} +retrieved by \code{\link[gargle:gargle_oauth_email]{gargle::gargle_oauth_email()}}.} \item{path}{JSON identifying the service account, in one of the forms supported for the \code{txt} argument of \code{\link[jsonlite:fromJSON]{jsonlite::fromJSON()}} (typically, a @@ -40,11 +40,11 @@ permissions for each scope. and \code{gm_scopes()} to return a vector of the available scopes.} \item{cache}{Specifies the OAuth token cache. Defaults to the option named -"gargle_oauth_cache", retrieved via \code{\link[gargle:gargle_options]{gargle::gargle_oauth_cache()}}.} +"gargle_oauth_cache", retrieved via \code{\link[gargle:gargle_oauth_cache]{gargle::gargle_oauth_cache()}}.} \item{use_oob}{Whether to prefer "out of band" authentication. Defaults to the option named "gargle_oob_default", retrieved via -\code{\link[gargle:gargle_options]{gargle::gargle_oob_default()}}.} +\code{\link[gargle:gargle_oob_default]{gargle::gargle_oob_default()}}.} \item{token}{A token with class \link[httr:Token-class]{Token2.0} or an object of httr's class \code{request}, i.e. a token that has been prepared with diff --git a/man/gm_auth_configure.Rd b/man/gm_auth_configure.Rd index 087a0d3..4d1499f 100644 --- a/man/gm_auth_configure.Rd +++ b/man/gm_auth_configure.Rd @@ -35,7 +35,7 @@ used to make it easier to identify different applications.} \value{ \itemize{ \item \code{gm_auth_configure()}: An object of R6 class -\link[gargle:AuthState-class]{gargle::AuthState}, invisibly. +\link[gargle:AuthState]{gargle::AuthState}, invisibly. \item \code{gm_oauth_app()}: the current user-configured \code{\link[httr:oauth_app]{httr::oauth_app()}}. } diff --git a/man/gm_mime.Rd b/man/gm_mime.Rd index cdeac48..9a59cff 100644 --- a/man/gm_mime.Rd +++ b/man/gm_mime.Rd @@ -9,6 +9,7 @@ \alias{gm_subject.mime} \alias{gm_text_body} \alias{gm_html_body} +\alias{gm_markdown_body} \alias{gm_attach_part} \alias{gm_attach_file} \title{Create a mime formatted message object} @@ -44,6 +45,15 @@ gm_html_body( ... ) +gm_markdown_body( + mime, + body, + content_type = "text/html", + charset = "utf-8", + encoding = "base64", + ... +) + gm_attach_part(mime, part, id = NULL, ...) gm_attach_file(mime, filename, type = NULL, id = NULL, ...) diff --git a/man/gm_token.Rd b/man/gm_token.Rd index 6edaa46..75ddba5 100644 --- a/man/gm_token.Rd +++ b/man/gm_token.Rd @@ -7,7 +7,7 @@ gm_token() } \value{ -A \code{request} object (an S3 class provided by \link[httr:httr-package]{httr}). +A \code{request} object (an S3 class provided by \link[httr:httr]{httr}). } \description{ For internal use or for those programming around the Gmail API.