Go package for parsing a raw string into a tree of typed(-ish) nodes (that can also construct the original string again)
Find a file
2025-05-02 15:24:11 +02:00
coverage_badge.png Fix parser invalid results, add tests, readme 2025-05-02 15:18:14 +02:00
go.mod Fix parser invalid results, add tests, readme 2025-05-02 15:18:14 +02:00
go.sum Fix parser invalid results, add tests, readme 2025-05-02 15:18:14 +02:00
informer.go Implementation should be good like this. TODO: Tests 2025-04-23 17:33:11 +02:00
informer_test.go Fix parser invalid results, add tests, readme 2025-05-02 15:18:14 +02:00
LICENSE Fix license year 2025-05-02 15:24:11 +02:00
node.go Batman 2025-04-23 16:18:24 +02:00
node_test.go Fix parser invalid results, add tests, readme 2025-05-02 15:18:14 +02:00
parser.go Fix parser invalid results, add tests, readme 2025-05-02 15:18:14 +02:00
parser_test.go Fix parser invalid results, add tests, readme 2025-05-02 15:18:14 +02:00
README.md Fix parser invalid results, add tests, readme 2025-05-02 15:18:14 +02:00

Treeificator

Go Coverage license Go Documentation GoDoc

A small module to turn a string into a tree of nodes based on a list of informers.

How to use

First import the module go get git.mstar.dev/mstar/treeificator

Then define the informers for the beginning and end of each node type you want

type PInformer struct{}

// The prefix starting a block of type PInformer
func (p *PInformer) GetPrefix() string {
  return "<p>"
}

// The suffix ending a block of type PInformer
func (p *PInformer) GetSuffix() string {
  return "</p>"
}

// The name of PInformer
func (p *PInformer) GetName() string {
  return "p-element"
}

And finally parse any string

import "git.mstar.dev/mstar/treeificator"

treeRoot := treeificator.Marshal(yourString, &PInformer{})

See documentation for more details