Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hlaueriksson/GEmojiSharp
:octocat: GitHub Emoji for C#, ASP.NET Core and Blazor, dotnet tool for the terminal and PowerToys Run plugin
https://github.com/hlaueriksson/GEmojiSharp
asp-net-core blazor csharp dotnet dotnet-tool emoji gemoji github powertoys-run
Last synced: 10 days ago
JSON representation
:octocat: GitHub Emoji for C#, ASP.NET Core and Blazor, dotnet tool for the terminal and PowerToys Run plugin
- Host: GitHub
- URL: https://github.com/hlaueriksson/GEmojiSharp
- Owner: hlaueriksson
- License: mit
- Created: 2019-04-14T17:40:25.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-10T22:22:07.000Z (10 months ago)
- Last Synced: 2024-04-30T11:32:18.676Z (6 months ago)
- Topics: asp-net-core, blazor, csharp, dotnet, dotnet-tool, emoji, gemoji, github, powertoys-run
- Language: C#
- Homepage: https://hlaueriksson.github.io/GEmojiSharp/
- Size: 72.8 MB
- Stars: 96
- Watchers: 3
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-powertoys-run-plugins - GEmojiSharp - Find and copy GitHub emoji. (Plugins)
- awesome-blazor - GEmojiSharp.Blazor - ![last commit](https://img.shields.io/github/last-commit/hlaueriksson/GEmojiSharp?style=flat-square&cacheSeconds=86400) GitHub Emoji for Blazor ([Demo](https://hlaueriksson.github.io/GEmojiSharp/)). (Libraries & Extensions / 2D/3D Rendering engines)
README
# GEmojiSharp :octocat:
[![Build status](https://github.com/hlaueriksson/GEmojiSharp/workflows/build/badge.svg)](https://github.com/hlaueriksson/GEmojiSharp/actions?query=workflow%3Abuild)
[![CodeFactor](https://www.codefactor.io/repository/github/hlaueriksson/gemojisharp/badge)](https://www.codefactor.io/repository/github/hlaueriksson/gemojisharp)[![GEmojiSharp](https://img.shields.io/nuget/v/GEmojiSharp.svg?label=GEmojiSharp)](https://www.nuget.org/packages/GEmojiSharp)
[![GEmojiSharp.AspNetCore](https://img.shields.io/nuget/v/GEmojiSharp.AspNetCore.svg?label=GEmojiSharp.AspNetCore)](https://www.nuget.org/packages/GEmojiSharp.AspNetCore)
[![GEmojiSharp.Blazor](https://img.shields.io/nuget/v/GEmojiSharp.Blazor.svg?label=GEmojiSharp.Blazor)](https://www.nuget.org/packages/GEmojiSharp.Blazor)
[![GEmojiSharp.DotnetTool](https://img.shields.io/nuget/v/GEmojiSharp.DotnetTool.svg?label=GEmojiSharp.DotnetTool)](https://www.nuget.org/packages/GEmojiSharp.DotnetTool)> GitHub Emoji for C# and .NET:
>
> - `netstandard2.0`
> - ASP.NET Core
> - Blazor
> - `dotnet` tool
> - PowerToys Run plugin```txt
π :octopus:
β :heavy_plus_sign:
π :cat2:
β©΅
β€οΈ :heart:
```## Content
- [Introduction](#introduction)
- [`GEmojiSharp`](#gemojisharp)
- [`GEmojiSharp.AspNetCore`](#gemojisharpaspnetcore)
- [TagHelpers](#taghelpers)
- [HtmlHelpers](#htmlhelpers)
- [`GEmojiSharp.Blazor`](#gemojisharpblazor)
- [`GEmojiSharp.DotnetTool`](#gemojisharpdotnettool)
- [Installation](#installation)
- [Usage](#usage)
- [`GEmojiSharp.PowerToysRun`](#gemojisharppowertoysrun)
- [Installation](#installation-1)
- [Usage](#usage-1)
- [Configuration](#configuration)
- [Samples](#samples)
- [Attribution](#attribution)## Introduction
[Using emojis](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#using-emojis) on GitHub is accomplish with emoji aliases enclosed by colons:
`:+1: This PR looks great - it's ready to merge! :shipit:`
:+1: This PR looks great - it's ready to merge! :shipit:
`GEmojiSharp` make this possible in C#. The library contains a static array of all valid emoji in GitHub Flavored Markdown.
That is the intersection of the [emoji.json](https://raw.githubusercontent.com/github/gemoji/master/db/emoji.json) database and the API with [available emojis](https://api.github.com/emojis).A visual referense of all GitHub Emoji:
- https://github.com/hlaueriksson/github-emoji
## `GEmojiSharp`
[![NuGet](https://buildstats.info/nuget/GEmojiSharp)](https://www.nuget.org/packages/GEmojiSharp/)
> GitHub Emoji for C# and .NET π¦
Static methods:
```csharp
Emoji.Get(":tada:").Raw; // π
Emoji.Get("π").Alias(); // :tada:
Emoji.Raw(":tada:"); // π
Emoji.Alias("π"); // :tada:
Emoji.Emojify(":tada: initial commit"); // π initial commit
Emoji.Demojify("π initial commit"); // :tada: initial commit
Emoji.Find("party popper").First().Raw; // π
Emoji.Get("βοΈ").RawSkinToneVariants(); // βπ», βπΌ, βπ½, βπΎ, βπΏ
```Extension methods:
```csharp
":tada:".GetEmoji().Raw; // π
"π".GetEmoji().Alias(); // :tada:
":tada:".RawEmoji(); // π
"π".EmojiAlias(); // :tada:
":tada: initial commit".Emojify(); // π initial commit
"π initial commit".Demojify(); // :tada: initial commit
"party popper".FindEmojis().First().Raw; // π
```Regular expression pattern to match all emojis:
```csharp
var text = "Lorem ππ ipsum";var matches = Regex.Matches(text, Emoji.RegexPattern);
string.Join(string.Empty, matches.Select(x => x.Value)); // ππRegex.Replace(text, Emoji.RegexPattern, string.Empty); // Lorem ipsum
```## `GEmojiSharp.AspNetCore`
[![NuGet](https://buildstats.info/nuget/GEmojiSharp.AspNetCore)](https://www.nuget.org/packages/GEmojiSharp.AspNetCore/)
> GitHub Emoji for ASP.NET Core π¦
The package includes:
- TagHelpers
- HtmlHelpers### TagHelpers
Update the `_ViewImports.cshtml` file, to enable tag helpers in all Razor views:
```cshtml
@addTagHelper *, GEmojiSharp.AspNetCore
```Use the `` tag or `emoji` attribute to render emojis:
```html
:tada: initial commit
```Standard emoji characters are rendered like this:
```html
π
```Custom GitHub emojis are rendered as images:
```html
```Use CSS to properly position the custom GitHub emojis images:
```css
.emoji {
background-color: transparent;
max-width: none;
vertical-align: text-top;
}
```Use the JavaScript from [`g-emoji-element`](https://github.com/github/g-emoji-element) to support old browsers.
> Backports native emoji characters to browsers that don't support them by replacing the characters with fallback images.
Add a [`libman.json`](https://docs.microsoft.com/en-us/aspnet/core/client-side/libman/libman-vs?view=aspnetcore-6.0) file:
```json
{
"version": "1.0",
"defaultProvider": "cdnjs",
"libraries": [
{
"provider": "unpkg",
"library": "@github/[email protected]",
"destination": "wwwroot/lib/g-emoji-element/"
}
]
}
```And add the script to the `_Layout.cshtml` file:
```html
```
Do you want to use emoji anywhere, on any tag, in the `body`? Then you can use the `BodyTagHelperComponent`.
Use any tag to render emojis:
```html
Hello, :earth_africa:
```[Registration](https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/th-components?view=aspnetcore-6.0#registration-via-services-container) via services container:
```cs
using GEmojiSharp.AspNetCore;
using Microsoft.AspNetCore.Razor.TagHelpers;var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages();
builder.Services.AddTransient();
```[Registration](https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/th-components?view=aspnetcore-6.0#registration-via-razor-file) via Razor file:
```cshtml
@page
@model GEmojiSharp.Sample.Web.Pages.ComponentModel
@using Microsoft.AspNetCore.Mvc.Razor.TagHelpers
@using GEmojiSharp.AspNetCore
@inject ITagHelperComponentManager manager;
@{
ViewData["Title"] = "Component";
manager.Components.Add(new BodyTagHelperComponent());
}
```[Registration](https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/th-components?view=aspnetcore-6.0#registration-via-page-model-or-controller) via Page Model or controller:
```cs
using GEmojiSharp.AspNetCore;
using Microsoft.AspNetCore.Mvc.Razor.TagHelpers;
using Microsoft.AspNetCore.Mvc.RazorPages;namespace GEmojiSharp.Sample.Web.Pages
{
public class ComponentModel : PageModel
{
private readonly ITagHelperComponentManager _tagHelperComponentManager;public IndexModel(ITagHelperComponentManager tagHelperComponentManager)
{
_tagHelperComponentManager = tagHelperComponentManager;
}public void OnGet()
{
_tagHelperComponentManager.Components.Add(new BodyTagHelperComponent());
}
}
}
```### HtmlHelpers
Update the `_ViewImports.cshtml` file, to enable HTML helpers in all Razor views:
```cshtml
@using GEmojiSharp.AspNetCore
```Use the `Emoji` extension methods to render emojis:
```cshtml
@Html.Emoji(":tada: initial commit")
@Html.Emoji(x => x.Text)
```## `GEmojiSharp.Blazor`
[![NuGet](https://buildstats.info/nuget/GEmojiSharp.Blazor)](https://www.nuget.org/packages/GEmojiSharp.Blazor/)
> GitHub Emoji for Blazor π¦
The package is a Razor class library (RCL) with a Razor component.
Update the `_Imports.razor` file, to enable the component in all Razor views:
```cshtml
@using GEmojiSharp.Blazor
```> [!NOTE]
> In a Blazor Web App (.NET 8 or later), the component requires an interactive render mode applied either globally to the app or to the component definition.Set the global render mode in `App.razor`:
```cshtml
```
or per page/component:
```cshtml
@rendermode InteractiveServer
```Use the `` component to render emojis:
```html
:tada: initial commit
```Standard emoji characters are rendered like this:
```html
π
```Custom GitHub emojis are rendered as images:
```html
```## `GEmojiSharp.DotnetTool`
[![NuGet](https://buildstats.info/nuget/GEmojiSharp.DotnetTool)](https://www.nuget.org/packages/GEmojiSharp.DotnetTool/)
> GitHub Emoji `dotnet` tool π§°
![GEmojiSharp.DotnetTool](GEmojiSharp.DotnetTool.gif)
### Installation
Install:
```cmd
dotnet tool install -g GEmojiSharp.DotnetTool
```Update:
```cmd
dotnet tool update -g GEmojiSharp.DotnetTool
```Uninstall:
```cmd
dotnet tool uninstall -g GEmojiSharp.DotnetTool
```Enable emoji in the terminal:
- Open Settings / Time & Language / Language / Administrative Language Settings / Change system locale...
- Check "Beta: Use Unicode UTF-8 for worldwide language support" and click OK
- Reboot the PC for the change to take effect![Beta: Use Unicode UTF-8 for worldwide language support](Unicode.png)
- [Set a process code page to UTF-8](https://learn.microsoft.com/en-us/windows/apps/design/globalizing/use-utf8-code-page#set-a-process-code-page-to-utf-8)
### Usage
```cmd
emoji --help
``````cmd
Description:
GitHub Emoji dotnet toolUsage:
emoji [command] [options]Options:
--version Show version information
-?, -h, --help Show help and usage informationCommands:
r, raw Get raw emojis
a, alias Get emoji aliases
e, emojify Replace aliases in text with raw emojis
d, demojify Replace raw emojis in text with aliases
export Export emoji data to
```#### Raw
```cmd
emoji raw --help
``````cmd
Description:
Get raw emojisUsage:
emoji raw [...] [options]Arguments:
Find emojis via description, category, alias or tagOptions:
-st, --skin-tones Include skin tone variants
-c, --copy Copy to clipboard
-?, -h, --help Show help and usage information
```Examples π
Get raw emojis:
```cmd
emoji raw "grinning cat"
emoji raw grinning cat
emoji r grinning cat
``````cmd
πΊ
πΈ
```Copy to clipboard:
```cmd
emoji raw "grinning cat" --copy
emoji r grinning cat -c
``````txt
πΊπΈ
```Skin tone variants:
```cmd
emoji raw "victory" --skin-tones
emoji r victory -st
``````txt
βοΈ
βπ»
βπΌ
βπ½
βπΎ
βπΏ
```#### Alias
```cmd
emoji alias --help
``````cmd
Description:
Get emoji aliasesUsage:
emoji alias [...] [options]Arguments:
Find emojis via description, category, alias or tagOptions:
-c, --copy Copy to clipboard
-?, -h, --help Show help and usage information
```Examples π
Get emoji aliases:
```cmd
emoji alias "grinning cat"
emoji alias grinning cat
emoji a grinning cat
``````cmd
:smiley_cat:
:smile_cat:
```Copy to clipboard:
```cmd
emoji alias "grinning cat" --copy
emoji a grinning cat -c
``````txt
:smiley_cat::smile_cat:
```#### Emojify
```cmd
emoji emojify --help
``````cmd
Description:
Replace aliases in text with raw emojisUsage:
emoji emojify [...] [options]Arguments:
A text with emoji aliasesOptions:
-c, --copy Copy to clipboard
-?, -h, --help Show help and usage information
```Examples π
Replace aliases in text with raw emojis:
```cmd
emoji emojify ":tada: initial commit"
emoji emojify :tada: initial commit
emoji e :tada: initial commit
``````cmd
π initial commit
```Copy to clipboard:
```cmd
emoji emojify ":tada: initial commit" --copy
emoji e :tada: initial commit -c
```#### Demojify
```cmd
emoji demojify --help
``````cmd
Description:
Replace raw emojis in text with aliasesUsage:
emoji demojify [...] [options]Arguments:
A text with raw emojisOptions:
-c, --copy Copy to clipboard
-?, -h, --help Show help and usage information
```Examples π
Replace raw emojis in text with aliases:
```cmd
emoji demojify "π initial commit"
emoji demojify π initial commit
emoji d π initial commit
``````cmd
:tada: initial commit
```Copy to clipboard:
```cmd
emoji demojify "π initial commit" --copy
emoji d π initial commit -c
```#### Export
```cmd
emoji export --help
``````cmd
Description:
Export emoji data toUsage:
emoji export [...] [options]Arguments:
Find emojis via description, category, alias or tagOptions:
-f, --format Format the data as
-c, --copy Copy to clipboard
-?, -h, --help Show help and usage information
```Formats:
- `json`
- `toml`
- `xml`
- `yaml`Examples π
Export emoji data to `json`:
```cmd
emoji export "grinning cat" --format json
emoji export grinning cat --format json
emoji export grinning cat -f json
emoji export grinning cat
``````json
[
{
"Raw": "πΊ",
"Description": "grinning cat",
"Category": "Smileys & Emotion",
"Aliases": [
"smiley_cat"
],
"Tags": null,
"UnicodeVersion": "6.0",
"IosVersion": "6.0",
"Filename": "1f63a",
"IsCustom": false
},
{
"Raw": "πΈ",
"Description": "grinning cat with smiling eyes",
"Category": "Smileys & Emotion",
"Aliases": [
"smile_cat"
],
"Tags": null,
"UnicodeVersion": "6.0",
"IosVersion": "6.0",
"Filename": "1f638",
"IsCustom": false
}
]
```Copy to clipboard:
```cmd
emoji export "grinning cat" --format json --copy
emoji export "grinning cat" -c
```## `GEmojiSharp.PowerToysRun`
[![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/hlaueriksson/GEmojiSharp/total)](https://github.com/hlaueriksson/GEmojiSharp/releases/latest)
[![Mentioned in Awesome PowerToys Run Plugins](https://awesome.re/mentioned-badge.svg)](https://github.com/hlaueriksson/awesome-powertoys-run-plugins)> GitHub Emoji [PowerToys Run](https://docs.microsoft.com/en-us/windows/powertoys/run) plugin ποΈππ
![GEmojiSharp.PowerToysRun](GEmojiSharp.PowerToysRun.gif)
### Installation
The plugin is developed and tested with `PowerToys` `v0.83.0`.
Install:
0. [Install PowerToys](https://docs.microsoft.com/en-us/windows/powertoys/install)
1. Exit PowerToys
2. Download the `.zip` file from the latest [release](https://github.com/hlaueriksson/GEmojiSharp/releases/latest) and extract it to:
- `%LocalAppData%\Microsoft\PowerToys\PowerToys Run\Plugins`
3. Start PowerToys![GEmojiSharp.PowerToysRun](GEmojiSharp.PowerToysRun.png)
### Usage
1. Open PowerToys Run with `alt + space`
2. Type `emoji`
- A list of all emojis will be displayed
3. Continue to type to find emojis via description, category, alias or tag
4. Use β¬οΈ and β¬οΈ keys to select an emoji
5. Press `Enter` to copy the selected raw emoji to clipboard
6. Press `ctrl + c` to copy the selected emoji aliases to clipboard
7. Press `ctrl + Enter` to copy the selected raw emoji skin tone variants to clipboard
- For emoji that supports skin tone modifiersEmojify:
- You can paste a text containing emoji aliases to replace them with raw emojis
Demojify:
- You can paste a text containing raw emojis to replace them with aliases
### Configuration
Change action keyword:
1. Open PowerToys
2. Select PowerToys Run
3. Scroll down to Plugins
4. Expand `GEmojiSharp`
5. Change *Direct activation command*![GEmojiSharp.PowerToysRun](GEmojiSharp.PowerToysRun-Configuration.png)
## Samples
The [`samples`](/samples) folder contains...
- `GEmojiSharp.Sample.BlazorWeb`, a Blazor Web App (InteractiveServer render mode)
- `GEmojiSharp.Sample.BlazorWebAssembly`, a Blazor WebAssembly App
- `GEmojiSharp.Sample.Web`, a ASP.NET Core Web App (Razor Pages)The Blazor WebAssembly app is showcased here:
- https://hlaueriksson.github.io/GEmojiSharp/ (GitHub Pages)
- https://purple-mushroom-05c6bad10.azurestaticapps.net (Azure Static Web Apps)[![GEmojiSharp.Sample.BlazorWebAssembly](GEmojiSharp.Sample.BlazorWebAssembly.png)](https://hlaueriksson.github.io/GEmojiSharp/)
## Attribution
Repositories consulted when building this:
- https://github.com/github/gemoji
- https://github.com/github/g-emoji-element
- https://github.com/dotnet/command-line-api
- https://github.com/microsoft/PowerToys