hi there, I’ve just tagged [email protected]:
https://codeberg.org/sbinet/daktilo https://pkg.go.dev/codeberg.org/sbinet/[email protected] It’s a Go package that uses a Cgo package wrapping a simple-minded FFI around a couple of Typst crates, mostly statically compiled. ``` import ( "bytes" "fmt" "log" "strings" "codeberg.org/sbinet/daktilo" ) func ExampleCompilePDF() { dst := new(bytes.Buffer) err := daktilo.CompilePDF(dst, strings.NewReader(` #set document( date: datetime(year:2009,month:11,day:10), author: "daktilo", ) #set page(width: 200pt, height: 300pt) #set text(font: "New Computer Modern", weight: 450) #show raw: set text(font: "New Computer Modern Mono", weight: 450) = H1 == H2 === H3 Hell·o from *Typ·st* and _Go_. $ sum_(k=1)^n k = (n(n+1)) / 2 $ List: - item a - item b Enumeration: + item a + item b *Bye.* `)) if err != nil { log.Fatal(err) } fmt.Printf("PDF: %d bytes.\n", len(dst.Bytes())) // Output: // PDF: 16694 bytes. } ``` There are also two commands provided with the current daktilo module: - cmd/daktilo that wraps daktilo.CompilePDF, - cmd/md2typ that converts a subset of Markdown (no raw-HTML support) to Typst, leveraging goldmark plugin machinery. I plan to expand a bit the exported Rust-FFI to allow producing PNGs and SVGs (and HTML once Typst-0.14.x is out), taking fonts from the system and better error reporting (right now, the error is exposed to Go as a dumb string). I am a very new Rust programmer so the plans above may not come to fruition just about now :) (also, if you have constructive criticism about my Rust style, I’ll gladly consider it, although I understand it "may not" be the best place to seek advice on Rust :P) I may split the module into a pure-Go one and a Cgo one (with the static library .a stored in, to improve the go-get'ability of daktilo) cheers, -s -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/DDOYTCKL8667.14FI102GERF3P%40cern.ch.
