你知道一些markdown PHP
解析器,code highlight
等,就像GitHub
markdown解析器或https://stackedit.io/editor?Markdown - PHP解析器
如果它是可通過Composer
則更好。
我已經試過:
https://packagist.org/packages/michelf/php-markdown
https://packagist.org/packages/league/commonmark
https://packagist.org/packages/erusev/parsedown
但所有這些結果幾乎是純文本。
最好的結果屬於michelf/php-markdown
你可以下面的圖片上看到:
$ composer require michelf/php-markdown
---
use Michelf\MarkdownExtra;
$parser = new MarkdownExtra();
$html = $parser->transform($markdown);
echo $html;
[編輯1]
現在我幾乎是在我的目標。
我用:
https://github.com/sindresorhus/github-markdown-css
現在我得到非常相似GitHub
一個結果,但根據該代碼是沒有得到highlighted
(與colors
)的對應language
(在這種情況下:html
)爲您可以下面的圖片上看到:
然後我問題現在是:
什麼額外的步驟,我需要爲了得到代碼的語法高亮像GitHub上確實做的?請檢查下面的GitHub的輸出:
感謝,幫助很大。我做了一個** **編輯在我的崗位上面因爲現在是最後一步,我需要根據語言的語法顏色突出顯示的代碼。 – Angel
使用https://highlightjs.org語法高亮。 – ivoba
謝謝,這有幫助! – Angel