Astrotomic / Astrotomic/php-twemoji

Add HTML parser/replacer

Open
#2 3 comments 1 reaction 0 assignees View on GitHub
enhancement help wanted
Dominant language
PHP
Stars
34
Forks
13
PR merge metrics
No merged PRs in 30d

Description

The original JavaScript Twemoji client allows replacing all emojis in a given text with the corresponding Twemoji image tag in one go.
We should provide a similar method like `Twemoji::parse($html)` which will search for emojis and replace them.

As this requires a DOM/HTML parser to don't replace emojis in image alternate attributes for example this should be an opt-in feature. SO the DOM library shouldn't be part of the default dependencies but the `suggestions`.

The method should also be flagged as experimental so everyone knows that it's possible that this method makes trouble.

To test this we should use snapshot testing on some blog posts for example. (could be faked)
They should cover emojis in plain text `.txt`, in the displayed content of HTML (outside of tags, in tag(s), with body or without) and as part of HTML attributes.

content parser and emoji replacer for:
* [x] Text `.txt` https://github.com/Astrotomic/php-twemoji/issues/3
* [ ] HTML `.html`
* [ ] Markdown `.md`

Contributor guide

Open the contributing guide

Research direction

Start with the existing text parser/replacer from issue #3 and investigate the proposed Twemoji::parse($html) entry point. Review how the optional DOM/HTML parser would be declared under suggestions rather than default dependencies, then design snapshot coverage for plain text, HTML content, tags, bodies with and without body elements, and attributes. Done means emoji replacement works without altering image alt attributes and the method is marked experimental.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
content
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.