Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring back smartypants #2689

Merged
merged 1 commit into from Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -17,6 +17,7 @@
"league/commonmark": "^1.5",
"league/csv": "^9.0",
"league/glide": "^1.1",
"michelf/php-smartypants": "^1.8",
"pixelfear/composer-dist-plugin": "^0.1.0",
"spatie/blink": "^1.1.2",
"statamic/stringy": "^3.1",
Expand Down
12 changes: 12 additions & 0 deletions src/Modifiers/CoreModifiers.php
Expand Up @@ -1854,6 +1854,18 @@ public function slugify($value)
return Stringy::slugify($value, '-', Config::getShortLocale());
}

/**
* Parse with SmartyPants. Aren't you fancy?
*
* @param $value
* @param $params
* @return string
*/
public function smartypants($value, $params)
{
return Html::smartypants($value);
}

/**
* Sort an array by key $params[0] and direction $params[1].
*
Expand Down
6 changes: 6 additions & 0 deletions src/Support/Html.php
Expand Up @@ -3,6 +3,7 @@
namespace Statamic\Support;

use Illuminate\Support\HtmlString;
use Michelf\SmartyPants;
use Statamic\Facades\Config;
use Statamic\Facades\Markdown;

Expand Down Expand Up @@ -315,6 +316,11 @@ public static function markdown($string)
return Markdown::parse($string);
}

public static function smartypants($string)
{
return SmartyPants::defaultTransform($string, SmartyPants::ATTR_DEFAULT);
}

/**
* Sanitizes a string.
*
Expand Down