2024-09-03 01:15:56 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-09-03 21:56:07 +08:00
|
|
|
"C"
|
2024-11-12 04:09:27 +08:00
|
|
|
// "log"
|
2024-09-03 01:15:56 +08:00
|
|
|
|
2024-10-31 20:40:33 +08:00
|
|
|
md "github.com/tomkosm/html-to-markdown"
|
|
|
|
"github.com/tomkosm/html-to-markdown/plugin"
|
2024-09-03 01:15:56 +08:00
|
|
|
)
|
|
|
|
|
2024-09-03 21:56:07 +08:00
|
|
|
//export ConvertHTMLToMarkdown
|
|
|
|
func ConvertHTMLToMarkdown(html *C.char) *C.char {
|
2024-09-03 01:15:56 +08:00
|
|
|
converter := md.NewConverter("", true, nil)
|
|
|
|
converter.Use(plugin.GitHubFlavored())
|
|
|
|
|
2024-09-03 21:56:07 +08:00
|
|
|
markdown, err := converter.ConvertString(C.GoString(html))
|
2024-09-03 01:15:56 +08:00
|
|
|
if err != nil {
|
2024-11-12 03:53:21 +08:00
|
|
|
// log.Fatal(err)
|
2024-09-03 01:15:56 +08:00
|
|
|
}
|
2024-09-03 21:56:07 +08:00
|
|
|
return C.CString(markdown)
|
2024-09-03 01:15:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2024-09-03 21:56:07 +08:00
|
|
|
// This function is required for the main package
|
2024-09-03 01:15:56 +08:00
|
|
|
}
|