Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jeffwcx/extendown

A extendable, lightweight, github compatible markdown compiler!
https://github.com/jeffwcx/extendown

javascript markdown parser

Last synced: about 1 month ago
JSON representation

A extendable, lightweight, github compatible markdown compiler!

Awesome Lists containing this project

README

        

[![TravisCi Build](https://img.shields.io/travis/jeffwcx/extendown.svg)](https://travis-ci.org/jeffwcx/extendown)
[![Coverage Status](https://img.shields.io/coveralls/jeffwcx/extendown/master.svg)](https://coveralls.io/github/jeffwcx/extendown?branch=master)
[![MIT](https://img.shields.io/npm/l/extendown.svg)](https://github.com/jeffwcx/extendown/blob/master/LICENSE)
[![Version](https://img.shields.io/npm/v/extendown.svg)](https://www.npmjs.com/package/extendown)
## extendable markdown compiler

## Features

+ Extenable
+ Github Mardown Syntax

## Usage
### 1. install it by npm
```
npm install extendown
```
### 2. use it in nodejs or browser
The libray is packaged in UMD, you can import it in ES6 modules, CommonJS, AMD, etc.

### 3. how to use

```javascript
import Extendown from 'extendown';

const parse = Extendown.parse;
parse(YourMarkdownString);
```

### 4. how to extend
the following code is extend a inline feature
```javascript
const parse = Extendown.parse;
const extend = Extendown.extend;
const feature = {
reg: '==(.+?)==',
process(section) {
return section.replace(new RegExp(feature.reg, 'g'),
'$1');
},
}
extend(Extdown.INLINE, feature);
parse('==color==');
//

color


```
the following code is extend a block feature
```javascript
const feature = {
reg: '(?:^|\\n)@@\\n((?:[^@]*\\n)?)@@(?=\\n|$)',
process(section) {
return section.replace(new RegExp(feature.reg, 'g'), (match, g1) => {
return `${g1}`
});
},
};
extend(Extdown.BLOCK, feature);
parse(`@@

here is your article


@@`);
//

here is your article

\n
```

### 5. how to config
The most config is for emoji, we will provide more config in future.

You can change emoji image's url in following ways.
1. change base path
```javascript
config.emoji.path = 'https://dn-phphub.qbox.me/assets/images/emoji/';
```
2. change extension
```javascript
config.emoji.ext = 'gif';
```
3. change your format function

```javascript
config.emoji.nameFormat = function(name) {
return `${name}test`;
};
```

## Basic Syntax

Refer to Github Markdown

## refenrence
+ [Markdown: Syntax](http://daringfireball.net/projects/markdown/syntax)

+ [Basic writing and formatting syntax](https://help.github.com/articles/basic-writing-and-formatting-syntax)