bubbaops/boggarts

Identify mischievous, invisible, and ambiguous Unicode whitespace characters (zero width spaces, no-break spaces, and similar).

v0.0.3 2023-03-27 22:35 UTC

README

To repel or destroy a boggart, it must be laughed at.
~ Harry Potter and the Prisoner of Azkaban

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

What even is this?

Bare Bones Software famous BBEdit HTML and text editor for macOS has had a “Zap Gremlins” feature since its first public release on April 12th, 1992! Sublime text later rolled out it's own Gremlins plugin, and today you can find a VSCode Gremlins plugin.

These plugins help identify invisible and ambiguous Unicode whitespace characters (zero width spaces, no-break spaces, and others.) and have been referred to as gremlins all the way back to the early 1990's.

If you do any amount of text processing, you have no doubt run into these buggers and have probably played the game where you copy the text into an editor that will show them to you, they continue to attempt to hide, and ultimately you delete the offending thing, then copy the result back into your source material to run again.

If you are clever, you have likely worked through various iterations of attempting to simply convert your entire string to ISO-8859, perhaps created a function to remove them, and add a new one everytime you run into one, or something along those lines.

We've had enough and have decided it's time for a first class solution to the problem. We also decided on an alternative name. The new name is fairly synonymous with the concept of a gremlin, but it has a richer history and, quite frankly, I just like it better. That movie gave me nightmares as a kid, and I don't want anything to do with them now.

Features

  • Configuration for fine-grained control over your boggarts.
  • Laravel Integration.
  • Easy to use.
  • Can delete all configured bogies from your text.
  • Can optionally replace configured bogies with your choice of characters.
  • Comes pre-configured with a very nice set of boggarts to start off with.
  • Has an awesome name with references to current pop culture!
  • Solves a growing security issue for you.

Installation

You can install the package via composer:

composer require bubbaops/boggarts

Laravel Projects

You can publish the config file with:

php artisan vendor:publish --tag="boggarts-config"

Usage

$text = "    Just imagine this text full of me an nasty boggarts invisible to you!       ";
$text = \BubbaOps\Boggarts\Facades\Excise::clip($text);
// Results "Just imagine this text full of mean nasty boggarts invisible to you!" 
// All cleaned up and ready to go our for a fun night.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

❤️ Sponsor Me, Maybe

Sponsor me