Garrick Aden-Buie 6 лет назад
Родитель
Сommit
9a1ae298d1
4 измененных файлов: 45 добавлений и 6 удалений
  1. +5
    -6
      DESCRIPTION
  2. +1
    -0
      NAMESPACE
  3. +23
    -0
      R/ermoji_gadget.R
  4. +16
    -0
      man/emoji2html.Rd

+ 5
- 6
DESCRIPTION Просмотреть файл

@@ -1,23 +1,22 @@
Package: ermoji
Title: RStudio Addin to Search and Copy Emoji
Version: 0.1.3
Version: 0.1.4
Authors@R: "Garrrick Aden-Buie <garrick@adenbuie.com> [aut, cre]"
Description: RStudio addin to search through emoji and copy the
emoji name, unicode string or glyph to the clipboard.
License: MIT + file LICENSE
URL: https://github.com/gadenbuie/ermoji
BugReports: https://github.com/gadenbuie/ermoji/issues
Depends:
miniUI,
shiny
Imports:
clipr,
DT,
emo
emo,
miniUI,
shiny
Remotes:
hadley/emo
ByteCompile: true
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 6.1.0
RoxygenNote: 7.0.2

+ 1
- 0
NAMESPACE Просмотреть файл

@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(emoji2html)
export(ermoji_gadget)
export(ermoji_shiny)
import(miniUI)

+ 23
- 0
R/ermoji_gadget.R Просмотреть файл

@@ -193,6 +193,29 @@ escape_html <- function(x) {
x
}

#' Convert Emoji to HTML
#'
#' Uses [emo::ji()] to look up emoji, but return the escaped HTML.
#'
#' @param x A search term passed to [emo::ji()] or the result of [emo::ji()].
#' @param copy Should the result be copied to the clipboard?
#' @export
emoji2html <- function(x, copy = clipr::clipr_available()) {
emojis <- emo::jis$runes
names(emojis) <- emo::jis$emoji
if (!inherits(x, "emoji")) {
x <- emo::ji(x)
}
emoji <- emojis[x]
emoji_html <- rune2html(unname(emoji))
if (copy) {
clipr::write_clip(emoji_html)
message(emoji_html, " copied to clipboard")
return(invisible(emoji_html))
}
emoji_html
}

rune2html <- function(runes) {
gsub("([0-9A-F]{4,8}) ?", "&#x\\1;", runes)
}

+ 16
- 0
man/emoji2html.Rd Просмотреть файл

@@ -0,0 +1,16 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ermoji_gadget.R
\name{emoji2html}
\alias{emoji2html}
\title{Convert Emoji to HTML}
\usage{
emoji2html(x, copy = clipr::clipr_available())
}
\arguments{
\item{x}{A search term passed to \code{\link[emo:ji]{emo::ji()}} or the result of \code{\link[emo:ji]{emo::ji()}}.}

\item{copy}{Should the result be copied to the clipboard?}
}
\description{
Uses \code{\link[emo:ji]{emo::ji()}} to look up emoji, but return the escaped HTML.
}

Загрузка…
Отмена
Сохранить