HTML to Text converter/formatter for Telegram Bot API
Inspired by thephpleague/html-to-markdown.
Please use wpsocio/telegram-format-text
composer require wptelegram/format-text
require_once __DIR__ . '/autoload-static.php';
// Or this for usage in WordPress
require_once __DIR__ . '/autoload-wp.php';
$html = 'Some html here';
$options = [
'format_to' => 'Markdown',
];
$converter = new \WPTelegram\FormatText\HtmlConverter( $options );
// The text is now safe to be sent to Telegram
$text = $converter->convert( $html );
NOTES:
- Do not require conditionally, like
if ( class_exists() )
. - It's safe to include it directly.
- Library takes care of its multiple versions being loaded.
- It always loads the latest version.
PHP >= 7.0