Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zhike-team/zhike-md-parser
used to parser md
https://github.com/zhike-team/zhike-md-parser
Last synced: 13 days ago
JSON representation
used to parser md
- Host: GitHub
- URL: https://github.com/zhike-team/zhike-md-parser
- Owner: zhike-team
- Created: 2016-12-07T11:16:01.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-13T09:30:53.000Z (about 7 years ago)
- Last Synced: 2025-01-20T22:36:43.366Z (14 days ago)
- Language: JavaScript
- Size: 43 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# 解析自定义标签为格式化数据
markdown自定义标签及规则参考产品整理的文件
## Demo
### use node```js
const MDParser = require('zhike-md-parser');
const mdParser = new MDParser({cdnCommon: '//xxx.xxx.com'});
let str = '{{paragraph}}\n{{time}}0.34/5.17{{end}}\n{{raw}}__You will hear a tutor and a student{{end}}'
+ '{{raw}}__You will hear a tutor and a student{{end}}{{trans}}{{end}}{{raw}}__You will hear a tutor and a student{{end}}{{end}}';
let mdRet = mdParser.parse(str, true, true);result:
{ start: 0.34,
end: 5.17,
raw: 'You will hear a tutor and a studentYou will hear a tutor and a student__You will hear a tutor and a student
',
trans: '' }
```### use browser
```
step: cd zhike-md-parser
npm i
node test/server
usage: http://localhost:8888/browser.html
```
## api### 1.MDParser(opts)
#### params+ cdnCommon e: {cdnCommon: 'http:xxx.xxx.com'} (如果md中有img标签,cdnCommon为图片cdn前缀地址)
### 2.mdParser.parse(mdStr, isCombine, toHtml);
#### params
+ mdStr md的字符串 string
+ isCombine 是否合并 boolean
+ toHtml 是否转为html boolean