From 31343185e6358c33fe33a920e4c338b0106beb28 Mon Sep 17 00:00:00 2001 From: Cameron Chunn Date: Thu, 5 Oct 2023 00:19:01 -0500 Subject: [PATCH 1/2] Stubbed out initital work for markdown format of everything --- CHANGES.md | 12 +++++++++--- README.md | 11 +++++++++-- bible/bible.go | 16 ++++++++-------- bible/book.go | 8 ++++---- bible/chapter.go | 16 ++++++++-------- bible/formatting.go | 14 ++++++++++++++ bible/verse.go | 36 +++++++----------------------------- 7 files changed, 59 insertions(+), 54 deletions(-) create mode 100644 bible/formatting.go diff --git a/CHANGES.md b/CHANGES.md index 6972ae2..30eee71 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,8 +1,14 @@ -# 1.1.1 +# Changes + +## 1.1.1 + - Added additional meta data to bible objects -# 1.1.0 + +## 1.1.0 + - Added ability to load bibles from bible.Bible objects with `GoBible.LoadObject()` method - Added `bible.Bible.ToJSON()` method to convert a bible.Bible object to JSON -# 1.0.0 +## 1.0.0 + - Initial Release \ No newline at end of file diff --git a/README.md b/README.md index d9a7859..cb01fb4 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,18 @@ Gobible is a library for interacting with the Bible in Go. Initially, Gobible was created as an effort to support an easy to use JSON format for the Bible for use in other projects, but through development has grown to instead be a library for working with that format, as well and importing other formats into the Gobible format. ### Supported Formats -- Gobible JSON [Example](https://raw.githubusercontent.com/gobible/gobible/master/data/WEB.json) +- Gobible JSON [Example](https://raw.githubusercontent.com/gobible/gobible/master/data/KJV.json) - OSIS XML [Example](https://raw.githubusercontent.com/gobible/gobible/master/data/WEB.xml) +Please note that since Gobible works around a data structure defined by the Gobible JSON format, some features or formatting of other formats may not be fully supported. -Please note that since Gobible works around a data structure defined by the Gobible JSON format, some features of other formats may not be supported. +### Rich Text + +Rich text is stored in an extended version of Markdown, with some additional features -- specifically `small-caps` and `red-letter` text. + +```markdown +example here +``` ## Usage diff --git a/bible/bible.go b/bible/bible.go index cd2522c..7468aac 100644 --- a/bible/bible.go +++ b/bible/bible.go @@ -14,17 +14,17 @@ type Bible struct { // Version holds the name and abbreviation of the bible version type Version struct { - Name string `json:"name"` - Abbrev string `json:"abbrev"` - Publisher string `json:"publisher"` - Copyright string `json:"copyright"` - Language string `json:"language"` + Name string `json:"name"` + Abbrev string `json:"abbrev"` + Publisher BibleMarkdown `json:"publisher"` + Copyright BibleMarkdown `json:"copyright"` + Language string `json:"language"` } type Extra struct { - Preface string `json:"preface"` // Markdown Preface - Foreword string `json:"foreword"` // Markdown Forword - About string `json:"about"` // Markdown About + Preface BibleMarkdown `json:"preface"` // Markdown Preface + Foreword BibleMarkdown `json:"foreword"` // Markdown Forword + About BibleMarkdown `json:"about"` // Markdown About } // GetBook returns a pointer to a Book struct by the name of the book diff --git a/bible/book.go b/bible/book.go index f3614f4..3564e0a 100644 --- a/bible/book.go +++ b/bible/book.go @@ -2,10 +2,10 @@ package bible // Book holds the name and chapters of a book type Book struct { - Number int `json:"number"` - Name string `json:"name"` - Notes string `json:"notes"` // translation notes that might be relevant to store - Chapters []Chapter `json:"chapters"` + Number int `json:"number"` + Name string `json:"name"` + Notes BibleMarkdown `json:"notes"` // translation notes that might be relevant to store + Chapters []Chapter `json:"chapters"` } func (b *Book) GetName() string { diff --git a/bible/chapter.go b/bible/chapter.go index efd2187..f773083 100644 --- a/bible/chapter.go +++ b/bible/chapter.go @@ -2,12 +2,12 @@ package bible // Chapter holds the number and verses of a chapter type Chapter struct { - Number int `json:"number"` - Name string `json:"name"` - Title string `json:"title,omitempty"` - Content string `json:"content,omitempty"` // optional content that is not a verse, in markdown format - Notes string `json:"notes,omitempty"` // optional notes that are not a verse, in markdown format - Verses []Verse `json:"verses"` + Number int `json:"number"` + Name string `json:"name"` + Title BibleMarkdown `json:"title,omitempty"` + Content BibleMarkdown `json:"content,omitempty"` // optional content that is not a verse, in markdown format + Notes BibleMarkdown `json:"notes,omitempty"` // optional notes that are not a verse, in markdown format + Verses []Verse `json:"verses"` } func (c *Chapter) GetVerseCount() int { @@ -35,12 +35,12 @@ func (c *Chapter) GetVerses(start, end int) []Verse { } // Set chapter title -func (c *Chapter) SetTitle(title string) { +func (c *Chapter) SetTitle(title BibleMarkdown) { c.Title = title } // Set verse text, optionally adding the verse if its missing -func (c *Chapter) SetVerse(number int, text string) { +func (c *Chapter) SetVerse(number int, text BibleMarkdown) { for k := range c.Verses { verse := &c.Verses[k] if verse.Number == number { diff --git a/bible/formatting.go b/bible/formatting.go new file mode 100644 index 0000000..af2e4d0 --- /dev/null +++ b/bible/formatting.go @@ -0,0 +1,14 @@ +package bible + +type BibleMarkdown string + +// Removes all formatting from the text and returns a string +func (b BibleMarkdown) Text() string { + return "" +} + +// Returns the text in HTML format +func (b BibleMarkdown) HTML() string { + + return "" +} diff --git a/bible/verse.go b/bible/verse.go index 152cae2..a5e06c7 100644 --- a/bible/verse.go +++ b/bible/verse.go @@ -2,36 +2,14 @@ package bible // Verse holds the number and text of a verse type Verse struct { - Number int `json:"number"` - Text string `json:"text"` - Footnotes []Footnote `json:"footnotes,omitempty"` // optional - Formatting []Formatting `json:"formatting,omitempty"` // optional -} - -func (v *Verse) SetText(text string) { - v.Text = text + Number int `json:"number"` + Text BibleMarkdown `json:"text"` + Footnotes []Footnote `json:"footnotes,omitempty"` // optional } +// Footnote holds the text and location of a footnote type Footnote struct { - Marker string `json:"number"` - Text string `json:"text"` - Start int `json:"start"` - End int `json:"end"` -} - -type FormattingType string - -// define valid FormattingType values -const ( - FormatBold FormattingType = "bold" - FormatItalic FormattingType = "italic" - FormatUnderline FormattingType = "underline" - FormatRedLetter FormattingType = "red-letter" - FormatSmallCaps FormattingType = "small-caps" -) - -type Formatting struct { - Type FormattingType `json:"type"` - Start int `json:"start"` - End int `json:"end"` + Text BibleMarkdown `json:"text"` + Start int `json:"start"` + End int `json:"end"` } From 47a89ade3427c544e378c1a0622a29d8425edbad Mon Sep 17 00:00:00 2001 From: Cameron Chunn Date: Thu, 5 Oct 2023 00:19:37 -0500 Subject: [PATCH 2/2] note in changes --- CHANGES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 30eee71..5142167 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Changes +## 1.2.0 + +- All richtext fields are now stored as our extended Markdown Format + ## 1.1.1 - Added additional meta data to bible objects