Preserve layout in embedded Bible data
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import std/[strutils, unittest]
|
||||
|
||||
import ../src/embedded_bible
|
||||
import ../src/kjv
|
||||
import ../src/reference_parser
|
||||
|
||||
@@ -82,3 +83,51 @@ suite "offline KJV backend":
|
||||
check passages.len == 1
|
||||
check passages[0].startsWith("Jude 3\n")
|
||||
check passages[0].contains(" [3] ")
|
||||
|
||||
suite "embedded Bible layout":
|
||||
const layoutRows = """
|
||||
JHN 8 31 0 paragraph 0 Then Jesus said,
|
||||
JHN 8 31 1 same 0 "If you remain in My word,
|
||||
JHN 8 32 0 same 0 you shall know the truth."
|
||||
JHN 8 33 0 paragraph 0 They answered Him.
|
||||
HEB 4 7 0 paragraph 0 again He establishes a certain day:
|
||||
HEB 4 7 1 line 0 "Today, if you will hear His voice,
|
||||
HEB 4 7 2 line 1 do not harden your hearts."
|
||||
"""
|
||||
|
||||
test "preserves inline verse markers within a paragraph":
|
||||
let passages = embedded_bible.fetchPassages(layoutRows, "John 8:31-32", "TEST")
|
||||
|
||||
check passages.len == 1
|
||||
check passages[0] == "John 8:31-32\n" &
|
||||
" [31] Then Jesus said, \"If you remain in My word, [32] you shall know the truth.\""
|
||||
|
||||
test "preserves paragraph breaks":
|
||||
let passages = embedded_bible.fetchPassages(layoutRows, "John 8:31-33", "TEST")
|
||||
|
||||
check passages[0] == "John 8:31-33\n" &
|
||||
" [31] Then Jesus said, \"If you remain in My word, [32] you shall know the truth.\"\n" &
|
||||
"\n" &
|
||||
" [33] They answered Him."
|
||||
|
||||
test "preserves indented quote lines":
|
||||
let passages = embedded_bible.fetchPassages(layoutRows, "Hebrews 4:7", "TEST")
|
||||
|
||||
check passages[0] == "Hebrews 4:7\n" &
|
||||
" [7] again He establishes a certain day:\n" &
|
||||
" \"Today, if you will hear His voice,\n" &
|
||||
" do not harden your hearts.\""
|
||||
|
||||
test "starts mid-paragraph ranges on a fresh line":
|
||||
let passages = embedded_bible.fetchPassages(layoutRows, "John 8:32-33", "TEST")
|
||||
|
||||
check passages[0] == "John 8:32-33\n" &
|
||||
" [32] you shall know the truth.\"\n" &
|
||||
"\n" &
|
||||
" [33] They answered Him."
|
||||
|
||||
test "supports legacy verse rows":
|
||||
const legacyRows = "JHN\t3\t16\tFor God so loved the world.\n"
|
||||
let passages = embedded_bible.fetchPassages(legacyRows, "John 3:16", "TEST")
|
||||
|
||||
check passages[0] == "John 3:16\n [16] For God so loved the world."
|
||||
|
||||
Reference in New Issue
Block a user