Download the PHP package schibsted-tech-polska/php-content-stylizer without Composer
On this page you can find all versions of the php package schibsted-tech-polska/php-content-stylizer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download schibsted-tech-polska/php-content-stylizer
More information about schibsted-tech-polska/php-content-stylizer
Files in schibsted-tech-polska/php-content-stylizer
Package php-content-stylizer
Short Description Content stylizer for Schibsted Media Platform data
License MIT
Homepage https://github.com/Schibsted-Tech-Polska/php-content-stylizer
Informations about the package php-content-stylizer
Content Stylizer - PHP
This library was written to support converting text objects introduced in Schibsted Media Platform's article format version 5 into HTML in PHP.
To use it you have to create Stylizer instance and define a list of supported tags in one of two ways. Then you can use getHtml
method passing text and an array with markups and receiving HTML code as an output.
Basic usage:
Defining tags list (method 1):
Defining tags list (method 2):
Converting text into HTML:
Parameters inside tags:
Both beginning
and end
attribute of any tag can be defined using string or anonymous function. The second way allows us to add some logic to HTML creation process and to use parameters passed in markup objects.
Let's define link
tag:
Then we can use link
markup:
Note that $params
object contains all attributes of markup one except length
, offset
and type
which means that in this example it contains only uri
parameter.
Singleton tags:
There is also a way of defining singleton tags, e.g. line breaks - Stylizer will treat as singleton every tag without end
parameter defined.
It can be defined in an array passed to constructor:
We can define it using addTag
method as well:
If we define br
tag, Stylizer will also add line break in every place in text before PHP_EOL
sign occurence.
Tests:
This library contains unit tests and some other CI tools which can be easily run using Node.js. To do it install Node.js environment, then Grunt CLI:
and project dependencies:
To start testing just simply execute:
All versions of php-content-stylizer with dependencies
php Version >=5.6.0