Skip to content

Commit

Permalink
When formatting verse numbers, handle range separator
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvire committed Jan 8, 2025
1 parent 3ed7064 commit 7ee1bce
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/lib/components/ScriptureViewSofria.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ LOGGING:
inlineGraft: 1,
mark: 1,
meta: 1,
row: 1
row: 1,
placement: 1
}
: $logs['scripture'];
Expand Down Expand Up @@ -524,10 +525,14 @@ LOGGING:
}
function addVerseNumber(workspace: any, element: any, showVerseNumbers: boolean) {
if (showVerseNumbers === true) {
var spanV = document.createElement('span');
const spanV = document.createElement('span');
spanV.classList.add('v');
spanV.innerText = numerals.formatNumber(numeralSystem, element.atts['number']);
var spanVsp = document.createElement('span');
// 'number' can be a range of verse numbers
const numbers = element.atts['number']
.split(verseRangeSeparator)
.map((x) => numerals.formatNumber(numeralSystem, x));
spanV.innerText = numbers.join(verseRangeSeparator);
const spanVsp = document.createElement('span');
spanVsp.classList.add('vsp');
spanVsp.innerText = '\u00A0'; // &nbsp
workspace.phraseDiv.appendChild(spanV);
Expand Down Expand Up @@ -979,6 +984,9 @@ LOGGING:
pos: string,
verse: string
) {
if (scriptureLogs?.placement) {
console.log('Placing element:', element, 'at', pos, 'of verse', verse);
}
if (pos === 'after') {
const el = document.getElementById('bookmarks' + verse);
el.insertAdjacentElement('afterend', element);
Expand Down Expand Up @@ -2397,7 +2405,8 @@ LOGGING:
$: books = $refs.catalog.documents;
$: direction = config.bookCollections.find((x) => x.id === references.collection).style
.textDirection;
$: verseRangeSeparator = config.bookCollections.find((x) => x.id === references.collection)
.features['ref-verse-range-separator'];
$: (() => {
performance.mark('query-start');
const bookHasIntroduction = books.find((x) => x.bookCode === currentBook)?.hasIntroduction;
Expand Down

0 comments on commit 7ee1bce

Please sign in to comment.