常見問題

thinkphp6 后端解析markdown標(biāo)簽內(nèi)容

常見問題

2451

字體:

在 項目下/extend/Parsedown.php創(chuàng)建 Parsedown.php文件

解析文件內(nèi)容

function text($text)
{
    $Elements = $this->textElements($text);

    # convert to markup
    $markup = $this->elements($Elements);

    # trim line breaks
    $markup = trim($markup, "\n");

    return $markup;
}

全部文件下載 

Parsedown.php

后端調(diào)用方法引入

use Parsedown


$content="要解析的內(nèi)容";
$Parsedown = new Parsedown();//實例化$bodyParse = $Parsedown->text($content); //調(diào)用解析$choices=['role'=>'assistant','content'=>"$content"];//返回前端

來源:thinkphp6 后端解析markdown標(biāo)簽內(nèi)容 (hbsjsd.cn)

[聲明]原創(chuàng)不易,請轉(zhuǎn)發(fā)者備注下文章來源(hbsjsd.cn)【速建時代】。