Methods
(async) WMd2html(fpIn, fpOut, optopt) → {Promise}
- Description:
Markdown檔轉Html檔
- Source:
Example
import w from 'wsemi'
import WMd2html from './src/WMd2html.mjs'
//import WMd2html from 'w-md2html/src/WMd2html.mjs'
//import WMd2html from 'w-md2html'
async function test() {
let fpIn = `./test/report.md`
let fpOut = `./test/report.html`
let opt = {
imgWidthMax: '500px',
funProcFpOut: (msg) => {
console.log('msg', msg)
return msg.fpOut
},
}
let r = await WMd2html(fpIn, fpOut, opt)
console.log(r)
// => ok
w.fsDeleteFile(fpOut)
}
test()
.catch((err) => {
console.log('catch', err)
})
Parameters:
| Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
fpIn |
String | 輸入來源Markdown檔位置字串 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fpOut |
String | 輸入轉出Html檔位置字串 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
opt |
Object |
<optional> |
{}
|
輸入設定物件,預設{} Properties
|
Returns:
回傳Promise,resolve回傳成功訊息,reject回傳錯誤訊息
- Type
- Promise
(async) md2html(md, optopt) → {Promise}
- Description:
Markdown轉Html
- Source:
Example
let markdown = `...`
md2html(markdown,{mergeStyle:true})
.then((res)=>{
console.log(res)
ele.innerHTML = res.html
})
.catch((err)=>{
console.log(err)
})
Parameters:
| Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
md |
String | 輸入Markdown字串 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
opt |
Object |
<optional> |
{}
|
輸入設定物件,預設{} Properties
|
Returns:
回傳Promise,resolve回傳轉換後物件,包含html、styleSrcs、styleDef,reject回傳錯誤訊息
- Type
- Promise