From b2bde9bf78926c867a8423c07ad9ba20f98b118b Mon Sep 17 00:00:00 2001 From: "Benjamin A. Shelton" Date: Sun, 21 Jun 2026 15:29:48 -0600 Subject: [PATCH] Added parser. --- go.mod | 20 ++++ go.sum | 48 ++++++++++ main.go | 277 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 345 insertions(+) create mode 100644 go.mod create mode 100644 go.sum create mode 100644 main.go diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..c0c256a --- /dev/null +++ b/go.mod @@ -0,0 +1,20 @@ +module git.destrealm.org/zancarius/sundays + +go 1.26.3 + +require ( + git.destrealm.org/go/capstan v0.0.0-20241020013023-152fb4231d4e // indirect + git.destrealm.org/go/cryptohelper v0.0.0-20211103023304-eafe2acf8fc2 // indirect + git.destrealm.org/go/errors v1.3.1 // indirect + git.destrealm.org/go/logging/v2 v2.3.1 // indirect + git.destrealm.org/go/signals/v2 v2.2.0 // indirect + git.destrealm.org/go/vfs v0.0.0-20211019061313-07ffa809d4c8 // indirect + github.com/flosch/pongo2/v4 v4.0.2 // indirect + github.com/fsnotify/fsnotify v1.5.1 // indirect + github.com/go-chi/chi/v5 v5.0.4 // indirect + github.com/gorilla/websocket v1.4.2 // indirect + golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect + golang.org/x/sys v0.0.0-20211004093028-2c5d950f24ef // indirect + kernel.org/pub/linux/libs/security/libcap/cap v1.2.69 // indirect + kernel.org/pub/linux/libs/security/libcap/psx v1.2.69 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..ed40cc7 --- /dev/null +++ b/go.sum @@ -0,0 +1,48 @@ +git.destrealm.org/go/capstan v0.0.0-20241020013023-152fb4231d4e h1:MwAIDkX6PCjyylwG7th66nJoFnjhJqAAkeqUXz4ifuo= +git.destrealm.org/go/capstan v0.0.0-20241020013023-152fb4231d4e/go.mod h1:38opG+fyMm+WJSm6ZEWuo2vtGy3cwCA+X6tYlUQkpko= +git.destrealm.org/go/cryptohelper v0.0.0-20211103023304-eafe2acf8fc2 h1:cmNqjfMnvNrFYX/OCI88stlrnCNsumXmNbM0WdSPiMc= +git.destrealm.org/go/cryptohelper v0.0.0-20211103023304-eafe2acf8fc2/go.mod h1:o56aklqGh9x5Nt6E43+hp55liokI3KBJzPuTe1/WOlI= +git.destrealm.org/go/errors v1.3.1 h1:nINk49XtF9ffD5cb4vbB63tuvWiKjvpReZ5BGrpcA90= +git.destrealm.org/go/errors v1.3.1/go.mod h1:a9gTpEl10AxWOQCL6BoRrQg4O7RnP1OJcY5JJm1oXNA= +git.destrealm.org/go/headr v0.0.0-20220222231429-3c33e6559b09/go.mod h1:qltyhiVUC6ZBoDjH9mRfgtOVkZPkkejsPHmI6B/cna0= +git.destrealm.org/go/libkeystar v0.0.0-20241020012936-be87bd226f67/go.mod h1:LUUk40RyhIANN8Ebpba29cPu7CTx2cibQzP9LT7ubPI= +git.destrealm.org/go/logging/v2 v2.3.1 h1:+bPXhPtRz+EB5EsAU+7RglajkPczfZz+p3sMZpmKESM= +git.destrealm.org/go/logging/v2 v2.3.1/go.mod h1:cJJOOfkOkl/IpKYFvdfyBoO7TWc3M+gEk+51WWMhKw8= +git.destrealm.org/go/please v1.1.0/go.mod h1:Ny+9MjPPIDhSU6aFhBBAmvFeQyyiQjCbQrfiVHA6QIk= +git.destrealm.org/go/principal v0.0.0-20211106062354-8acf5a80c041/go.mod h1:wvO+xMR6ngKDyvbyk+W3rykTMxhxM2JFhdbcyZen0AI= +git.destrealm.org/go/signals/v2 v2.2.0 h1:dr+keHWDWg2Y/wXnYS8mS0DcXZsFbjIhS6LCsKEyE1k= +git.destrealm.org/go/signals/v2 v2.2.0/go.mod h1:sr/FUucf/fpKEWuR2riA/Pfg5S3THGy24KnEtVSw2ds= +git.destrealm.org/go/tokenizr v0.0.0-20220226050314-216fe0f97f8a/go.mod h1:s+0pXDtaXIsC89LyqfEp7qb8exjutZA1kNBCkrK2yUA= +git.destrealm.org/go/vfs v0.0.0-20211019061313-07ffa809d4c8 h1:gKatgJze4JxPW+LzKHNXZrqdwj09KqE5TUZ0qaRyPvE= +git.destrealm.org/go/vfs v0.0.0-20211019061313-07ffa809d4c8/go.mod h1:q9J7c5JMGMDvvpigodXW3MTsj0CHr0wfCZ7bhAFVzh8= +github.com/flosch/pongo2/v4 v4.0.2 h1:gv+5Pe3vaSVmiJvh/BZa82b7/00YUGm0PIyVVLop0Hw= +github.com/flosch/pongo2/v4 v4.0.2/go.mod h1:B5ObFANs/36VwxxlgKpdchIJHMvHB562PW+BWPhwZD8= +github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= +github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= +github.com/go-chi/chi/v5 v5.0.4 h1:5e494iHzsYBiyXQAHHuI4tyJS9M3V84OuX3ufIIGHFo= +github.com/go-chi/chi/v5 v5.0.4/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= +github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20211005215030-d2e5035098b3/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211004093028-2c5d950f24ef h1:fPxZ3Umkct3LZ8gK9nbk+DWDJ9fstZa2grBn+lWVKPs= +golang.org/x/sys v0.0.0-20211004093028-2c5d950f24ef/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +kernel.org/pub/linux/libs/security/libcap/cap v1.2.69 h1:N0m3tKYbkRMmDobh/47ngz+AWeV7PcfXMDi8xu3Vrag= +kernel.org/pub/linux/libs/security/libcap/cap v1.2.69/go.mod h1:Tk5Ip2TuxaWGpccL7//rAsLRH6RQ/jfqTGxuN/+i/FQ= +kernel.org/pub/linux/libs/security/libcap/psx v1.2.69 h1:IdrOs1ZgwGw5CI+BH6GgVVlOt+LAXoPyh7enr8lfaXs= +kernel.org/pub/linux/libs/security/libcap/psx v1.2.69/go.mod h1:+l6Ee2F59XiJ2I6WR5ObpC1utCQJZ/VLsEbQCD8RG24= diff --git a/main.go b/main.go new file mode 100644 index 0000000..17bc26e --- /dev/null +++ b/main.go @@ -0,0 +1,277 @@ +package main + +import ( + "encoding/json" + "encoding/xml" + "errors" + "fmt" + "io" + "os" +) + +type node struct { + Type string `json:"type"` + Version string `json:"version,omitempty"` + Caller string `json:"caller,omitempty"` + Content json.RawMessage `json:"content"` + Code string `json:"code,omitempty"` + Marker string `json:"marker,omitempty"` + Number string `json:"number,omitempty"` +} + +type chapter struct { + Number int + Verses []*verse + Titles *textGroup +} + +type verse struct { + Number int + TextGroup *textGroup +} + +type textGroup struct { +} + +type Document struct { + USX *USX `xml:"usx"` + Book *Book `xml:"book"` + Meta []*Para `xml:"para"` +} + +type USX struct { + Version string `xml:"version,attr"` +} + +type Book struct { + Style string `xml:"style,attr"` + Code string `xml:"code,attr"` + Content string `xml:"chardata"` +} + +type Chapter struct { + Style string `xml:"style,attr"` + Number int `xml:"number,attr"` +} + +type Para struct { + Style string `xml:"style,attr"` +} + +type usxMeta struct { + Version string + H string + TOC1 string + TOC2 string + TOC3 string + MT1 string + MT2 string +} + +type usxDoc struct { + Book *usxBook + Meta *usxMeta +} + +type usxBook struct { + Style string `xml:"style,attr"` + Code string `xml:"code,attr"` + Info string `xml:"chardata"` + Chapters []*usxChapter `xml:"-"` +} + +type usxChapter struct { + XMLName xml.Name `xml:"chapter"` + Number int `xml:"number,attr"` + Style string `xml:"style,attr"` + Para []*usxPara `xml:"-"` +} + +type usxPara struct { + XMLName xml.Name `xml:"para"` + Style string `xml:"style,attr"` + Content string `xml:",chardata"` + Refs []*usxRef `xml:"ref"` + Verses []*usxVerse `xml:"verse"` +} + +type usxRef struct { + XMLName xml.Name `xml:"ref"` + Loc string `xml:"loc,attr"` + Content string `xml:",chardata"` +} + +type usxVerse struct { + XMLName xml.Name `xml:"verse"` + Style string `xml:"style,attr"` + Number int `xml:"number,attr"` + Content string `xml:",chardata"` + Notes []*usxNote `xml:"note"` +} + +type usxNote struct { + Style string `xml:"style,attr"` + Caller string `xml:"caller,attr"` + Chars []*usxChar `xml:"char"` +} + +type usxChar struct { + Style string `xml:"style,attr"` + Content string `xml:",chardata"` +} + +// Convert USX to S2F (Structured Scripture Format). +func usxToS2f() { + +} + +type sm struct { + version string + + // Are we actually processing the XML document? Requires valid processing instructions (