diff --git a/.travis.yml b/.travis.yml index 804f24a..002f045 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: go +go: "1.x" script: - make test - make generate-gh-pages diff --git a/README.org b/README.org index 2f0a017..aff6da2 100644 --- a/README.org +++ b/README.org @@ -1,5 +1,7 @@ * go-org [[https://travis-ci.org/niklasfasching/go-org.svg?branch=master]] -A basic org-mode parser in go. Take a look at [[https://niklasfasching.github.io/go-org/][github pages]] for some output examples. +A basic org-mode parser in go. +Take a look at [[https://niklasfasching.github.io/go-org/][github pages]] for some examples and an online org->html demo. + * next - checkboxes - definition lists diff --git a/etc/_wasm.go b/etc/_wasm.go new file mode 100644 index 0000000..e668a9f --- /dev/null +++ b/etc/_wasm.go @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + "strings" + "syscall/js" + + "github.com/niklasfasching/go-org/org" +) + +func main() { + js.Global().Call("initialized") + + document := js.Global().Get("document") + in := document.Call("getElementById", "input") + out := document.Call("getElementById", "output") + + js.Global().Set("run", js.NewCallback(func([]js.Value) { + in := strings.NewReader(in.Get("value").String()) + html, err := org.NewDocument().Parse(in).Write(org.NewHTMLWriter()) + if err != nil { + out.Set("innerHTML", fmt.Sprintf("
%s", err)) + } else { + out.Set("innerHTML", html) + } + })) + + <-make(chan struct{}) // stay alive +} diff --git a/etc/generate-gh-pages b/etc/generate-gh-pages index b0cadaf..ed613e5 100755 --- a/etc/generate-gh-pages +++ b/etc/generate-gh-pages @@ -1,7 +1,7 @@ #!/bin/bash org_files=org/testdata/*.org -content=" +examples="
language: go +go: "1.x" script: - make test - make generate-gh-pages