在 Go 中将 C 和 Python 代码串在一起?
我正在尝试创建一个简单的 Go 函数,该函数只需在 reddit 风格的 Markdown 字符串中并返回适当的 HTML。
现在,我知道安装 Discount 是先决条件,并且reddit 至少使用以下三个文件作为 Discount 的包装器:
https://github.com/reddit /reddit/blob/master/r2/r2/lib/c/reddit-discount-wrapper.c
https://github.com/reddit/reddit/blob/master /r2/r2/lib/c_markdown.py
https://github.com/reddit/reddit/blob/master /r2/r2/lib/py_markdown.py
基于此,有谁知道我如何将所有这些与 Cgo 和 go-python 创建一个简单的 Markdown 函数? (独立于 Reddit 源代码的其余部分)
I'm trying to create a simple Go function which will simply take in a string of reddit-style Markdown and return the appropriate HTML.
Right now, I know that having Discount installed is a prerequisite and that at least the following three files are used by reddit as wrappers around Discount:
https://github.com/reddit/reddit/blob/master/r2/r2/lib/c/reddit-discount-wrapper.c
https://github.com/reddit/reddit/blob/master/r2/r2/lib/c_markdown.py
https://github.com/reddit/reddit/blob/master/r2/r2/lib/py_markdown.py
Based on this, does anyone know how I can sort of glue all this together with Cgo and go-python to create a simple Markdown function? (independent of the rest of the reddit source code)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你想要的只是 Markdown,我不明白 Python 如何适应这个。也许还有更多内容,但如果可能的话,您应该将 Python 排除在外。如果问题中没有提到使用 Python 的原因,我可以编辑这个答案并解决这个问题。
首先,尝试这个原生 Go Markdown 包: https://github.com/knieriem/markdown
如果没有不起作用,下一个最简单的方法是采用 Discount (或任何其他用 C 编写的 Markdown 库,例如 GitHub 的 Upskirt fork )并用 cgo 或 SWIG 包装它。
If all you want is Markdown, I don't see how Python fits into this. Maybe there's more to it, but if at all possible you should leave Python out of this. If there's a reason to use Python that wasn't in the question, I can edit this answer and address that.
First, try this native Go Markdown package: https://github.com/knieriem/markdown
If that doesn't work, the next easiest thing is to take Discount (or any other Markdown library written in C, such as GitHub's Upskirt fork) and wrap it with cgo or SWIG.