PHPackages                             schibsted-tech-polska/php-content-stylizer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. schibsted-tech-polska/php-content-stylizer

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

schibsted-tech-polska/php-content-stylizer
==========================================

Content stylizer for Schibsted Media Platform data

1.0.2(9y ago)12101MITPHPPHP &gt;=5.6.0CI failing

Since Feb 3Pushed 9y ago18 watchersCompare

[ Source](https://github.com/Schibsted-Tech-Polska/php-content-stylizer)[ Packagist](https://packagist.org/packages/schibsted-tech-polska/php-content-stylizer)[ Docs](https://github.com/Schibsted-Tech-Polska/php-content-stylizer)[ RSS](/packages/schibsted-tech-polska-php-content-stylizer/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (4)Versions (5)Used By (0)

Content Stylizer - PHP
======================

[](#content-stylizer---php)

This library was written to support converting [text objects introduced in Schibsted Media Platform's article format version 5](https://github.schibsted.io/spt-mediaplatform/formatron/tree/master/article-v5#text) 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:
------------

[](#basic-usage)

### Defining tags list (method 1):

[](#defining-tags-list-method-1)

```
$stylizer = new \ContentStylizer\Stylizer([
    [
        'beginning' => '',
        'end' => '',
        'type' => 'strong',
    ],
]);

```

### Defining tags list (method 2):

[](#defining-tags-list-method-2)

```
$stylizer = new \ContentStylizer\Stylizer();
$stylizer->addTag('strong', '', '');

```

### Converting text into HTML:

[](#converting-text-into-html)

```
$text = 'Sample text';
$markups = [
    [
        'length' => 6,
        'offset' => 0,
        'type' => 'strong',
    ],
];

$html = $stylizer->getHtml($text, $markups);

```

Parameters inside tags:
-----------------------

[](#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:

```
$stylizer->addTag('link', function (\stdClass $params) {
    return ';
}, '');

```

Then we can use `link` markup:

```
$html = $stylizer->getHtml('Our link', [
    [
        'length' => 4,
        'offset' => 4,
        'type' => 'link',
        'uri' => 'http://www.example.com',
    ],
]);

```

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:
---------------

[](#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:

```
    ...
    [
        'beginning' => '',
        'type' => 'br',
    ],
    ...

```

We can define it using `addTag` method as well:

```
$stylizer->addTag('br', '');

```

If we define `br` tag, Stylizer will also add line break in every place in text before `PHP_EOL` sign occurence.

Tests:
------

[](#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:

```
sudo npm install -g grunt-cli

```

and project dependencies:

```
npm install

```

To start testing just simply execute:

```
grunt test

```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

4

Last Release

3422d ago

Major Versions

0.1.0 → 1.0.02017-02-07

### Community

Maintainers

![](https://www.gravatar.com/avatar/8f7a83887201d4d7911caa6e42f1552846694182ccd1ab2496acd73619363748?d=identicon)[svd-stp](/maintainers/svd-stp)

---

Tags

contentsvdstylizerstylizr

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/schibsted-tech-polska-php-content-stylizer/health.svg)

```
[![Health](https://phpackages.com/badges/schibsted-tech-polska-php-content-stylizer/health.svg)](https://phpackages.com/packages/schibsted-tech-polska-php-content-stylizer)
```

###  Alternatives

[willdurand/negotiation

Content Negotiation tools for PHP provided as a standalone library.

1.4k126.6M194](/packages/willdurand-negotiation)[rubix/tensor

A library and extension that provides objects for scientific computing in PHP.

2791.5M5](/packages/rubix-tensor)[mtownsend/read-time

A PHP package to show users how long it takes to read content.

282616.7k2](/packages/mtownsend-read-time)[h5p/h5p-core

H5P Core functionality in PHP

1461.6M38](/packages/h5p-h5p-core)[j0k3r/php-readability

Automatic article extraction from HTML

184861.9k6](/packages/j0k3r-php-readability)[ichhabrecht/content-defender

Define allowed or denied content element types in your backend layouts

903.1M24](/packages/ichhabrecht-content-defender)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
