Laravel文档阅读笔记-makedown转html

Posted IT1995

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Laravel文档阅读笔记-makedown转html相关的知识,希望对你有一定的参考价值。

关键是这个函数:

\\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的例子,后端接收后,存储,然后前端再展示的例子。

以上是关于Laravel文档阅读笔记-makedown转html的主要内容,如果未能解决你的问题,请参考以下文章

Laravel文档阅读笔记-How to use @auth and @guest directives in Laravel

Laravel文档阅读笔记-How to use @auth and @guest directives in Laravel

Laravel文档阅读笔记-Adding a Markdown editor to Laravel

Laravel文档阅读笔记-Laravel Str slug() Function Example

Laravel文档阅读笔记-Laravel Str slug() Function Example

Laravel文档阅读笔记-Custom Authentication Login And Registration Using Laravel 8