npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sanscript

v0.0.2

Published

Transliteration scheme for devanagari characters

Downloads

25

Readme

Sanscript.js

Introduction

Sanscript is a transliteration library for Indian languages. It supports the most popular Indian scripts and several different romanization schemes. Although Sanscript focuses on Sanskrit transliteration, it has partial support for other languages and is easy to extend.

Usage

Sanscript is simple to use:

var output = Sanscript.t(input, from, to);

Here, from and to are the names of different schemes. In Sanscript, the word "scheme" refers to both scripts and romanizations. These schemes are of two types:

  1. Brahmic schemes, which are abugidas. All Indian scripts are Brahmic schemes.
  2. Roman schemes, which are alphabets. All romanizations are Roman schemes.

By default, Sanscript supports the following Brahmic schemes:

  • bengali
  • devanagari
  • gujarati
  • gurmukhi
  • kannada
  • malayalam
  • oriya
  • tamil
  • telugu

and the following Roman schemes:

  • hk (Harvard-Kyoto)
  • iast (International Alphabet of Sanskrit Transliteration)
  • itrans (ITRANS)
  • itrans_dravidian (ITRANS with support for Dravidian short "e" and "o")
  • kolkata (National Library at Kolkata)
  • slp1 (Sanskrit Library Phonetic Basic)
  • velthuis (Velthuis)
  • wx (WX)

Disabling transliteration

When Sanscript sees the token ##, it toggles the transliteration state:

Sanscript.t('ga##Na##pa##te', 'hk', 'devanagari'); // गNaपte
Sanscript.t('ध##र्म##क्षेत्रे', 'devanagari', 'hk'); // dhaर्मkSetre

When Sanscript sees the token \, it disables transliteration on the character that immediately follows. \ is used for ITRANS compatibility; we recommend always using ## instead.

Sanscript.t('a \\a', 'itrans', 'devanagari'); // अ a
Sanscript.t('\\##aham', 'itrans', 'devanagari'); // ##अहम्

Transliterating to lossy schemes

A lossy scheme does not have the letters needed to support lossless translation. For example, Bengali is a lossy scheme because it uses for both ba and va. In future releases, Sanscript might let you choose how to handle lossiness. For the time being, it makes some fairly bad hard-coded assumptions. Corrections and advice are always welcome.

Transliteration options

You can tweak the transliteration function by passing an options object:

var output = Sanscript.t(input, from, to, options);

options maps options to values. Currently, these options are supported:

  • skip_sgml - If true, transliterate SGML tags as if they were ordinary words (<b>iti</b><ब्>इति</ब्>). Defaults to false.
  • syncope - If true, use Hindi-style transliteration (ajayअजय). In linguistics, this behavior is known as schwa syncope. Defaults to false.

Adding new schemes

Adding a new scheme is simple:

Sanscript.addBrahmicScheme(schemeName, schemeData);
Sanscript.addRomanScheme(schemeName, schemeData);

For help in creating schemeData, see the comments on the addBrahmicScheme and addRomanScheme functions.

Testing

Top level Makefile Starts a Webserver using PHP on Port 9732.

make - will start the webserver on port 9732

Open your browser and launch this url http://127.0.0.1:9732/test/index.html and see that all tests are ok.

Changelog

  • Added Sanskrit Vedic Accent Support
  • Added Tamil Accent Support