环境
- 操作系统: Ubuntu 16.04
- Node: v7.0.0
- Express: 4.x
模块及样式
markdown解析工具 和 样式及语法高亮的插件有很多,比如解析工具还有markdown-js,语法高亮还有Google Code Prettify,等等。
这里我们只介绍使用其中的三个,作为一个组合。
- Markdown解析: marked v0.3.6
- Markdown-css: github-markdown-css
- 语法高亮: prismjs
Marked
A full-featured markdown parser and compiler, written in JavaScript. Built for speed.
这是它的github上的介绍,安装和基本使用在github上都有,我使用它的最新版本 v0.3.6。
用它来解析 markdown 语法。
Github-markdown-css
The minimal amount of CSS to replicate the GitHub Markdown style
用来给解析好的 html 加样式,这里有个使用它的示例: Demo
Prismjs
Prism is a lightweight, extensible syntax highlighter, built with modern web standards in mind. It’s used in thousands of websites, including some of those you visit daily.
它是一款轻量、可扩展的代码语法高亮库,使用现代化的 Web 标准构建的,同时支持大部分流行的编程语言,并且支持多种主题样式。使用起来也很简单,只需要在 html 中引入 css 和 js 文件即可。
我们可以根据需要自己在 Prismjs Download 中选择主题、语言和各种插件。
目录介绍
就是 express-generator 默认生成的目录,在根目录加了个 markdown 文件夹,里面放 .md
文