<commit_before><?php

/*
 * This file is part of the Tinyissue package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Tinyissue\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\View\Compilers\BladeCompiler;

/**
 * BladeServiceProvider is the blade service provider for extending blade template engine
 *
 * @author <NAME> <<EMAIL>>
 */
class BladeServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     */
    public function boot()
    {
        \Blade::extend(function ($view) {
            $pattern = '/@macro\s*\(\s*[\'"](.*)[\'"]\s*,\s*(.*)\)/';

            return preg_replace($pattern, "<?php \$___tiny['\$1']=function(\$2){ ob_start(); ?>\n", $view);
        });

        \Blade::extend(function ($view, BladeCompiler $compiler) {
            $pattern = $compiler->createPlainMatcher('endmacro');

            return preg_replace($pattern, "\n<?php return ob_get_clean();} ?>\n", $view);
        });

        \Blade::extend(function ($view) {
            $pattern = '/\s*@usemacro\s*\(\s*[\'"](\w+|\d+)[\'"]\s*,\s*(.*)\)/';

            return preg_replace($pattern, "<?php echo \$___tiny['\$1'](\$2); ?>\n", $view);<commit_msg>Misc: improve blade macro regex pattern<commit_after><?php

/*
 * This file is part of the Tinyissue package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Tinyissue\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\View\Compilers\BladeCompiler;

/**
 * BladeServiceProvider is the blade service provider for extending blade template engine
 *
 * @author <NAME> <<EMAIL>>
 */
class BladeServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     */
    public function boot()
    {
        \Blade::extend(function ($view) {
            $pattern = '/@(macro)\s*(\([\'|\"](\w+)[\'|\"],\s*(([^\@])+|(.*))\))/xim';

            return preg_replace($pattern, "<?php \$___tiny['\$3']=function(\$4){ ob_start(); ?>\n", $view);
        });

        \Blade::extend(function ($view, BladeCompiler $compiler) {
            $pattern = $compiler->createPlainMatcher('endmacro');

            return preg_replace($pattern, "\n<?php return ob_get_clean();} ?>\n", $view);
        });

        \Blade::extend(function ($view) {
            $pattern = '/@(usemacro)\s*(\([\'|\"](\w+)[\'|\"],\s*(([^\@])+|(.*))\))/xim';

            return preg_replace($pattern, "<?php echo \$___tiny['\$3'](\$4); ?>\n", $view);
{'fraction_non_alphanumeric': 0.20459599703484063, 'fraction_numerical': 0.0029651593773165306, 'mean_word_length': 3.0525525525525525, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4610836', 'n_tokens_mistral': 859, 'n_tokens_neox': 827, 'n_words': 198}