Skip to content

Commit

Permalink
Fix issues noticed in usfmGeneartion in web module
Browse files Browse the repository at this point in the history
  • Loading branch information
kavitharaju committed Nov 28, 2024
1 parent 5540b68 commit 2226bc3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 16 additions & 2 deletions web-usfm-parser/src/usfmGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,17 @@ class USFMGenerator {
if (typeof item === "string") {
this.usfmString += item;
} else {
this.usjToUsfm(item, usjObj.type === "char");
this.usjToUsfm(item, usjObj.type === "char" && item.marker !== "fv");
}
});
}

let attributes = [];
Object.keys(usjObj).forEach((key) => {
if (!NON_ATTRIB_USJ_KEYS.includes(key)) {
attributes.push(`${key}="${usjObj[key]}"`);
let lhs = key;
if (key === "file") { lhs = "src" }
attributes.push(`${lhs}="${usjObj[key]}"`);
}
});

Expand All @@ -74,6 +76,18 @@ class USFMGenerator {
}
this.usfmString += `${usjObj.marker}* `;
}
if (usjObj.type === "ms") {
if ("sid" in usjObj) {
if (attributes.length == 0 ) {
this.usfmString += '|';
}
this.usfmString += `sid="${usjObj.sid}" `;
}
this.usfmString = this.usfmString.trim() + "\\*";
}
if (usjObj.type === "sidebar" ) {
this.usfmString += "\\esbe";
}
if (
!NO_NEWLINE_USJ_TYPES.includes(usjObj.type) &&
this.usfmString[this.usfmString.length - 1] !== "\n"
Expand Down
2 changes: 1 addition & 1 deletion web-usfm-parser/src/utils/types.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const NO_USFM_USJ_TYPES = ["USJ", "table"];
export const CLOSING_USJ_TYPES
= ["char", "note", "figure"];
= ["char", "note", "figure", "ref"];
export const NON_ATTRIB_USJ_KEYS = [
"type",
"marker",
Expand Down

0 comments on commit 2226bc3

Please sign in to comment.