Skip to content

Commit

Permalink
fix: update usage example
Browse files Browse the repository at this point in the history
  • Loading branch information
radulucut committed Jul 31, 2024
1 parent 42354fd commit 0ba02c6
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,28 @@ HTML-like DSL that that can be converted into HTML.
package main

import (
"fmt"
"github.com/radulucut/htnoml"
"os"

"github.com/radulucut/htnoml"
)

func main() {
f, err := os.Open("example.htnoml")
if err != nil {
panic(err)
}
defer f.Close()

p, err := NewParser(f)
if err != nil {
panic(err)
}

w := new(bytes.Buffer)
p.ToHTML(w) // writes the HTML to the buffer
f, err := os.Open("example.htnoml")
if err != nil {
panic(err)
}
defer f.Close()

p, err := htnoml.NewParser(f)
if err != nil {
panic(err)
}

o, err := os.Create("example.html")
if err != nil {
panic(err)
}
defer o.Close()
p.ToHTML(o) // writes the HTML to the buffer
}
```

0 comments on commit 0ba02c6

Please sign in to comment.