Skip to content

Commit

Permalink
feat: Add support for emoji-codes
Browse files Browse the repository at this point in the history
  • Loading branch information
ENDERZOMBI102 committed Sep 24, 2023
1 parent 9af5067 commit 8fec89f
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 4 deletions.
139 changes: 139 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,21 @@
},
"homepage": "https://github.com/StrataSource/strata-wiki#readme",
"dependencies": {
"typescript": "^4.9.5",
"fs-extra": "^11.1.0",
"highlight.js": "^11.7.0",
"markdown-it": "^13.0.1",
"markdown-it-container": "^3.0.0",
"markdown-it-emoji": "^2.0.2",
"markdown-it-front-matter": "^0.2.3",
"typescript": "^4.9.5",
"twemoji": "^14.0.2",
"yaml": "^2.2.1"
},
"devDependencies": {
"@types/node": "^18.13.0",
"@types/fs-extra": "^11.0.1",
"@types/markdown-it": "^12.2.3",
"@types/markdown-it-emoji": "^2.0.2",
"@types/node": "^18.13.0",
"@typescript-eslint/eslint-plugin": "^5.52.0",
"@typescript-eslint/parser": "^5.52.0",
"eslint": "^8.34.0",
Expand Down
12 changes: 10 additions & 2 deletions src/exporter/render.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import fs from 'node:fs';
import hljs from 'highlight.js';
import yaml from 'yaml';
import container_block from 'markdown-it-container';
import MarkdownIt from 'markdown-it';
import markdownItEmoji from 'markdown-it-emoji';
import container_block from 'markdown-it-container';
import markdownItFrontMatter from 'markdown-it-front-matter';
import twemoji from 'twemoji';

import { Slug } from '../common/slug';
import { MarkdownString, RenderedPage } from '../common/types';
import { Exporter } from './export';
Expand Down Expand Up @@ -31,7 +34,12 @@ export class Renderer {

return '';
}
}).use(markdownItFrontMatter, (frontMatter) => (this.tempMetaValue = yaml.parse(frontMatter)));
})
.use(markdownItEmoji)
.use(markdownItFrontMatter, (frontMatter) => (this.tempMetaValue = yaml.parse(frontMatter)));

// Use Twemojis for emojis
this.md.renderer.rules.emoji = (token, idx) => twemoji.parse(token[idx].content);

// For each game, register up a handler for its game exclusive block
for (const game of this.exporter.pageHandler.games) {
Expand Down

0 comments on commit 8fec89f

Please sign in to comment.