asokol1981 / telegram-entities-html
Renders Telegram message entities into HTML
Installs: 33
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:project
Requires
- php: >=8.1
- ext-mbstring: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.75
- phpunit/phpunit: ^10.5.17 || ^11.0.7
This package is auto-updated.
Last update: 2025-05-26 19:28:23 UTC
README
📦 Turn Telegram message entities into HTML with ease.
Features
- Converts
text
andcaption
withentities
orcaption_entities
to HTML - Supports all Telegram formatting types (bold, italic, code, etc.)
- Outputs safe and valid HTML, suitable for web rendering
- Written in modern PHP
Installation
Composer
composer require asokol1981/telegram-entities-html
VCS
If the package is not available on Packagist, you can install it by adding the following to your composer.json
:
{ "repositories": [ { "type": "vcs", "url": "https://github.com/asokol1981/telegram-entities-html" } ], "require": { "asokol1981/telegram-entities-html": "dev-main" } }
Then run:
composer update
⚠️ Make sure your project allows the dev-main version or use a specific tag (e.g. ^1.0) once available.
Usage
use ASokol1981\Telegram\Entities\Html\Renderer; $renderer = new Renderer(); $html = $renderer->render( '😎 Text message with bold and italic', [ ['type' => 'bold', 'offset' => 21, 'length' => 4], ['type' => 'italic', 'offset' => 30, 'length' => 6], ] ); echo $html; // 😎 Text message with <b>bold</b> and <i>italic</i>
Works with both text
+ entities
and caption
+ caption_entities
.
Supported entity types:
- bold
- italic
- underline
- strikethrough
- spoiler
- blockquote
- expandable_blockquote
- code
- pre
- text_link
- text_mention
- custom_emoji
🛠️ Makefile Commands
To simplify local development, the following make
commands are available:
📦 Installation
make install
Builds the Docker container, starts it in the background, and installs Composer dependencies.
🏗️ Build Image
make build
Builds the Docker image with the tag asokol1981/telegram-entities-html
.
▶️ Start Container
make start
Starts the container in detached mode.
⏹️ Stop Container
make stop
Stops and removes the container (volumes are preserved).
🧹 Uninstall
make uninstall
Stops and removes the container, associated volumes, and the Docker image.
🐚 Shell Access
make exec -- bash
Runs a command inside the container.
Be sure to use --
to separate make
arguments from the actual command:
make exec -- php -v
🎼 Composer
make composer -- require --dev phpunit/phpunit
Executes a Composer command inside the container. Example: install PHPUnit as a dev dependency.
✅ Run Tests
make test
Runs tests and shows code coverage summary in the terminal.
📊 HTML Coverage Report
make coverage
Generates a code coverage report in HTML format and saves it in the coverage/
directory.
🧱 Artisan
make artisan -- list
Executes an Artisan command inside the container.
🧹 Code Style Fix
make php-cs-fixer
Runs PHP-CS-Fixer inside the container to automatically fix coding style issues according to the defined .php-cs-fixer.dist.php
configuration.
✅ Validate Codecov Configuration
You can validate codecov.yml
configuration using:
make codecov-validate
This command checks the syntax and structure of the codecov.yml
file using Codecov’s validation API.
It helps catch errors before pushing changes.
ℹ️ Note:
When passing arguments to exec
, composer
, artisan
, test
, or coverage
targets, always prefix them with --
so make
doesn't interpret them as its own flags.
License
MIT © asokol1981