Skip to content
This repository has been archived by the owner on Feb 3, 2024. It is now read-only.

wpsocio/wptelegram-format-text

Repository files navigation

WPTelegram\FormatText

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