Gurmukhi Utils
Gurmukhi Utils is a library for converting, analyzing, and testing gurmukhi strings. Try gurmukhi-utils
in your browser.
#
UsageGurmukhi Utils is available as the gurmukhi-utils
package on npm.
Additionally, the package is available for web use via unpkg CDN:
#
PeopleThe original author and current lead maintainer of Gurmukhi Utils is Harjot Singh (@harjot1singh).
"Thank you!" to all the volunteers who've already contributed to Gurmukhi Utils. Additional thanks to:
- Preetcharan S (@NerdSingh) and Basics of Sikhi for english pronunciation guidelines
- Dr. Gurpreet S Lehal (Punjabi University, Patiala) for his work in Gurmukhi-Hindi (Devanagri) and Gurmukhi-Shahmukhi (Urdu) transliteration
#
APInumber
#
countSyllables(text) ⇒ Calculates the number of syllables according to Sanskrit prosody, Pingala, Matra/Meter/Morae
Returns: number
- An integer adding up all the 1's (laghu/light/short) and 2's (guru/heavy/long).
Param | Type | Description |
---|---|---|
text | String | The string to analyze |
Example
String
#
firstLetters(line) ⇒ Generates the first letters for a unicode Gurmukhi, Hindi transliteration, or English transliteration string. Includes any end-word vishraams, and line-end characters.
Returns: String
- The first letters of each word in the provided Gurmukhi line.
Param | Type | Description |
---|---|---|
line | String | The line to generate the first letters for. |
Example (Gurmukhi first letters)
Example (Hindi first letters)
Example (English first letters)
boolean
#
isGurmukhi(text, [exhaustive]) ⇒ Checks if first char in string is part of the Gurmukhi Unicode block.
Returns: boolean
- True if Unicode Gurmukhi, false if other.
Param | Type | Description |
---|---|---|
text | String | The text to check. |
[exhaustive] | boolean | If true , checks if the whole string is Unicode Gurmukhi. |
Example
String
#
stripAccents(text) ⇒ Removes accents from ASCII/Unicode Gumrukhi letters with their base letter. Useful for generalising search queries.
Returns: String
- A simplified version of the provided Gurmukhi string.
Param | Type | Description |
---|---|---|
text | String | The text to convert. |
Example
String
#
stripEndings(text) ⇒ Strips line endings from any Gurmukhi or translation string. Accepts both Unicode and ASCII input. Useful for generating accurate first letters or modifying non-Gurbani for better display. Not designed for headings or Sirlekhs.
Returns: String
- A ending-less version of the text.
Param | Type | Description |
---|---|---|
text | String | The text to stip endings from. |
Example (Line ending phrases)
Example (English Translations)
Example (Spanish Translations)
String
#
stripVishraams(text, options) ⇒ Removes the specified vishraams from a string.
Returns: String
- A vishraam-less Gurmukhi string.
Param | Type | Description |
---|---|---|
text | String | The text to remove vishraams from. |
options | Object | The vishraams to remove. Defaults to all. |
Example (Text only, default options)
Example (Heavy vishraams only)
Example (Medium vishrams only)
Example (Light vishrams only)
String
#
toAscii(text) ⇒ Converts Gurmukhi unicode text to ASCII, used GurmukhiAkhar font.
Returns: String
- An ASCII representation of the provided unicode Gurmukhi string.
Param | Type | Description |
---|---|---|
text | String | The unicode text to convert. |
Example
String
#
toEnglish(line) ⇒ Transliterates a line from Unicode Gurmukhi to english.
Currently supports the ,
, ;
, .
vishraam characters.
Returns: String
- The English transliteration of the provided Gurmukhi line.
Param | Type | Description |
---|---|---|
line | String | The Gurmukhi Unicode line to transliterate. |
Example
Example
String
#
toHindi(text) ⇒ Transliterates Unicode Gurmukhi text to Hindi (Devanagari script).
Returns: String
- A Hindi transliteration of the provided Unicode Gurmukhi string.
Param | Type | Description |
---|---|---|
text | String | The Unicode Gurmukhi text to convert. |
Example
String
#
toShahmukhi(text) ⇒ Transliterates Unicode Gurmukhi text to the Shahmukhi script.
Returns: String
- A Shahmukhi transliteration of the provided Unicode Gurmukhi string.
Param | Type | Description |
---|---|---|
text | String | The Unicode Gurmukhi text to convert. |
Example
String
#
toSyllabicSymbols(text) ⇒ Represents text in syllables according to Sanskrit prosody, Pingala, Matra/Meter/Morae
Returns: String
- A syllabic representation of 1's (laghu/light/short) and 2's (guru/heavy/long).
Param | Type | Description |
---|---|---|
text | String | The string to convert |
Example
String
#
toUnicode(text) ⇒ Converts ASCII text used in the GurmukhiAkhar font to Unicode.
Returns: String
- A unicode representation of the provided ASCII Gurmukhi string.
Param | Type | Description |
---|---|---|
text | String | The ASCII text to convert. |
Example