@sefaria/text-transform
v0.1.0-alpha.0
Published
Pure Sefaria text normalization, vocalization, footnote, and preview utilities.
Keywords
Readme
Created/edited by GitHub Copilot; pending human review.
@sefaria/text-transform
Makes Sefaria's HTML safe to display and prepares vowels and footnotes, with no UI and no network. Run normalizeText first: it sanitizes. applyVocalizationToHtml does not sanitize, and createTextPreview normalizes its input itself.
A community-driven project with Sefaria backing and support. The toolkit is experimental; names and APIs may change.
Install
Public npm release 0.1.0-alpha.0 is prepared but remains pending hosted qualification. After release, installation is anonymous and needs no GitHub token. Types are included; no @types package is needed. Install and status › Packages owns current availability and exact-version installation guidance.
First success
import {
applyVocalizationToHtml,
normalizeText,
} from "@sefaria/text-transform";
// Sefaria text you already have, for example from a file or a database.
const stored =
'הִגִּ֥יד לְךָ֛ אָדָ֖ם מַה־טּ֑וֹב <span class="mam-spi-samekh" onclick="alert(1)">{ס}</span>';
// 1. Make the markup safe first.
const { bodyHtml } = normalizeText(stored);
// 2. Then remove the cantillation marks and keep the vowels.
const withVowels = applyVocalizationToHtml(bodyHtml, "nikkud");
console.log(bodyHtml);
console.log(withVowels);Next steps
- Use the data and text tools
- Clean up stored Sefaria text
- Clean text and safety
- Text transform reference
For maintainers: IMPLEMENTATION.md.
