Skip to content

Commit 12a63c8

Browse files
Merge branch 'sillsdev:main' into feature/test-parse-config-rebase/679
2 parents 125fd5c + bd4f2f3 commit 12a63c8

5 files changed

Lines changed: 25 additions & 28 deletions

File tree

convert/convertBooks.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ function isImageMissing(imageSource: string): boolean {
190190
return !fs.existsSync(path.join('data', 'illustrations', imageSource));
191191
}
192192

193+
function addParagraphMarkersAroundTableRows(text: string): string {
194+
return text.replace(/((?:\\tr [^\n]*\n)+)/g, '\n\\p\n$1\\p\n');
195+
}
196+
193197
type FilterFunction = (text: string, bcId: string, bookId: string) => string;
194198

195199
const usfmFilterFunctions: FilterFunction[] = [
@@ -199,7 +203,8 @@ const usfmFilterFunctions: FilterFunction[] = [
199203
convertMarkdownsToMilestones,
200204
handleNoCaptionFigures,
201205
removeMissingFigures,
202-
trimTrailingWhitespace
206+
trimTrailingWhitespace,
207+
addParagraphMarkersAroundTableRows
203208
];
204209

205210
const htmlFilterFunctions: FilterFunction[] = [updateImgTags, trimTrailingWhitespace];

convert/convertConfig.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,10 @@ export function parseBookCollections(document: Document, verbose: number) {
523523
const audioTag = page.getElementsByTagName('audio')[0];
524524
if (!audioTag) continue;
525525
const fTag = audioTag.getElementsByTagName('f')[0];
526-
if (verbose >= 2)
527-
console.log(`... audioTag: ${audioTag.outerHTML}, fTag:${fTag.outerHTML}`);
526+
if (verbose >= 2) {
527+
console.log(`... audioTag: ${audioTag.outerHTML}, fTag:${fTag?.outerHTML}`);
528+
}
529+
if (!fTag) continue;
528530
audio.push({
529531
num: parseInt(page.attributes.getNamedItem('num')!.value),
530532
filename: fTag.innerHTML,

src/lib/components/ScriptureViewSofria.svelte

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -277,21 +277,12 @@ LOGGING:
277277
if (workspace.textType.includes('usfm') && workspace.usfmWrapperType === 'xt') {
278278
const references = text.split('; ');
279279
for (let i = 0; i < references.length; i++) {
280-
const links = references[i].split('|');
281-
const displayText = links[0];
282-
const referenceText = links.length > 1 ? links[1] : links[0];
283-
const spanElement = document.createElement('span');
284-
spanElement.classList.add('reflink');
285-
286-
// TODO: Figure out what really needs to be added to go to references
287-
// For now, just make it look consistent
288-
const aElement = document.createElement('a');
289-
aElement.setAttribute('href', referenceText);
290-
const refText = document.createTextNode(displayText);
291-
aElement.appendChild(refText);
292-
spanElement.appendChild(aElement);
293-
294-
workspace.tableCellElement.appendChild(spanElement);
280+
var spanV = document.createElement('span');
281+
spanV.classList.add('reflink');
282+
const refText = generateHTML(text, 'header-ref');
283+
spanV.innerHTML = refText;
284+
spanV.addEventListener('click', onClick, false);
285+
workspace.tableCellElement.appendChild(spanV);
295286
if (i < references.length - 1) {
296287
const textNode = document.createTextNode('; ');
297288
workspace.tableCellElement.appendChild(textNode);
@@ -1272,8 +1263,8 @@ LOGGING:
12721263
}
12731264
function preprocessAction(action: string, workspace: any) {
12741265
// Table ends if row ended and anything other than start row follows it
1275-
if (!workspace.inRow && workspace.inTable && !(action === 'startRow')) {
1276-
workspace.inTable = false;
1266+
if (!workspace.inRow && workspace.insideTable && !(action === 'startRow')) {
1267+
workspace.insideTable = false;
12771268
workspace.root.appendChild(workspace.tableElement);
12781269
}
12791270
}
@@ -1399,7 +1390,7 @@ LOGGING:
13991390
workspace.lastPhraseTerminated = false;
14001391
workspace.currentVideoIndex = 0;
14011392
workspace.chapterNumText = '';
1402-
workspace.inTable = false;
1393+
workspace.insideTable = false;
14031394
workspace.inRow = false;
14041395
workspace.tableElement = null;
14051396
workspace.tableRowElement = null;
@@ -2369,10 +2360,10 @@ LOGGING:
23692360
console.log('Start Row %o', context.sequences[0].element);
23702361
}
23712362
preprocessAction('startRow', workspace);
2372-
if (!workspace.inTable) {
2363+
if (!workspace.insideTable) {
23732364
workspace.tableElement = document.createElement('table');
23742365
workspace.tableElement.setAttribute('cellpadding', '5');
2375-
workspace.inTable = true;
2366+
workspace.insideTable = true;
23762367
}
23772368
workspace.inRow = true;
23782369
workspace.tableRowElement = document.createElement('tr');

src/lib/video/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function getYouTubeVideoId(url: string): string {
6363
export function getEmbeddedVideoUrl(
6464
videoUrl: string,
6565
autoplay: boolean,
66-
features: { [key: string]: string }
66+
features: { [key: string]: any }
6767
) {
6868
let returnUrl = videoUrl;
6969
const type = getVideoType(videoUrl);
@@ -140,7 +140,7 @@ export function getEmbeddedVideoUrl(
140140
export function createVideoBlockFromUrl(
141141
document: Document,
142142
videoUrl: string,
143-
features: { [key: string]: string }
143+
features: { [key: string]: any }
144144
): HTMLElement {
145145
const url = getEmbeddedVideoUrl(videoUrl, false, features);
146146

src/routes/contents/[id]/+page.svelte

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,12 @@
9191
}
9292
9393
function getReference(item) {
94-
let docSet;
95-
let collection;
94+
let docSet = $refs.docSet;
95+
let collection = docSet.split('_')[1];
9696
let book;
9797
let chapter;
9898
let verse;
9999
const reference = item.linkTarget.split('.');
100-
101100
if (item.layoutMode && item.layoutCollection?.length > 0) {
102101
/*
103102
Note: have not handled layout modes

0 commit comments

Comments
 (0)