Compare commits

...

4 Commits

Author SHA1 Message Date
github-actions[bot] 1ba0b3f791 Auto Update by GitHub Actions
3 years ago
nxu 25913f4e85 Version 1.0.3b
3 years ago
github-actions[bot] aef59814b1 Auto Update by GitHub Actions
3 years ago
nxu d3c4b67557 Version 1.0.3
3 years ago

@ -5,6 +5,7 @@ on:
- main
paths-ignore:
- 'README.md'
- 'github-emoji.json'
pull_request:
branches:
- main
@ -34,6 +35,6 @@ jobs:
run: |
git config --global user.name "${{ env.AUTO_COMMIT_AUTHOR }}"
git config --global user.email "${{ env.AUTO_COMMIT_EMAIL }}"
git add README.md
git add README.md github-emoji.json
git commit -m "${{ env.AUTO_COMMIT_MESSAGE }}"
git push

@ -1,12 +1,16 @@
# GitHub Emoji Icon List
This list includes all the usable Emoji icon shortcodes in GitHub Markdown. The list is automatically generated from [GitHub Emoji API](https://api.github.com/emojis) with the information from [Unicode Emoji data file](https://unicode.org/Public/emoji/15.0/emoji-test.txt).
This list includes all the usable Emoji icon shortcodes in GitHub Markdown. The list is automatically generated from [:octocat: GitHub Emoji API](https://api.github.com/emojis) with the information from [Unicode Emoji data file](https://unicode.org/Public/emoji/15.0/emoji-test.txt).
The first column is the emoji icon, second column is the shortcode for Markdown, third column is the name of the emoji from the Unicode data.
> :information_source: *The emoji may be displayed in different result on various system or browser*
*The emoji may be displayed in different result on various system*
:bar_chart: Number of GitHub Emoji Icon: :one::eight::seven::four:
![Auto Update by GitHub Actions](https://github.com/jasonfoknxu/github-emoji-icon-list/actions/workflows/auto-update.yml/badge.svg)
[:floppy_disk: JSON version](https://github.com/jasonfoknxu/github-emoji-icon-list/blob/main/github-emoji.json) is available. Feel free to use it for further development.
[![Auto Update by GitHub Actions](https://github.com/jasonfoknxu/github-emoji-icon-list/actions/workflows/auto-update.yml/badge.svg)](https://github.com/jasonfoknxu/github-emoji-icon-list/actions/workflows/auto-update.yml) :robot: Auto update by GitHub Actions every week.
:red_circle: :orange_circle: :yellow_circle: :green_circle: :large_blue_circle: :purple_circle: :brown_circle: :black_circle: :white_circle: :red_square: :orange_square: :yellow_square: :green_square: :blue_square: :purple_square: :brown_square: :black_large_square: :white_large_square:
## Table of Contents
@ -2748,7 +2752,7 @@ The first column is the emoji icon, second column is the shortcode for Markdown,
[:top: Back to Top](#github-emoji-icon-list)
### GitHub Custom Emoji
## GitHub Custom Emoji
|Emoji|Shortcode|
|:---:|:-----:|

@ -1,3 +1,13 @@
# Changelog
### Version 1.0.3b
- Quick fix minor bug
### Version 1.0.3
- Add GitHub emoji counter
- Add original Unicode
- Add JSON version
### Version 1.0.2
- Add GitHub Actions badge
- Fix minor visual bug of the markdown

File diff suppressed because one or more lines are too long

@ -1,6 +1,6 @@
{
"name": "github-emoji-icon-list",
"version": "1.0.2",
"version": "1.0.3b",
"description": "Generate GitHub Emoji Icon list in Markdown format.",
"homepage": "https://github.com/jasonfoknxu/github-emoji-icon-list",
"author": "jasonfoknxu <nxu@nxu.biz> (https://nxuweb.net)",

@ -1,6 +1,6 @@
/**
* GitHub Emoji Icon Markdown Generator
* - Version: 1.0.2
* GitHub Emoji Icon List Markdown Generator
* - Version: 1.0.3b
* - Developer: NXU (GitHub: @jasonfoknxu)
* - https://github.com/jasonfoknxu/github-emoji-icon-list
*/
@ -21,10 +21,14 @@ import * as Utils from './utilities';
process.exit(1);
}
// Count number of GitHub emoji
let numberOfEmoji = 0;
// Handle the GitHub emoji from the GitHub Emoji Icon List
let githubEmojis: IGithubEmoji = {};
for (const [shortcode, url] of Object.entries(githubEmojisData)) {
githubEmojis[shortcode] = Utils.base(url).toUpperCase();
numberOfEmoji++;
}
// Process the Unicode emoji data from the Unicode Emoji Data text
@ -46,7 +50,8 @@ import * as Utils from './utilities';
name: parseResult.name,
group: group ?? '',
subgroup: subgroup ?? '',
order: emojiCount++
order: emojiCount++,
origUnicode: parseResult.original
};
}
}
@ -65,10 +70,10 @@ import * as Utils from './utilities';
if (!emojis[emojiData.group][emojiData.subgroup]) {
emojis[emojiData.group][emojiData.subgroup] = [];
}
const emojiToAdd = {unicode: unicode, shortcode: shortcode, name: emojiData.name, order: emojiData.order};
const emojiToAdd = {unicode: unicode, shortcode: shortcode, name: emojiData.name, order: emojiData.order, origUnicode: emojiData.origUnicode };
// Ordering the emoji within the subgroup
const index = emojis[emojiData.group][emojiData.subgroup].findIndex((emoji) => {
return emoji.order > emojiToAdd.order;
return (emoji.order ?? 0) > emojiToAdd.order;
});
if (index > -1) {
emojis[emojiData.group][emojiData.subgroup].splice(index, 0, emojiToAdd);
@ -78,6 +83,23 @@ import * as Utils from './utilities';
}
}
// Export the emoji list to format the JSON
let exportEmoji: IEmojiGroup = {};
for (const group in emojis) {
exportEmoji[group] = {};
for (const subgroup in emojis[group]) {
exportEmoji[group][Utils.title(subgroup)] = emojis[group][subgroup].map((e) => ({
unicode: Utils.toUnicode(e.origUnicode ?? e.unicode),
shortcode: `:${e.shortcode}:` ?? '',
name: e.name,
emoji: Utils.toEmoji(e.origUnicode ?? e.unicode)
}));
}
}
// Write to a JSON file
await Utils.writeFile('github-emoji.json',JSON.stringify(exportEmoji));
// Sort the emoji from group and subgroup
let organizedEmoji: EmojiGroup[] = [];
for (const group in emojis) {
@ -141,7 +163,7 @@ import * as Utils from './utilities';
// Add GitHub Custom Emoji
tableOfContents += `\n- ${Utils.anchor('GitHub Custom Emoji')}\n\n`;
markdown += `### GitHub Custom Emoji\n\n`;
markdown += `## GitHub Custom Emoji\n\n`;
markdown += `|Emoji|Shortcode|\n`;
markdown += `|:---:|:-----:|\n`;
for (let x = 0; x < customGroup.length; x++) {
@ -155,11 +177,20 @@ import * as Utils from './utilities';
// Add Table of Contents
markdown = tableOfContents + '\n\n' + markdown;
// icon divider
markdown = ':red_circle: :orange_circle: :yellow_circle: :green_circle: :large_blue_circle: :purple_circle: :brown_circle: :black_circle: :white_circle: :red_square: :orange_square: :yellow_square: :green_square: :blue_square: :purple_square: :brown_square: :black_large_square: :white_large_square: \n\n' + markdown;
// Add GitHub Actions badge (Auto Update)
markdown = `![Auto Update by GitHub Actions](https://github.com/jasonfoknxu/github-emoji-icon-list/actions/workflows/auto-update.yml/badge.svg)\n\n` + markdown;
markdown = `[![Auto Update by GitHub Actions](https://github.com/jasonfoknxu/github-emoji-icon-list/actions/workflows/auto-update.yml/badge.svg)](https://github.com/jasonfoknxu/github-emoji-icon-list/actions/workflows/auto-update.yml) :robot: Auto update by GitHub Actions every week.\n\n` + markdown;
// Add the Json version info
markdown = `[:floppy_disk: JSON version](https://github.com/jasonfoknxu/github-emoji-icon-list/blob/main/github-emoji.json) is available. Feel free to use it for further development.\n\n` + markdown;
// Add the Json version info
markdown = `:bar_chart: Number of GitHub Emoji Icon: ${Utils.numberIcon(numberOfEmoji)}\n\n` + markdown;
// Introduction
markdown = `This list includes all the usable Emoji icon shortcodes in GitHub Markdown. The list is automatically generated from [GitHub Emoji API](${config.GitHub_Emojis_List}) with the information from [Unicode Emoji data file](${config.Unicode_Emojis_Data}).\n\nThe first column is the emoji icon, second column is the shortcode for Markdown, third column is the name of the emoji from the Unicode data.\n\n*The emoji may be displayed in different result on various system*\n\n` + markdown;
markdown = `This list includes all the usable Emoji icon shortcodes in GitHub Markdown. The list is automatically generated from [:octocat: GitHub Emoji API](${config.GitHub_Emojis_List}) with the information from [Unicode Emoji data file](${config.Unicode_Emojis_Data}).\n\n> :information_source: *The emoji may be displayed in different result on various system or browser*\n\n` + markdown;
// Heading
markdown = `# GitHub Emoji Icon List\n\n` + markdown;

@ -2,7 +2,9 @@ interface IEmoji {
unicode: string,
shortcode?: string,
name: string,
order: number
order?: number,
emoji?: string,
origUnicode?: string
}
interface IEmojiGroup {

@ -1,7 +1,8 @@
interface IUnicode {
type: string,
name: string,
unicode?: string
unicode?: string,
original?: string
}
interface IUnicodeEmojiData {
@ -12,5 +13,6 @@ interface IUnicodeEmoji {
name: string,
group: string,
subgroup: string,
order: number
order: number,
origUnicode?: string
}

@ -63,9 +63,11 @@ const parse = (text: string): IUnicode | null => {
const dataRegex = /^(.+)\s+;.+#.+E[\d.]+\s+(.+)$/i;
const dataMatch = text.match(dataRegex);
if (dataMatch !== null) {
let unicode = dataMatch[1].trim();
// \u200d is the joiner unicode which is not used in GitHub icon file naming
const unicode = dataMatch[1].trim().replace(/\s200D/g, '').replace(/\s/g, '-').toUpperCase();
return {type: 'emoji', name: dataMatch[2].trim(), unicode: unicode};
const originalUnicode = (unicode.includes(' 200D')) ? unicode.replace(/\s/g, '-').toUpperCase() : undefined;
unicode = unicode.replace(/\s200D/g, '').replace(/\s/g, '-').toUpperCase();
return {type: 'emoji', name: dataMatch[2].trim(), unicode: unicode, original: originalUnicode };
}
const subgroupRegex = /^#\s+subgroup:\s+(.+)$/i;
const subgroupMatch = text.match(subgroupRegex);
@ -115,6 +117,39 @@ const toEmoji = (unicode: string): string => {
return String.fromCodePoint(parseInt(unicode, 16));
};
/**
* Convert the unicode text to Unicode
*
* @param unicodeText - The text of the Unicode
*
* @returns The Unicode formatted unicode
*/
const toUnicode = (unicodeText: string): string => {
if (unicodeText.includes('-')) {
const codes = unicodeText.split('-');
return codes.map((u) => {
return ` U+${u}`;
}).join('').trim();
}
return `U+${unicodeText}`;
};
/**
* Convert the number to icon
*
* @param num - The number text
*
* @returns The shortcodes of the number icon
*/
const numberIcon = (num: number | string): string => {
const mapping = ['zero','one','two','three','four','five','six','seven','eight','nine'];
let result = '';
for (const n of num.toString()) {
result += `:${mapping[parseInt(n)]}:`;
}
return result;
};
/**
* Create a Markdown Anchor
*
@ -177,4 +212,4 @@ const timeNow = (): string => {
};
export {getConfig, get, base, parse, title, toEmoji, anchor, writeFile, log, timeNow};
export {getConfig, get, base, parse, title, toEmoji, toUnicode, numberIcon, anchor, writeFile, log, timeNow};

Loading…
Cancel
Save