PHPackages                             jacksleight/statamic-bard-mutator - 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. jacksleight/statamic-bard-mutator

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

jacksleight/statamic-bard-mutator
=================================

3.0.5(8mo ago)26101.0k↓25.3%4[1 PRs](https://github.com/jacksleight/statamic-bard-mutator/pulls)1PHP

Since Sep 23Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/jacksleight/statamic-bard-mutator)[ Packagist](https://packagist.org/packages/jacksleight/statamic-bard-mutator)[ GitHub Sponsors](https://github.com/jacksleight)[ RSS](/packages/jacksleight-statamic-bard-mutator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (37)Used By (1)

Bard Mutator
============

[](#bard-mutator)

This Statamic addon allows you to modify the data and tags rendered by the Bard fieldtype, giving you full control over the final HTML. You can add, remove and modify attributes, wrap tags and content, or rename and replace tags entirely. You can also make changes the raw data before anything is rendered to HTML.

Examples
--------

[](#examples)

Here are a few examples of what's possible. For more information and more examples check [the documentation](https://jacksleight.dev/docs/bard-mutator/examples).

### Add a class to all external links

[](#add-a-class-to-all-external-links)

```
use JackSleight\StatamicBardMutator\Facades\Mutator;
use Statamic\Facades\URL;

Mutator::html('link', function ($value) {
    if (URL::isExternal($value[1]['href'])) {
        $value[1]['class'] = 'external';
    }
    return $value;
});
```

### Add an auto-generated ID to all level 2 headings

[](#add-an-auto-generated-id-to-all-level-2-headings)

```
use Illuminate\Support\Str;
use JackSleight\StatamicBardMutator\Facades\Mutator;

Mutator::html('heading', function ($value, $item) {
    if ($item->attrs->level === 2) {
        $value[1]['id'] = Str::slug(collect($item->content)->implode('text', ''));
    }
    return $value;
});
```

### Add permalink anchors to all headings

[](#add-permalink-anchors-to-all-headings)

```
use Illuminate\Support\Str;
use JackSleight\StatamicBardMutator\Facades\Mutator;
use JackSleight\StatamicBardMutator\Support\Data;

Mutator::data('heading', function ($data) {
    $slug = Str::slug(collect($data->content)->implode('text', ''));
    array_unshift(
        $data->content,
        Data::html('#')
    );
});
```

Documentation
-------------

[](#documentation)

[Statamic Bard Mutator Documentation](https://jacksleight.dev/docs/bard-mutator)

Compatibility
-------------

[](#compatibility)

In order to give you access to the Tiptap rendering process Bard Mutator has to override the Tiptap editor class and replace the built-in extensions with its own. It can only do that reliably if there are no other addons (or user code) trying to do the same thing. To help minimise incompatibilities Bard Mutator will only replace extensions that are actually being mutated, and this is only required for HTML plugins.

Sponsoring
----------

[](#sponsoring)

This addon is completely free to use. However fixing bugs, adding features and helping users takes time and effort. If you find this addon useful and would like to support its development any [contribution](https://github.com/sponsors/jacksleight) would be greatly appreciated. Thanks! 🙂

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance58

Moderate activity, may be stable

Popularity42

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 98.4% of commits — single point of failure

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 ~51 days

Recently: every ~80 days

Total

29

Last Release

269d ago

Major Versions

0.2.0 → 1.0.02021-12-01

1.1.3 → 2.0.02023-01-31

2.3.1 → 3.0.02024-09-03

### Community

Maintainers

![](https://www.gravatar.com/avatar/5b1acb404d9801e5f633e31efa3403a4735e43ea93c798e3f895ba3264c92c6e?d=identicon)[jacksleight](/maintainers/jacksleight)

---

Top Contributors

[![jacksleight](https://avatars.githubusercontent.com/u/126740?v=4)](https://github.com/jacksleight "jacksleight (185 commits)")[![jelleroorda](https://avatars.githubusercontent.com/u/9193686?v=4)](https://github.com/jelleroorda "jelleroorda (1 commits)")[![robdekort](https://avatars.githubusercontent.com/u/69107412?v=4)](https://github.com/robdekort "robdekort (1 commits)")[![wesort](https://avatars.githubusercontent.com/u/3920126?v=4)](https://github.com/wesort "wesort (1 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/jacksleight-statamic-bard-mutator/health.svg)

```
[![Health](https://phpackages.com/badges/jacksleight-statamic-bard-mutator/health.svg)](https://phpackages.com/packages/jacksleight-statamic-bard-mutator)
```

###  Alternatives

[statamic/ssg

Generate static sites with Statamic.

254302.4k](/packages/statamic-ssg)[statamic/seo-pro

65440.7k](/packages/statamic-seo-pro)[jacksleight/statamic-bard-texstyle

17172.5k](/packages/jacksleight-statamic-bard-texstyle)[visuellverstehen/statamic-classify

A useful helper to add CSS classes to all HTML tags generated by the bard editor.

20116.8k](/packages/visuellverstehen-statamic-classify)[marcorieser/statamic-livewire

A Laravel Livewire integration for Statamic.

2381.5k10](/packages/marcorieser-statamic-livewire)[withcandour/aardvark-seo

Save time and get your Statamic site to rank better with the SEO addon for Statamic.

13128.3k](/packages/withcandour-aardvark-seo)

PHPackages © 2026

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