Laravel Framework 7.5.2 安裝markdown

首先我們來安裝Laravel Framework 7.x框架。這裏有好多種方法;

直接去官網下載Laravel 源碼包,或者直接clone源代碼:

下載後進入Laravel 目錄:

接下來進行安裝Laravel ,這裏面有個前奏,如果對Composer 的使用不太瞭解,可以先看一下這篇文章,進一步瞭解Composer 的用法:

https://blog.csdn.net/lchmyhua88/article/details/88928342

 

接下來就開始安裝,由於Composer 進項安裝太慢,換鏡像:

 一直等到安裝 完成後,接着安裝key:generate

 在nginx裏面配置訪問地址:

server {
    listen 80;
    server_name lch.markdown.com;
    root "/htdocs/laravel-master/public/";

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log on;
    error_log  /var/log/nginx/lch.markdown.com-error.log error;

    sendfile off;

    client_max_body_size 100m;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
    }

    location ~ /\.ht {
        deny all;
    }
}

重啓nginx,後訪問:

接着安裝 Markdown:

安裝流程
1、安裝的兩種方式

① 直接編輯配置文件

將以下內容增加到 composer.json:

require: {
    "chenhua/laravel5-markdown-editor": "~1.0"
}
然後運行 composer update。

② 執行命令安裝

運行命令:

composer require chenhua/laravel5-markdown-editor
2、完成上面的操作後,修改 config/app.php 中 providers 數組

Chenhua\MarkdownEditor\MarkdownEditorServiceProvider::class,
3、修改 config/app.php 中 aliases 數組

'MarkdownEditor' => Chenhua\MarkdownEditor\Facades\MarkdownEditor::class,
4、執行 artisan 命令,生成 config/markdowneditor.php 配置文件

php artisan vendor:publish --tag=markdown
5、修改 config/markdowneditor.php 配置文件

<?php
return [
    "default"     => 'local', //默認返回存儲位置url
    "dirver"      => ['local'], //存儲平臺 ['local', 'qiniu', 'aliyun']
    "connections" => [
        "local"  => [
            'prefix' => 'uploads/markdown', //本地存儲位置,默認uploads
        ],
        "qiniu"  => [
            'access_key' => '',
            'secret_key' => '',
            'bucket'     => '',
            'prefix'     => '', //文件前綴 file/of/path
            'domain'     => '' //七牛自定義域名
        ],
        "aliyun" => [
            'ak_id'     => '',
            'ak_secret' => '',
            'end_point'  => '',
            'bucket'    => '',
            'prefix'    => '',
        ],
    ],
];

 

接下來我們在/routes/web.php文件中添加:

Route::get('/markDown', function () {
    return view('markdown');
});

 在resources/views/目錄下面添加markdown.blade.php文件:

內容如下:

保存後,我們通過瀏覽器訪問:

 可以看到編輯器已經生成了,可以在編輯器裏面輸入內容就可以看到效果了,比如我輸入以下內容:

### 主要特性

- 支持“標準”Markdown / CommonMark和Github風格的語法,也可變身爲代碼編輯器;
- 支持實時預覽、圖片(跨域)上傳、預格式文本/代碼/表格插入、代碼摺疊、搜索替換、只讀模式、自定義樣式主題和多語言語法高亮等功能;
- 支持ToC(Table of Contents)、Emoji表情、Task lists、@鏈接等Markdown擴展語法;
- 支持TeX科學公式(基於KaTeX)、流程圖 Flowchart 和 時序圖 Sequence Diagram;
- 支持識別和解析HTML標籤,並且支持自定義過濾標籤解析,具有可靠的安全性和幾乎無限的擴展性;
- 支持 AMD / CMD 模塊化加載(支持 Require.js & Sea.js),並且支持自定義擴展插件;
- 兼容主流的瀏覽器(IE8+)和Zepto.js,且支持iPad等平板設備;
- 支持自定義主題樣式;

# Editor.md

![](https://pandao.github.io/editor.md/images/logos/editormd-logo-180x180.png)

![](https://img.shields.io/github/stars/pandao/editor.md.svg) ![](https://img.shields.io/github/forks/pandao/editor.md.svg) ![](https://img.shields.io/github/tag/pandao/editor.md.svg) ![](https://img.shields.io/github/release/pandao/editor.md.svg) ![](https://img.shields.io/github/issues/pandao/editor.md.svg) ![](https://img.shields.io/bower/v/editor.md.svg)

**目錄 (Table of Contents)**

[TOCM]

[TOC]

# Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6
# Heading 1 link [Heading link](https://github.com/pandao/editor.md "Heading link")
## Heading 2 link [Heading link](https://github.com/pandao/editor.md "Heading link")
### Heading 3 link [Heading link](https://github.com/pandao/editor.md "Heading link")
#### Heading 4 link [Heading link](https://github.com/pandao/editor.md "Heading link") Heading link [Heading link](https://github.com/pandao/editor.md "Heading link")
##### Heading 5 link [Heading link](https://github.com/pandao/editor.md "Heading link")
###### Heading 6 link [Heading link](https://github.com/pandao/editor.md "Heading link")

#### 標題(用底線的形式)Heading (underline)

This is an H1
=============

This is an H2
-------------

### 字符效果和橫線等
                
----

~~刪除線~~ <s>刪除線(開啓識別HTML標籤時)</s>
*斜體字*      _斜體字_
**粗體**  __粗體__
***粗斜體*** ___粗斜體___

上標:X<sub>2</sub>,下標:O<sup>2</sup>

**縮寫(同HTML的abbr標籤)**

> 即更長的單詞或短語的縮寫形式,前提是開啓識別HTML標籤時,已默認開啓

The <abbr title="Hyper Text Markup Language">HTML</abbr> specification is maintained by the <abbr title="World Wide Web Consortium">W3C</abbr>.

### 引用 Blockquotes

> 引用文本 Blockquotes

引用的行內混合 Blockquotes
                    
> 引用:如果想要插入空白換行`即<br />標籤`,在插入處先鍵入兩個以上的空格然後回車即可,[普通鏈接](http://localhost/)。

### 錨點與鏈接 Links

[普通鏈接](http://localhost/)

[普通鏈接帶標題](http://localhost/ "普通鏈接帶標題")

直接鏈接:<https://github.com>

[錨點鏈接][anchor-id]

[anchor-id]: http://www.this-anchor-link.com/

GFM a-tail link @pandao

> @pandao

### 多語言代碼高亮 Codes

#### 行內代碼 Inline code

執行命令:`npm install marked`

#### 縮進風格

即縮進四個空格,也做爲實現類似`<pre>`預格式化文本(Preformatted Text)的功能。

    <?php
        echo "Hello world!";
    ?>
    
預格式化文本:

    | First Header  | Second Header |
    | ------------- | ------------- |
    | Content Cell  | Content Cell  |
    | Content Cell  | Content Cell  |

#### JS代碼

```javascript
function test(){
    console.log("Hello world!");
}
 
(function(){
    var box = function(){
        return box.fn.init();
    };

    box.prototype = box.fn = {
        init : function(){
            console.log('box.init()');

            return this;
        },

        add : function(str){
            alert("add", str);

            return this;
        },

        remove : function(str){
            alert("remove", str);

            return this;
        }
    };
    
    box.fn.init.prototype = box.fn;
    
    window.box =box;
})();

var testBox = box();
testBox.add("jQuery").remove("jQuery");
```

#### HTML代碼 HTML codes

```html
<!DOCTYPE html>
<html>
    <head>
        <mate charest="utf-8" />
        <title>Hello world!</title>
    </head>
    <body>
        <h1>Hello world!</h1>
    </body>
</html>
```

### 圖片 Images

Image:

![](https://pandao.github.io/editor.md/examples/images/4.jpg)

> Follow your heart.

![](https://pandao.github.io/editor.md/examples/images/8.jpg)

> 圖爲:廈門白城沙灘

圖片加鏈接 (Image + Link):

[![](https://pandao.github.io/editor.md/examples/images/7.jpg)](https://pandao.github.io/editor.md/examples/images/7.jpg "李健首張專輯《似水流年》封面")

> 圖爲:李健首張專輯《似水流年》封面
                
----

### 列表 Lists

#### 無序列表(減號)Unordered Lists (-)
                
- 列表一
- 列表二
- 列表三
     
#### 無序列表(星號)Unordered Lists (*)

* 列表一
* 列表二
* 列表三

#### 無序列表(加號和嵌套)Unordered Lists (+)
                
+ 列表一
+ 列表二
    + 列表二-1
    + 列表二-2
    + 列表二-3
+ 列表三
    * 列表一
    * 列表二
    * 列表三

#### 有序列表 Ordered Lists (-)
                
1. 第一行
2. 第二行
3. 第三行

#### GFM task list

- [x] GFM task list 1
- [x] GFM task list 2
- [ ] GFM task list 3
    - [ ] GFM task list 3-1
    - [ ] GFM task list 3-2
    - [ ] GFM task list 3-3
- [ ] GFM task list 4
    - [ ] GFM task list 4-1
    - [ ] GFM task list 4-2
                
----
                    
### 繪製表格 Tables

| 項目        | 價格   |  數量  |
| --------   | -----:  | :----:  |
| 計算機      | $1600   |   5     |
| 手機        |   $12   |   12   |
| 管線        |    $1    |  234  |
                    
First Header  | Second Header
------------- | -------------
Content Cell  | Content Cell
Content Cell  | Content Cell

| First Header  | Second Header |
| ------------- | ------------- |
| Content Cell  | Content Cell  |
| Content Cell  | Content Cell  |

| Function name | Description                    |
| ------------- | ------------------------------ |
| `help()`      | Display the help window.       |
| `destroy()`   | **Destroy your computer!**     |

| Left-Aligned  | Center Aligned  | Right Aligned |
| :------------ |:---------------:| -----:|
| col 3 is      | some wordy text | $1600 |
| col 2 is      | centered        |   $12 |
| zebra stripes | are neat        |    $1 |

| Item      | Value |
| --------- | -----:|
| Computer  | $1600 |
| Phone     |   $12 |
| Pipe      |    $1 |
                
----

#### 特殊符號 HTML Entities Codes

&copy; &  &uml; &trade; &iexcl; &pound;
&amp; &lt; &gt; &yen; &euro; &reg; &plusmn; &para; &sect; &brvbar; &macr; &laquo; &middot;

X&sup2; Y&sup3; &frac34; &frac14;  &times;  &divide;   &raquo;

18&ordm;C  &quot;  &apos;

### Emoji表情 :smiley:

> Blockquotes :star:

#### GFM task lists & Emoji & fontAwesome icon emoji & editormd logo emoji :editormd-logo-5x:

- [x] :smiley: @mentions, :smiley: #refs, [links](), **formatting**, and <del>tags</del> supported :editormd-logo:;
- [x] list syntax required (any unordered or ordered list supported) :editormd-logo-3x:;
- [x] [ ] :smiley: this is a complete item :smiley:;
- [ ] []this is an incomplete item [test link](#) :fa-star: @pandao;
- [ ] [ ]this is an incomplete item :fa-star: :fa-gear:;
    - [ ] :smiley: this is an incomplete item [test link](#) :fa-star: :fa-gear:;
    - [ ] :smiley: this is  :fa-star: :fa-gear: an incomplete item [test link](#);
 
#### 反斜槓 Escape

\*literal asterisks\*
            
### 科學公式 TeX(KaTeX)
                    
$$E=mc^2$$

行內的公式$$E=mc^2$$行內的公式,行內的$$E=mc^2$$公式。

$$\(\sqrt{3x-1}+(1+x)^2\)$$
                    
$$\sin(\alpha)^{\theta}=\sum_{i=0}^{n}(x^i + \cos(f))$$

多行公式:

```math
\displaystyle
\left( \sum\_{k=1}^n a\_k b\_k \right)^2
\leq
\left( \sum\_{k=1}^n a\_k^2 \right)
\left( \sum\_{k=1}^n b\_k^2 \right)
```

```katex
\displaystyle
    \frac{1}{
        \Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{
        \frac25 \pi}} = 1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {
        1+\frac{e^{-6\pi}}
        {1+\frac{e^{-8\pi}}
         {1+\cdots} }
        }
    }
```

```latex
f(x) = \int_{-\infty}^\infty
    \hat f(\xi)\,e^{2 \pi i \xi x}
    \,d\xi
```
                
### 繪製流程圖 Flowchart

```flow
st=>start: 用戶登陸
op=>operation: 登陸操作
cond=>condition: 登陸成功 Yes or No?
e=>end: 進入後臺

st->op->cond
cond(yes)->e
cond(no)->op
```
                    
### 繪製序列圖 Sequence Diagram
                    
```seq
Andrew->China: Says Hello
Note right of China: China thinks\nabout it
China-->Andrew: How are you?
Andrew->>China: I am good thanks!
```

### End

 

保存後,可以看到:

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章