alanshaw / alanshaw/markdown-pdf

Render problem with new lines

未关闭
#183 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
JavaScript
星标
2.9k
派生
253
PR 合并指标
30 天内没有已合并 PR

描述

Hi everyone,
I try to convert this string:
`
**Hi**\n##This is a title
`
into a PDF. But the result is:
![image](https://user-images.githubusercontent.com/8190931/75465636-33a40400-5989-11ea-8c09-1b2060c7d67d.png)

Seems **\n** are not parsed.

My code is:
```
/**
* Convert markdown string to buffer
*
* @param {String} body The Content body
* @returns {Promise}
*/
const asMarkdown = body => {
const markdownpdf = require('markdown-pdf')
console.log(body)
return new Promise((resolve, reject) => {
return markdownpdf()
.from.string(body)
.to.buffer({}, (err, buffer) => {
if (err) {
reject(err)
} else {
resolve(buffer)
}
})
})
}
```

There is something missing in my code (for example in options buffer) or the issue is another?
I've take inspiration from the example in the README project directory:

```
var markdownpdf = require("markdown-pdf")

var md = "foo===\n* bar\n* baz\n\nLorem ipsum dolor sit"
, outputPath = "/path/to/doc.pdf"

markdownpdf().from.string(md).to(outputPath, function () {
console.log("Created", outputPath)
})
```

with the difference that my output is a buffer and not a path file.

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。