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

md-js

v1.0.5

Published

A markdown parser

Downloads

11

Readme

Mdjs

Build Status

Mdjs is a lightweight Markdown parser for JavaScript (一个轻量级的 Markdown 解析器)
Demo: http://hangxingliu.github.io/mdjs.editor/
Mdjs.editor: Github Git@OSC


Latest version (目前版本)

1.0.5

2021-11-05

  • 修复了URL转译问题
  • 修复了链接的title的问题
  • 修复了HTML注释的问题

更多更新日志请参阅: CHANGELOG.md

Usage (使用)

Web frontend (Web 前端)

<!-- 不依赖其他任何库,仅一个脚本文件即可 -->
<script src="mdjs.min.js" type="text/javascript" charset="utf-8"></script>
//方法一
var html = Mdjs.md2html(markdownText);
//方法二
var mdjs = new Mdjs();
var html = mdjs.md2html(markdownText);

Node.js

npm i md-js
//方法一
var Mdjs = require('md-js');
var html = Mdjs.md2html(markdownText);
//方法二
var Mdjs = require('md-js').Mdjs;
var mdjs = new Mdjs();
var html = mdjs.md2html(markdownText);

Options for parser (配置解析选项)

var mdjs = new Mdjs();
var html = mdjs.md2html(markdownText, {
	//markdown 文本中表示段落的每行行末都加入 换行标签<br/>
	alwaysNewline: false
});

Custom render rules (自定义渲染规则)

//创建自定义渲染器类
var myRender = new Mdjs.MdjsRenderer();
//配置自定义引用区块的HTML标签
myRender.tag.quote = ['<div class="blockquote">', '</div>'],
//配置自定义邮箱部分的 HTML 生成函数
myRender.func.email = function(email){
	return '<a href="mailto:' + email + '">' + email + '</a>';
};
//自定义链接参考式
myRender.addRefLinkProvider(function(referName) {
	return { url: 'https://github.com/' + referName };
});
var mdjs = new Mdjs(myRender);
var html = mdjs.md2html(markdownText);

更多自定义渲染规则请参阅: CUSTOM_RENDER.md

Features (语法支持)

目前广泛使用的的Markdown语法都能被解析, 额外支持的语法还有:

  • 脚注
  • 表格
  • [toc]

暂不支持的语法和功能:

  • 选项框
  • 流程图,时序图和LaTeX公式
  • 代码块的高亮

Maintenance manual (开发维护手册)

参考学习或开发维护可参考文档: DEVELOP_MANUAL.md

Author (作者)

@hangxingliu (Liu Yue)
Github
码云Gitee

License (开源协议)

Apache Licence 2.0