acf_parse_markdown()
acf_parse_markdown
A very basic regex-based Markdown parser function based off slimdown.
Хуков нет.
Возвращает
Строку
.
Использование
acf_parse_markdown( $text );
- $text(строка)
- The string to parse.
По умолчанию: ''
Список изменений
С версии 5.7.2 | Введена. |
Код acf_parse_markdown() acf parse markdown ACF 6.0.4
function acf_parse_markdown( $text = '' ) { // trim $text = trim( $text ); // rules $rules = array( '/=== (.+?) ===/' => '<h2>$1</h2>', // headings '/== (.+?) ==/' => '<h3>$1</h3>', // headings '/= (.+?) =/' => '<h4>$1</h4>', // headings '/\[([^\[]+)\]\(([^\)]+)\)/' => '<a href="$2">$1</a>', // links '/(\*\*)(.*?)\1/' => '<strong>$2</strong>', // bold '/(\*)(.*?)\1/' => '<em>$2</em>', // intalic '/`(.*?)`/' => '<code>$1</code>', // inline code '/\n\*(.*)/' => "\n<ul>\n\t<li>$1</li>\n</ul>", // ul lists '/\n[0-9]+\.(.*)/' => "\n<ol>\n\t<li>$1</li>\n</ol>", // ol lists '/<\/ul>\s?<ul>/' => '', // fix extra ul '/<\/ol>\s?<ol>/' => '', // fix extra ol ); foreach ( $rules as $k => $v ) { $text = preg_replace( $k, $v, $text ); } // autop $text = wpautop( $text ); // return return $text; }