Yoast\WP\SEO\Llms_Txt\Application

Markdown_Escaper::escape_markdown_content │ public │ Yoast 1.0

Escapes markdown text.

Метод класса: Markdown_Escaper{}

Хуков нет.

Возвращает

string. The escaped markdown text.

Использование

$Markdown_Escaper = new Markdown_Escaper();
$Markdown_Escaper->escape_markdown_content( $text );
$text(строка) (обязательный)
The markdown text to escape.

Код Markdown_Escaper::escape_markdown_content() Yoast 28.9

public function escape_markdown_content( $text ) {
	// We have to decode the text first mostly because ampersands will be escaped below.
	$text = \html_entity_decode( $text, \ENT_QUOTES, 'UTF-8' );

	// Define a regex pattern for all the special characters in markdown that we want to escape.
	$pattern = '/[-#*+`._[\]()!&<>_{}|]/';

	$replacement = static function ( $matches ) {
		return '\\' . $matches[0];
	};

	return \preg_replace_callback( $pattern, $replacement, $text );
}