wptelegram/format-text

This package is abandoned and no longer maintained. The author suggests using the wpsocio/telegram-format-text package instead.

HTML to Text converter/formatter for Telegram Bot API

v1.1.0 2023-11-20 08:10 UTC

This package is auto-updated.

Last update: 2024-02-03 11:50:22 UTC


README

HTML to Text converter/formatter for Telegram Bot API

Inspired by thephpleague/html-to-markdown.

Abandonned!

Please use wpsocio/telegram-format-text

Usage

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.

Requirements

  • PHP >= 7.0