Skip to content

pakastin/nomoji

Repository files navigation

nomoji

Replace emojis in text with SVG images (https://github.com/googlefonts/noto-emoji)

installation

npm i nomoji

usage

nomoji(text, [prefix], [disableSanitation])

nomoji("Hello from 🇫🇮");
Hello from <img draggable="false" class="emoji" src="svg/1f1eb_1f1ee.svg" />

The optional prefix parameter defines where to find image files

nomoji("Hello from 🇫🇮", "nomoji/");
Hello from
<img draggable="false" class="emoji" src="nomoji/svg/1f1eb_1f1ee.svg" />

The optional disableSanitation parameter disables HTML sanitation

nomoji("Hello <b>HTML</b> 🤩!");
Hello &#60;b&#62;HTML&#60;/b&#62;
<img draggable="false" class="emoji" src="svg/1f929.svg" />!
nomoji("Hello <b>HTML</b> 🤩!", null, true);
Hello <b>HTML</b>
<img draggable="false" class="emoji" src="dist/svg/1f929.svg" />!

You can customize the style in CSS with .emoji selector:

.emoji {
  width: 1em;
  height: 1em;
}

About

Replace emojis in text with SVG images

Resources

License

Stars

Watchers

Forks

Contributors