Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 35 additions & 22 deletions static/js/sefaria/sefaria.js
Original file line number Diff line number Diff line change
Expand Up @@ -663,29 +663,42 @@ Sefaria = extend(Sefaria, {
}
return output;
},
_getLinkerTestString({text, inputRefParts, inputRefPartTypes}) {
/**
* Outputs a test string that can be pasted into linker_test.py to test the same input.
*/
_getLinkerTestString({text, inputRefParts, inputRefPartTypes, inputRangeSections, inputRangeToSections}) {
/**
* Outputs a test string that can be pasted into linker_test.py to test the same input.
*/
let testStr = "crrd([";
testStr += Sefaria._getLinkerTestStringForParts(inputRefParts, inputRefPartTypes, inputRangeSections, inputRangeToSections);
testStr += "]";
if (Sefaria.hebrew.isHebrew(text)) {
testStr += ")";
} else {
testStr += ", lang='en')";
}
return testStr;
},
_getLinkerTestStringForParts(refParts, refPartTypes, rangeSections, rangeToSections) {
const partTypeSymbolMap = {"NAMED": "@", "NUMBERED": "#", "DH": "*", "RANGE_SYMBOL": "^", "IBID": "&", "RELATIVE": "<"}
let testStr = "crrd([";
for (let i = 0; i < inputRefParts.length; i++) {
const part = inputRefParts[i];
const type = inputRefPartTypes[i];
const symbol = partTypeSymbolMap[type] || "?";
testStr += `"${symbol}${part.replace('"', '\\"')}"`;
if (i < inputRefParts.length - 1) {
testStr += ", ";
}
}
testStr += "]";
if (Sefaria.hebrew.isHebrew(text)) {
testStr += ")";
} else {
testStr += ", lang='en')";
}
return testStr;
},
let testStr = "";
for (let i = 0; i < refParts.length; i++) {
const part = refParts[i];
const type = refPartTypes[i];
if (type === "RANGE" && rangeSections && rangeToSections) {
testStr += Sefaria._getLinkerTestStringForParts(rangeSections, Array(rangeSections.length).fill("NUMBERED"));
testStr += ", ";
testStr += Sefaria._getLinkerTestStringForParts(["-"], ["RANGE_SYMBOL"]);
testStr += ", ";
testStr += Sefaria._getLinkerTestStringForParts(rangeToSections, Array(rangeToSections.length).fill("NUMBERED"));
} else {
const symbol = partTypeSymbolMap[type] || "?";
testStr += `"${symbol}${part.replace('"', '\\"')}"`;
}
if (i < refParts.length - 1) {
testStr += ", ";
}
}
return testStr;
},
getAllTranslationsWithText: async function(ref) {
let returnObj = await Sefaria.getTextsFromAPIV3(ref, [{languageFamilyName: 'translation', versionTitle: 'all'}], false);
return Sefaria._sortVersionsIntoBuckets(returnObj.versions);
Expand Down
Loading