Skip to content

Commit

Permalink
Rewrite to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
puzrin committed Dec 7, 2023
1 parent cc57dff commit 5490bf5
Show file tree
Hide file tree
Showing 36 changed files with 594 additions and 3,388 deletions.
149 changes: 4 additions & 145 deletions .eslintrc.yml
@@ -1,13 +1,8 @@
env:
node: true
es6: true
extends: standard

overrides:
-
files: [ '*.mjs' ]
parserOptions:
ecmaVersion: latest
sourceType: module
rules:
no-restricted-globals: [ 2, require, __dirname ]
-
Expand All @@ -18,145 +13,9 @@ overrides:
parserOptions: { ecmaVersion: 2015 }

ignorePatterns:
- coverage/
- dist/
- lib/data/full.js
- lib/data/light.js
- lib/data/light.mjs
- lib/data/full.mjs

rules:
accessor-pairs: 2
array-bracket-spacing: [ 2, "always", { "singleValue": true, "objectsInArrays": true, "arraysInArrays": true } ]
block-scoped-var: 2
block-spacing: 2
brace-style: [ 2, '1tbs', { allowSingleLine: true } ]
# Postponed
#callback-return: 2
comma-dangle: 2
comma-spacing: 2
comma-style: 2
computed-property-spacing: [ 2, never ]
consistent-this: [ 2, self ]
consistent-return: 2
# ? change to multi
curly: [ 2, 'multi-line' ]
dot-notation: 2
eol-last: 2
eqeqeq: 2
func-style: [ 2, declaration ]
# Postponed
#global-require: 2
guard-for-in: 2
handle-callback-err: 2

indent: [ 2, 2, { VariableDeclarator: { var: 2, let: 2, const: 3 }, SwitchCase: 1 } ]

# key-spacing: [ 2, { "align": "value" } ]
keyword-spacing: 2
linebreak-style: 2
max-depth: [ 1, 6 ]
max-nested-callbacks: [ 1, 4 ]
# string can exceed 80 chars, but should not overflow github website :)
max-len: [ 2, 120, 1000 ]
new-cap: 2
new-parens: 2
# Postponed
#newline-after-var: 2
no-alert: 2
no-array-constructor: 2
no-bitwise: 2
no-caller: 2
#no-case-declarations: 2
no-catch-shadow: 2
no-cond-assign: 2
no-console: 1
no-constant-condition: 2
#no-control-regex: 2
no-debugger: 2
no-delete-var: 2
no-div-regex: 2
no-dupe-args: 2
no-dupe-keys: 2
no-duplicate-case: 2
no-else-return: 2
# Tend to drop
# no-empty: 1
no-empty-character-class: 2
no-empty-pattern: 2
no-eq-null: 2
no-eval: 2
no-ex-assign: 2
no-extend-native: 2
no-extra-bind: 2
no-extra-boolean-cast: 2
no-extra-semi: 2
no-fallthrough: 2
no-floating-decimal: 2
no-func-assign: 2
# Postponed
#no-implicit-coercion: [2, { "boolean": true, "number": true, "string": true } ]
no-implied-eval: 2
no-inner-declarations: 2
no-invalid-regexp: 2
no-irregular-whitespace: 2
no-iterator: 2
no-label-var: 2
no-labels: 2
no-lone-blocks: 2
no-lonely-if: 2
no-loop-func: 2
no-mixed-requires: 2
no-mixed-spaces-and-tabs: 2
# Postponed
#no-native-reassign: 2
no-negated-in-lhs: 2
# Postponed
#no-nested-ternary: 2
no-new: 2
no-new-func: 2
no-new-object: 2
no-new-require: 2
no-new-wrappers: 2
no-obj-calls: 2
no-octal: 2
no-octal-escape: 2
no-path-concat: 2
no-proto: 2
no-redeclare: 2
# Postponed
#no-regex-spaces: 2
no-return-assign: 2
no-self-compare: 2
no-sequences: 2
no-shadow: 2
no-shadow-restricted-names: 2
no-sparse-arrays: 2
no-trailing-spaces: 2
no-undef: 2
no-undef-init: 2
no-undefined: 2
no-unexpected-multiline: 2
no-unreachable: 2
no-unused-expressions: 2
no-unused-vars: 2
no-use-before-define: 2
no-void: 2
no-with: 2
object-curly-spacing: [ 2, always, { "objectsInObjects": true, "arraysInObjects": true } ]
operator-assignment: 1
# Postponed
#operator-linebreak: [ 2, after ]
semi: 2
semi-spacing: 2
space-before-function-paren: [ 2, { "anonymous": "always", "named": "never" } ]
space-in-parens: [ 2, never ]
space-infix-ops: 2
space-unary-ops: 2
# Postponed
#spaced-comment: [ 1, always, { exceptions: [ '/', '=' ] } ]
strict: [ 2, global ]
quotes: [ 2, single, avoid-escape ]
quote-props: [ 1, 'as-needed', { "keywords": true } ]
radix: 2
use-isnan: 2
valid-typeof: 2
yoda: [ 2, never, { "exceptRange": true } ]
camelcase: 0
3 changes: 1 addition & 2 deletions .gitignore
@@ -1,4 +1,3 @@
.nyc_output
node_modules/
coverage/
*.log
dist/
8 changes: 8 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,11 @@
3.0.0 / 2023-12-07
------------------

- Breaking: changed exports. See README.
- Rewrite to ESM.
- Remove `dist/` from repo (build on package publish).


2.0.2 / 2022-04-22
------------------

Expand Down
49 changes: 18 additions & 31 deletions README.md
Expand Up @@ -4,39 +4,36 @@
[![NPM version](https://img.shields.io/npm/v/markdown-it-emoji.svg?style=flat)](https://www.npmjs.org/package/markdown-it-emoji)
[![Coverage Status](https://coveralls.io/repos/markdown-it/markdown-it-emoji/badge.svg?branch=master&service=github)](https://coveralls.io/github/markdown-it/markdown-it-emoji?branch=master)

> Plugin for [markdown-it](https://github.com/markdown-it/markdown-it) markdown parser, adding emoji & emoticon syntax support.
> Plugin for [markdown-it](https://github.com/markdown-it/markdown-it) markdown parser, adding emoji & emoticon syntax support. Also supports emoticons [shortcuts](https://github.com/markdown-it/markdown-it-emoji/blob/master/lib/data/shortcuts.js) like `:)`, `:-(`, and others.
__v1.+ requires `markdown-it` v4.+, see changelog.__

Three versions:

- __Full__ (default), with all github supported emojis.
- [Light](https://github.com/markdown-it/markdown-it-emoji/blob/master/lib/data/light.js), with only well-supported unicode emojis and reduced size.
- Bare, without included emojis or shortcuts. This requires defining your own definitions and shortcuts.

Also supports emoticons [shortcuts](https://github.com/markdown-it/markdown-it-emoji/blob/master/lib/data/shortcuts.js) like `:)`, `:-(`, and others. See the full list in the link above.
__NOTE. v3 changed exports, see below.__


## Install

node.js, browser:

```bash
npm install markdown-it-emoji --save
bower install markdown-it-emoji --save
npm install i markdown-it-emoji
```

## Use

### init

```js
var md = require('markdown-it')();
var emoji = require('markdown-it-emoji');
// Or for light version
// var emoji = require('markdown-it-emoji/light');

md.use(emoji [, options]);
//
// { full, light, bare } configs available.
//
// full: includes all available emojis support
// light: includes small subset of most useable emojis
// bare: no defaults
//
// Also CJS & UMD builds available in `dist/` folder of published package,
// if your env not supports ESM modules use.
//
import { full as emoji } from 'markdown-it-emoji'
import markdownit from 'markdown-it'

const md = markdownit().use(emoji/* , options */);
```

Options are not mandatory:
Expand All @@ -49,12 +46,6 @@ Options are not mandatory:

_Differences in browser._ If you load the script directly into the page without
using a package system, the module will add itself globally with the name `markdownitEmoji`.
Init code will look a bit different in this case:

```js
var md = window.markdownit().use(window.markdownitEmoji);
```


### change output

Expand All @@ -78,7 +69,7 @@ Or use [twemoji](https://github.com/twitter/twemoji):
// ...
// initialize

var twemoji = require('twemoji')
import twemoji from 'twemoji'

md.renderer.rules.emoji = function(token, idx) {
return twemoji.parse(token[idx].content);
Expand Down Expand Up @@ -108,7 +99,3 @@ becomes
```
Hello from mars 📡
```

## License

[MIT](https://github.com/markdown-it/markdown-it-emoji/blob/master/LICENSE)
25 changes: 0 additions & 25 deletions bare.js

This file was deleted.

0 comments on commit 5490bf5

Please sign in to comment.