אונטערשייד צווישן ווערסיעס פון "באַניצער:תנא קמא/tanachLinks.js"
קפיצה לניווט
קפיצה לחיפוש
אין תקציר עריכה |
אין תקציר עריכה |
||
| שורה 1: | שורה 1: | ||
// Function to convert Tanakh citations to Sefaria links | |||
function convertTanakhCitations(wikitext) { | |||
$ | // Regular expression to match the {{תנ"ך|Sefer|Chapter|Verse}} pattern | ||
const regex = /{{תנ"ך\|([^|]+)\|([^|]+)\|([^|]+)}}/g; | |||
return wikitext.replace(regex, function(match, sefer, chapter, verse) { | |||
// Construct the Sefaria URL | |||
const url = `https://www.sefaria.org/${sefer}.${chapter}.${verse}`; | |||
// Return the HTML link with Sefaria's logo | |||
return `<a href="${url}" target="_blank"><img src="https://www.sefaria.org/static/img/sefaria_logo.png" alt="Sefaria" style="vertical-align: middle; width: 20px; height: 20px;"/> ${sefer} ${chapter}:${verse}</a>`; | |||
}); | |||
} | |||
// Example usage | |||
const wikitext = 'Some text {{תנ"ך|Bamidbar|3|4}} more text.'; | |||
const convertedText = convertTanakhCitations(wikitext); | |||
console.log(convertedText); | |||
רעוויזיע פון 23:36, 3 אפריל 2025
// Function to convert Tanakh citations to Sefaria links
function convertTanakhCitations(wikitext) {
// Regular expression to match the {{תנ"ך|Sefer|Chapter|Verse}} pattern
const regex = /{{תנ"ך\|([^|]+)\|([^|]+)\|([^|]+)}}/g;
return wikitext.replace(regex, function(match, sefer, chapter, verse) {
// Construct the Sefaria URL
const url = `https://www.sefaria.org/${sefer}.${chapter}.${verse}`;
// Return the HTML link with Sefaria's logo
return `<a href="${url}" target="_blank"><img src="https://www.sefaria.org/static/img/sefaria_logo.png" alt="Sefaria" style="vertical-align: middle; width: 20px; height: 20px;"/> ${sefer} ${chapter}:${verse}</a>`;
});
}
// Example usage
const wikitext = 'Some text {{תנ"ך|Bamidbar|3|4}} more text.';
const convertedText = convertTanakhCitations(wikitext);
console.log(convertedText);