Git Product home page Git Product logo

asciidoctor-emoji's Introduction

πŸš€ Asciidoctor Emoji Extension

Build npm version

An extension for Asciidoctor.js that turns emoji:heart[] into ❀️ !

Install

Node.js

Install the dependencies:

$ npm i @asciidoctor/core asciidoctor-emoji

Create a file namedΒ emoji.js with following content and run it:

const asciidoctor = require('@asciidoctor/core')()
const emoji = require('asciidoctor-emoji')

const input = 'I emoji:heart[1x] Asciidoctor.js!'

emoji.register(asciidoctor.Extensions)
console.log(asciidoctor.convert(input)) // <1>

const registry = asciidoctor.Extensions.create()
emoji.register(registry)
console.log(asciidoctor.convert(input, {'extension_registry': registry})) // <2>

<1> Register the extension in the global registry
<2> Register the extension in a dedicated registry

Browser

Install the dependencies:

$ npm i @asciidoctor/core asciidoctor-emoji

Create a file named emoji.html with the following content and open it in your browser:

<html>
  <head>
    <script src="node_modules/@asciidoctor/core/dist/browser/asciidoctor.js"></script>
    <script src="node_modules/asciidoctor-emoji/dist/browser/asciidoctor-emoji.js"></script>
  </head>
  <body>
    <div id="content"></div>
    <script>
      var input = 'I emoji:heart[1x] Asciidoctor.js!'

      var asciidoctor = Asciidoctor()
      var emoji = AsciidoctorEmoji

      const registry = asciidoctor.Extensions.create()
      emoji.register(registry)
      var result = asciidoctor.convert(input, {'extension_registry': registry})
      document.getElementById('content').innerHTML = result
    </script>
  </body>
</html>

<1> Register the extension in the global registry
<2> Register the extension in a dedicated registry

Usage

Use emoji: followed by the name of your emoji (and don't forget the square brackets). For instance wink:

emoji:wink[]

Additionally you can configure the size of an emoji. By default, the size is 24px but you can use one of the following:

  • 1x (17px)
  • lg (24px)
  • 2x (34px)
  • 3x (50px)
  • 4x (68px)
  • 5x (85px)

If you want a really big 🐻, use:

emoji:bear[5x]

You can also specify a size in pixel πŸŽ‰

emoji:tada[42px]

How ?

This extension is using Twemoji from Twitter. The emoji inline macro is converted into an <image> that points to a remote SVG:

emoji:beetle[]
<span class="emoji"><img src="https://twemoji.maxcdn.com/2/svg/1f41e.svg" alt="beetle" width="24px" height="24px"></span>

beetle

asciidoctor-emoji's People

Contributors

cbergmann avatar dependabot-preview[bot] avatar dependabot[bot] avatar ggrossetie avatar mitm001 avatar xavier-calland avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

asciidoctor-emoji's Issues

Update @asciidoctor/core dep version

@asciidoctor/core is now version 3.0.2

It would be great to have a version of this plugin compatible with the new version on @asciidoctor/core

Possible format bug?

Converting from AsciiDoctor's emoji-inline-macro

Hi, I'm trying to convert docs from the Ruby Asciidoctor to Asciidoctor.js, because I'm now using Antora. I used to use emoji-inline-macro. I tried to use this module, but some emoji's aren't working. It used twemoji I'm pretty sure. Is it possible to use twemoji? Also, this project uses an old version of Asciidoctor.js. Do you have plans to update that?

Offline Emoji

Hello, thanks for this wonderful extension. It works superb!.
One idea is having an offline option so emojis are downloaded, using the local image instead of the twemoji url. This would be specially useful when using pdf output.

Thanks again πŸ‘

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.