bueltge/marksimple

View on GitHub
src/Rule/Italic.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

declare(strict_types=1);

namespace Bueltge\Marksimple\Rule;

class Italic extends AbstractRegexRule
{
    /**
     * Get the regex rule to identify the content for the callback.
     * Italic formatting via one star * or one underline _.
     *
     * @return string
     */
    public function rule(): string
    {
        return '#(?<!\\\)([*_])([^\n|`]+?)\1#';
    }

    /**
     * {@inheritdoc}
     */
    public function render(array $content): string
    {
        return sprintf('<em>%s</em>', $content[2]);
    }
}