Comments (1)
After playing with this, I've realized it would be substantially easier to store all formattable fields as a custom Markdown
string.
The library will provide helpers to return plain text as well as HTML markup from the markdown stored in the fields.
Leaving these here so I can decide next time I pick it up:
type BibleMarkdown string
// Removes all formatting from the text and returns a string
func (b BibleMarkdown) Text() string {
// TODO: implement
return ""
}
// Returns the text in HTML format
func (b BibleMarkdown) HTML() string {
// TODO: implement
return ""
}
// -----
// Verse holds the number and text of a verse
type Verse struct {
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 {
Text BibleMarkdown `json:"text"`
Start int `json:"start"`
End int `json:"end"`
}
So the output would be similar to this. (I have yet to decide how small caps will be marked inline, but I used +
for the example)
{
"number": 17,
"text": "For in it _the_ righteousness of God is revealed from faith to faith; as it is written, \"+But the righteous will live by faith.+\"",
"footnotes": [
{
"marker": "a",
"text": "Or _by_",
"start": 31,
"end": 35
},
{
"marker": "b",
"text": "Or _But he who is righteous by faith shall live_",
"start": 70,
"end": 106
}
]
}
And then ...
PlainText()
would return:
For in it the righteousness of God is revealed from faith to faith; as it is written, "But the righteous will live by faith."
ToHTML()
would return:
For in it <i>the</i> righteousness of God is revealed from faith to faith; as it is written, "<span class="small-caps">But the righteous will live by faith.</span>"
from gobible.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gobible.