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

Replace unicode emoji characters, allowing them to be customized by renderer rules #53

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix linter errors and code-coverage warnings
Use enforced code style for spaces.
The code coverage checker was complaining about the 'unnecessary' check that I added in the previous commit, in case the replacement regexp didn't match anything.
  • Loading branch information
carter-thaxton committed May 14, 2024
commit 06e62632d4db62fb7985cc9ba29b3b82d566b2bc
6 changes: 2 additions & 4 deletions lib/replace.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,14 @@ export default function create_rule (md, emojies, shortcuts, scanRE, replaceRE)
if (offset + match.length < src.length && !ZPCc.test(src[offset + match.length])) {
return
}
} else if (match[0] === ':' && match[match.length-1] === ':') {
} else if (match[0] === ':' && match[match.length - 1] === ':') {
// emoji_name specified like :smile:
emoji_name = match.slice(1, -1)
} else {
// replace unicode emoji using canonical name
emoji_name = emojies_rev[match]
}

if (!emoji_name) { return }

// Add new tokens to pending list
if (offset > last_pos) {
const token = new Token('text', '', 0)
Expand Down Expand Up @@ -91,7 +89,7 @@ export default function create_rule (md, emojies, shortcuts, scanRE, replaceRE)
}
};

function reverse_object(obj) {
function reverse_object (obj) {
return Object.fromEntries(Object
.entries(obj)
.map(([key, value]) => [value, key])
Expand Down