使用Perfect-Markdown,表格的呈现方式不像GitHub的UI

时间:2019-05-17 19:48:23

标签: swift markdown perfect

我正在使用Perfect框架,并导入Perfect-Markdown来在REST服务的登录页面上呈现README.md。

简而言之,我正在尝试渲染看起来像这样的表:

| Tables        | Are           | Cool  |
| ------------- |:-------------:| -----:|
| col 3 is      | right-aligned | $1600 |
| col 2 is      | centered      |   $12 |
| zebra stripes | are neat      |    $1 |

我的处理程序是:

func handler(request: HTTPRequest, response: HTTPResponse) {
    response.setHeader(.contentType, value: "text/html")
    let source = getSourceDir(for: #file)
    let data = FileManager.init().contents(atPath: "\(source)README2.md")
    let string = String.init(data: data!, encoding: .utf8)
    let html = string?.markdownToHTML
    response.appendBody(string: html!)
    response.completed()
}

getSourceDir()只是在项目中应用文件的路径。

我真的希望该表显示与GitHub UI一样,但是该表显示如下:

Tables  Are Cool
col 3 is    right-aligned   $1600
col 2 is    centered    $12
zebra stripes   are neat    $1

没有“桌子”可言...

0 个答案:

没有答案