Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for emoji-codes #43

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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