关键是这个函数:
\Illuminate\Support\Str::markdown()
目前是在Laravel8看到的,姑且是8引入的吧,使用的是GitHub上的,集成过来的。
/**
* Converts GitHub flavored Markdown into HTML.
*
* @param string $string
* @param array $options
* @return string
*/
public static function markdown($string, array $options = [])
{
$converter = new GithubFlavoredMarkdownConverter($options);
return (string) $converter->convertToHtml($string);
}
将markdown的text传过去就可以了。
这里后面将有前端使用MarkDown的例子,后端接收后,存储,然后前端再展示的例子。