oremus

package module
v0.0.0-...-4c39076 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2024 License: MIT Imports: 10 Imported by: 0

README

LICENSE GoReportCard GoDoc

go-oremus

Go library to Fetch Passages from bible.oremus.org

Currently the fetch logic & parsing is not currently configurable. The result is an HTML block with most formatting removed.

About

https://bible.oremus.org provides the NRSV translation of the Bible. It does not have an API, but the webform results are easily parsed.

Unless you need the NRSV translation, this isn't the most appropriate package for your project.

If you need a general-purpose API or other translations, there are many alternatives:

https://scripture.api.bible (no NRSV) https://bible-api.com (no NRSV) https://www.rkeplin.com/the-holy-bible-open-source-rest-api/ (no NRSV) https://api.esv.org (ESV only) https://labs.bible.org/api_web_service (no NRSV) https://biblegateway.com (no general API) and countless others

Basic Example

result, err := oremus.Get("Genesis 1:1-5")
if err != nil {
	//
}
fmt.Println(result)

the package also includes tools to validate and normalize scripture references

CleanReference takes a string and returns a normalized string

result, err := oremus.CleanReference("gen 1:1-5")
if err != nil {
	//
}
fmt.Println(result)

Results in

Genesis 1:1-5

ParseReferences() takes a string and returns a slice of oremus.Reference objects, these can be iterated through and printed.

result, err := ParseReferences("gen 1:1-5;ex 4:1,7")
if err != nil {
	//
}
for _, v := range result {
	fmt.Println(v.String())
}

Results in

Genesis 1:1-5
Exodus 4:1,7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanReference

func CleanReference(in string) (string, error)

CleanReference takes a string, returns a normalized string for a semi-colon separated list of scripture references

func Get

func Get(ctx context.Context, ref string) (string, error)

Get fetches a passage from bible.oremus.org, parses the result and returns the text formatted as simple HTML

Types

type ChapVerse

type ChapVerse struct {
	StartVerseSuffix rune // a, b, f
	EndVerseSuffix   rune // a, b, f
	StartChapter     uint8
	StartVerse       uint8
	EndChapter       uint8
	EndVerse         uint8
}

ChapVerse is the chapter/verse portion of a reference "1:14-2:7a"

type Reference

type Reference struct {
	Book      string
	ChapVerse []ChapVerse
	Prefix    rune
}

Reference is the datastructure used for parsing/validating references

func ParseReference

func ParseReference(in string) (*Reference, error)

ParseReference parses a single free-form reference to a scripture passage and returns a *Reference use the stringer method to get a normalized string format back XXX This doesn't work for "Acts of the Apostles"

func ParseReferences

func ParseReferences(in string) ([]*Reference, error)

ParseReference parses a free-form reference to a scripture passage and returns a []*Reference use the stringer method to get a normalized string format back

func (*Reference) String

func (r *Reference) String() string

String returns a normalized reference to a scripture passage

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL