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 Просмотреть файл

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

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

# Generated by roxygen2: do not edit by hand # Generated by roxygen2: do not edit by hand


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

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

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

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

% 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.
}

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