src/Rule/Italic.php
<?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]);
}
}