This is a Conversion library that handles the input from Sir Trevor and converts it to HTML. In the future, the conversion from HTML to the Json input Sir Trevor needs will be implemented too.
- Heading
- Paragraph
- List
- Video
- Quote
- Image
More coming soon
This library package requires PHP 5.3 or later.
Require the library in your composer.json:
{
"require": {
"woutersioen/sir-trevor-php": "dev-master"
}
}
Then composer install
and add require 'vendor/autoload.php';
to the top of your script.
// add the composer autoloader to your file
require_once 'vendor/autoload.php';
// Add a use statement to be able to use the class
use Sioen\Converter;
// fetch the data from the post
$sirTrevorInput = $_POST['textarea'];
// create a converter object and handle the input
$converter = new Converter();
$html = $converter->toHtml($sirTrevorInput);
// fetch html from database or wherever you want to fetch it from
$html = '<h2>This is my html</h2>';
// create a converter object and handle the output
$converter = new Converter();
$json = $converter->toJson($html);