npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

koa-md

v0.0.1

Published

A middleware to change markdown to html with code highlight

Downloads

2

Readme

koa-md

koa-md是一个koa中间件,可用于将markdown文件转换为HTML,并提供代码高亮功能

##EXAMPLE ###Hello 使用npm install koa安装koa,npm install koa-md安装koa-md,新建一个文件app.js,内容如下:

var koa = require('koa');
var md = require('koa-md');
var app = koa();

app.use(md({
	//koa-md配置信息
}));

app.listen(4000);

node --harmony app.js启动服务器后查看localhost:4000/index.md。koa-md会对所有.md.markdown.mdown的进行处理,若请求带参数?raw=true则会返回markdown文件源代码

###Markdown站点 koa-md能够通过修改配置,快速构建Markdown查看站点:

如有两个含有markdown文件的文件夹,路径分比为/dir1/dir2,则将app.js修改如下:

var koa = require('koa');
var md = require('koa-md');
var app = koa();

app.use(md({
  path: [{
  	label: "第一个文件夹",
  	dir: "/dir1"
  }, {
  	label: "第二个文件夹",
  	dir: "/dir2"
  }],
  contentOnly: false
}));

app.listen(4000);

即可搭建一个浏览markdown文件的站点,鼠标悬停左上角能看到目录下含有的所有markdown文件,并提供链接。若文件夹中存在index.md,将作为目录的链接

##OPTIONS ###contentOnly Boolean类型,是否只传输markdown内容,若为false,则构建markdown站点

###path Array类型,构建markdown站点时包含markdown文件的文件夹列表,每项包含两个属性:

  1. label:字符串,构建站点时右上角显示的文件夹标识
  2. dir:字符串,文件夹的绝对路径

###highlight Boolean类型,是否开启代码高亮

###highlightStyle String类型,若开启代码高亮,代码高亮的样式,目前可以取值为highlight.js的所有高亮样式,详细见highlight.js官方文档

默认为github,样式会使用<style>标签写入到页面中

###customCSS Array类型,仅在开启markdown站点时有效,表示使用自定义样式,每一项为一个字符串,为样式文件的路径,会通过<link>标签添加到页面中。

若配置为[],将不添加任何样式

若不进行配置,则会自动添加node_modules/koa-md/assets/css/typo.cssnode_modules/assets/css/style.css,会通过<style>标签添加到页面中

###index String类型,构建markdown站点时/index.md显示的内容,默认为node_modules/koa-md/assets/md/index.md

###error String类型,构建markdown站点时,文件未找到时显示的内容,默认为node_modules/koa-md/assets/md/error.md

##LICENSE MIT