#' Build an image in markdown
#'
#' This function helps users to paste image in markdown
#'
#' @return Character.
#' @author Jiaxiang Li
#'
#' @import rstudioapi
#' @importFrom stringr str_split
#' @importFrom glue glue
m2 <- function(){
line <-
# clipr::read_clip() %>%
rstudioapi::getSourceEditorContext() %>%
rstudioapi::primary_selection() %>%
.[["text"]] %>%
# 省略复制的步骤,参考reprex
stringr::str_split(n=2,pattern=' ') %>%
.[[1]]
url <- line[1]
name <- line[2]
name <- ifelse(is.na(name),'',name)
text <- glue::glue('')
# clipr::write_clip(text)
rstudioapi::insertText(text)
# avoid paste
cat(
sep="\n"
,text
,tips()
,'m2 is depreciated and added in m1, use m1!'
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.