From 4adbf3ffe170809c673d7e727c375159dcb8ffcd Mon Sep 17 00:00:00 2001 From: "Bhajneet S.K" Date: Mon, 2 Nov 2020 12:10:31 -0500 Subject: [PATCH] fix(stripEndings): constrain number stripping to end of lines (#178) Fixes #176 --- README.md | 70 ++++++---------- docs/README.md | 70 ++++++---------- lib/stripEndings.js | 11 ++- test/stripEndings.spec.js | 164 ++++++++++++++++++++++++++++---------- 4 files changed, 183 insertions(+), 132 deletions(-) diff --git a/README.md b/README.md index ecde0c7..3d3336b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -Shabad OS +Shabad OS

Gurmukhi Utils

@@ -84,13 +84,10 @@ Calculates the number of syllables according to Sanskrit prosody, Pingala, Matra **Example** ```js -countSyllables( 'ਪ੍ਰਭੂ ਪ੍ਰੇਮੀ ਪੜ੍ਹ ਚੜ੍ਹ ਦ੍ਵੈਤ' ) -// expected output: 14 +countSyllables( 'ਪ੍ਰਭੂ ਪ੍ਰੇਮੀ ਪੜ੍ਹ ਚੜ੍ਹ ਦ੍ਵੈਤ' ) // expected output: 14 ``` ### firstLetters(line) ⇒ String -Generates the first letters for a unicode Gurmukhi, -Hindi transliteration, or English transliteration string. -Includes any end-word vishraams, and line-end characters. +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. @@ -122,12 +119,10 @@ Checks if first char in string is part of the Gurmukhi Unicode block. **Example** ```js -isGurmukhi('ਗੁਰਮੁਖੀ') // => true -isGurmukhi('gurmuKI') // => false +isGurmukhi('ਗੁਰਮੁਖੀ') // => true isGurmukhi('gurmuKI') // => false ``` ### stripAccents(text) ⇒ String -Removes accents from ASCII/Unicode Gumrukhi letters with their base letter. -Useful for generalising search queries. +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. @@ -137,14 +132,10 @@ Useful for generalising search queries. **Example** ```js -stripAccents('ਜ਼ਫ਼ੈਸ਼ਸਓ') // => ਜਫੈਸਸੳ -stripAccents('Z^Svb') // => gKsvb +stripAccents('ਜ਼ਫ਼ੈਸ਼ਸਓ') // => ਜਫੈਸਸੳ stripAccents('Z^Svb') // => gKsvb ``` ### stripEndings(text) ⇒ String -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. +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. @@ -207,12 +198,10 @@ Converts Gurmukhi unicode text to ASCII, used GurmukhiAkhar font. **Example** ```js -toAscii('ਹਮਾ ਸਾਇਲਿ ਲੁਤਫ਼ਿ ਹਕ ਪਰਵਰਸ਼ ॥') // => hmw swieil luqi& hk prvrS ] -toAscii('ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥') // => su bYiT iekMqR ]578] +toAscii('ਹਮਾ ਸਾਇਲਿ ਲੁਤਫ਼ਿ ਹਕ ਪਰਵਰਸ਼ ॥') // => hmw swieil luqi& hk prvrS ] toAscii('ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥') // => su bYiT iekMqR ]578] ``` ### toEnglish(line) ⇒ String -Transliterates a line from Unicode Gurmukhi to english. -Currently supports the `,`, `;`, `.` vishraam characters. +Transliterates a line from Unicode Gurmukhi to english. Currently supports the `,`, `;`, `.` vishraam characters. **Returns**: String - The English transliteration of the provided Gurmukhi line. @@ -239,8 +228,7 @@ Transliterates Unicode Gurmukhi text to Hindi (Devanagari script). **Example** ```js -toHindi('ਕੁਲ ਜਨ ਮਧੇ ਮਿਲੵੋਿ ਸਾਰਗ ਪਾਨ ਰੇ ॥') // => कुल जन मधे मिल्यो सारग पान रे ॥ -toHindi('ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥') // => सु बैठ इकंत्र ॥५७८॥ +toHindi('ਕੁਲ ਜਨ ਮਧੇ ਮਿਲੵੋਿ ਸਾਰਗ ਪਾਨ ਰੇ ॥') // => कुल जन मधे मिल्यो सारग पान रे ॥ toHindi('ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥') // => सु बैठ इकंत्र ॥५७८॥ ``` ### toShahmukhi(text) ⇒ String Transliterates Unicode Gurmukhi text to the Shahmukhi script. @@ -253,8 +241,7 @@ Transliterates Unicode Gurmukhi text to the Shahmukhi script. **Example** ```js -toShahmukhi('ਹਮਾ ਸਾਇਲਿ ਲੁਤਫ਼ਿ ਹਕ ਪਰਵਰਸ਼ ॥') // => هما ساِال لُتف هک پرورش ۔۔ -toShahmukhi('ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥') // => سُ بَےٹھ ِاکںتر ۔۔۵۷۸۔۔ +toShahmukhi('ਹਮਾ ਸਾਇਲਿ ਲੁਤਫ਼ਿ ਹਕ ਪਰਵਰਸ਼ ॥') // => هما ساِال لُتف هک پرورش ۔۔ toShahmukhi('ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥') // => سُ بَےٹھ ِاکںتر ۔۔۵۷۸۔۔ ``` ### toSyllabicSymbols(text) ⇒ String Represents text in syllables according to Sanskrit prosody, Pingala, Matra/Meter/Morae @@ -267,8 +254,7 @@ Represents text in syllables according to Sanskrit prosody, Pingala, Matra/Meter **Example** ```js -toSyllabicSymbols( 'ਪ੍ਰਭੂ ਪ੍ਰੇਮੀ ਪੜ੍ਹ ਚੜ੍ਹ ਦ੍ਵੈਤ' ) -// expected output: '12 22 11 11 21' +toSyllabicSymbols( 'ਪ੍ਰਭੂ ਪ੍ਰੇਮੀ ਪੜ੍ਹ ਚੜ੍ਹ ਦ੍ਵੈਤ' ) // expected output: '12 22 11 11 21' ``` ### toUnicode(text) ⇒ String Converts ASCII text used in the GurmukhiAkhar font to Unicode. @@ -281,8 +267,7 @@ Converts ASCII text used in the GurmukhiAkhar font to Unicode. **Example** ```js -toUnicode('kul jn mDy imil´o swrg pwn ry ]') // => ਕੁਲ ਜਨ ਮਧੇ ਮਿਲੵੋਿ ਸਾਰਗ ਪਾਨ ਰੇ ॥ -toUnicode('su bYiT iekMqR ]578]') // => ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥ +toUnicode('kul jn mDy imil´o swrg pwn ry ]') // => ਕੁਲ ਜਨ ਮਧੇ ਮਿਲੵੋਿ ਸਾਰਗ ਪਾਨ ਰੇ ॥ toUnicode('su bYiT iekMqR ]578]') // => ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥ ``` ## Community @@ -292,7 +277,6 @@ Get updates on Shabad OS and chat with the project maintainers and community mem - [![Instagram][instagram-image]][instagram-url] Follow Shabad OS on Instagram - [![Twitter][twitter-image]][twitter-url] Follow Shabad OS on Twitter. - [![Chat][chat-image]][chat-url] Join the official Slack channel. -- [![WhatsApp][whatsapp-image]][whatsapp-url] Direct message us on WhatsApp. Or chat with fellow Shabad OS community members in the WhatsApp group chat. ## Contributing @@ -315,7 +299,7 @@ The original author and current lead maintainer of Gurmukhi Utils is Harjot Sing ## Feedback -- Ask a question via [Slack][chat-url] or [WhatsApp][whatsapp-url] +- Ask a question via [Slack][chat-url] - [Upvote popular feature requests][upvote-tracker-url] using the thumbs-up/+1 reaction on the first post of a feature request - Follow [@shabad_os on Instagram](instagram-url) and [@shabad_os on Twitter](twitter-url) and let us know what you think! @@ -323,10 +307,10 @@ The original author and current lead maintainer of Gurmukhi Utils is Harjot Sing Projects in the Shabad OS ecosystem of free and open source software which use the `gurmukhi-utils` package include: -- [Database](https://github.com/ShabadOS/database) -- [Viewer](https://github.com/ShabadOS/viewer) -- [Presenter](https://github.com/ShabadOS/presenter) -- [Mobile](https://github.com/ShabadOS/mobile) +- [Database](https://github.com/shabados/database) +- [Viewer](https://github.com/shabados/viewer) +- [Presenter](https://github.com/shabados/presenter) +- [Mobile](https://github.com/shabados/mobile) ## Code of Conduct @@ -354,12 +338,12 @@ The Shabad OS Docs repo is under v3 of the [GPL](LICENSE.md). It is similar to t [npm-url]: https://npmjs.org/package/gurmukhi-utils [downloads-image]: https://img.shields.io/npm/dm/gurmukhi-utils.svg [downloads-url]: https://npmcharts.com/compare/gurmukhi-utils?minimal=true -[release-image]: https://img.shields.io/circleci/project/github/ShabadOS/gurmukhi-utils/main.svg?label=release -[release-url]: https://circleci.com/gh/ShabadOS/gurmukhi-utils/tree/main -[next-image]: https://img.shields.io/circleci/project/github/ShabadOS/gurmukhi-utils/dev.svg?label=next%20release -[next-url]: https://circleci.com/gh/ShabadOS/gurmukhi-utils/tree/dev -[coveralls-image]: https://img.shields.io/coveralls/github/ShabadOS/gurmukhi-utils.svg?label=test%20coverage -[coveralls-url]: https://coveralls.io/github/ShabadOS/gurmukhi-utils +[release-image]: https://img.shields.io/circleci/project/github/shabados/gurmukhi-utils/main.svg?label=release +[release-url]: https://circleci.com/gh/shabados/gurmukhi-utils/tree/main +[next-image]: https://img.shields.io/circleci/project/github/shabados/gurmukhi-utils/dev.svg?label=next%20release +[next-url]: https://circleci.com/gh/shabados/gurmukhi-utils/tree/dev +[coveralls-image]: https://img.shields.io/coveralls/github/shabados/gurmukhi-utils.svg?label=test%20coverage +[coveralls-url]: https://coveralls.io/github/shabados/gurmukhi-utils [instagram-image]: https://img.shields.io/badge/Instagram-%40shabad__os-C13584.svg?logo=instagram&logoColor=white [instagram-url]: https://www.instagram.com/shabad_os/ @@ -367,10 +351,8 @@ The Shabad OS Docs repo is under v3 of the [GPL](LICENSE.md). It is similar to t [twitter-url]: https://www.twitter.com/shabad_os/ [chat-image]: https://img.shields.io/badge/Chat-Public%20Slack%20Channels-1264a3.svg?logo=slack [chat-url]: https://chat.shabados.com -[whatsapp-image]: https://img.shields.io/badge/WhatsApp-%2B1%20516%20619%206059-128C7E.svg?logo=whatsapp&logoColor=white -[whatsapp-url]: https://wa.me/15166196059 -[new-issue-url]: https://github.com/ShabadOS/gurmukhi-utils/issues/new +[new-issue-url]: https://github.com/shabados/gurmukhi-utils/issues/new [contributor-url]: https://github.com/shabados/gurmukhi-utils/graphs/contributors -[upvote-tracker-url]: https://github.com/ShabadOS/gurmukhi-utils/issues?q=is%3Aopen+is%3Aissue+label%3A%22Type%3A+Feature%2FEnhancement%22+sort%3Areactions-%2B1-desc +[upvote-tracker-url]: https://github.com/shabados/gurmukhi-utils/issues?q=is%3Aopen+is%3Aissue+label%3A%22Type%3A+Feature%2FEnhancement%22+sort%3Areactions-%2B1-desc [contributor-covenant-url]: https://www.contributor-covenant.org/version/2/0/code_of_conduct/ diff --git a/docs/README.md b/docs/README.md index ecde0c7..3d3336b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,6 +1,6 @@ -Shabad OS +Shabad OS

Gurmukhi Utils

@@ -84,13 +84,10 @@ Calculates the number of syllables according to Sanskrit prosody, Pingala, Matra **Example** ```js -countSyllables( 'ਪ੍ਰਭੂ ਪ੍ਰੇਮੀ ਪੜ੍ਹ ਚੜ੍ਹ ਦ੍ਵੈਤ' ) -// expected output: 14 +countSyllables( 'ਪ੍ਰਭੂ ਪ੍ਰੇਮੀ ਪੜ੍ਹ ਚੜ੍ਹ ਦ੍ਵੈਤ' ) // expected output: 14 ``` ### firstLetters(line) ⇒ String -Generates the first letters for a unicode Gurmukhi, -Hindi transliteration, or English transliteration string. -Includes any end-word vishraams, and line-end characters. +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. @@ -122,12 +119,10 @@ Checks if first char in string is part of the Gurmukhi Unicode block. **Example** ```js -isGurmukhi('ਗੁਰਮੁਖੀ') // => true -isGurmukhi('gurmuKI') // => false +isGurmukhi('ਗੁਰਮੁਖੀ') // => true isGurmukhi('gurmuKI') // => false ``` ### stripAccents(text) ⇒ String -Removes accents from ASCII/Unicode Gumrukhi letters with their base letter. -Useful for generalising search queries. +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. @@ -137,14 +132,10 @@ Useful for generalising search queries. **Example** ```js -stripAccents('ਜ਼ਫ਼ੈਸ਼ਸਓ') // => ਜਫੈਸਸੳ -stripAccents('Z^Svb') // => gKsvb +stripAccents('ਜ਼ਫ਼ੈਸ਼ਸਓ') // => ਜਫੈਸਸੳ stripAccents('Z^Svb') // => gKsvb ``` ### stripEndings(text) ⇒ String -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. +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. @@ -207,12 +198,10 @@ Converts Gurmukhi unicode text to ASCII, used GurmukhiAkhar font. **Example** ```js -toAscii('ਹਮਾ ਸਾਇਲਿ ਲੁਤਫ਼ਿ ਹਕ ਪਰਵਰਸ਼ ॥') // => hmw swieil luqi& hk prvrS ] -toAscii('ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥') // => su bYiT iekMqR ]578] +toAscii('ਹਮਾ ਸਾਇਲਿ ਲੁਤਫ਼ਿ ਹਕ ਪਰਵਰਸ਼ ॥') // => hmw swieil luqi& hk prvrS ] toAscii('ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥') // => su bYiT iekMqR ]578] ``` ### toEnglish(line) ⇒ String -Transliterates a line from Unicode Gurmukhi to english. -Currently supports the `,`, `;`, `.` vishraam characters. +Transliterates a line from Unicode Gurmukhi to english. Currently supports the `,`, `;`, `.` vishraam characters. **Returns**: String - The English transliteration of the provided Gurmukhi line. @@ -239,8 +228,7 @@ Transliterates Unicode Gurmukhi text to Hindi (Devanagari script). **Example** ```js -toHindi('ਕੁਲ ਜਨ ਮਧੇ ਮਿਲੵੋਿ ਸਾਰਗ ਪਾਨ ਰੇ ॥') // => कुल जन मधे मिल्यो सारग पान रे ॥ -toHindi('ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥') // => सु बैठ इकंत्र ॥५७८॥ +toHindi('ਕੁਲ ਜਨ ਮਧੇ ਮਿਲੵੋਿ ਸਾਰਗ ਪਾਨ ਰੇ ॥') // => कुल जन मधे मिल्यो सारग पान रे ॥ toHindi('ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥') // => सु बैठ इकंत्र ॥५७८॥ ``` ### toShahmukhi(text) ⇒ String Transliterates Unicode Gurmukhi text to the Shahmukhi script. @@ -253,8 +241,7 @@ Transliterates Unicode Gurmukhi text to the Shahmukhi script. **Example** ```js -toShahmukhi('ਹਮਾ ਸਾਇਲਿ ਲੁਤਫ਼ਿ ਹਕ ਪਰਵਰਸ਼ ॥') // => هما ساِال لُتف هک پرورش ۔۔ -toShahmukhi('ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥') // => سُ بَےٹھ ِاکںتر ۔۔۵۷۸۔۔ +toShahmukhi('ਹਮਾ ਸਾਇਲਿ ਲੁਤਫ਼ਿ ਹਕ ਪਰਵਰਸ਼ ॥') // => هما ساِال لُتف هک پرورش ۔۔ toShahmukhi('ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥') // => سُ بَےٹھ ِاکںتر ۔۔۵۷۸۔۔ ``` ### toSyllabicSymbols(text) ⇒ String Represents text in syllables according to Sanskrit prosody, Pingala, Matra/Meter/Morae @@ -267,8 +254,7 @@ Represents text in syllables according to Sanskrit prosody, Pingala, Matra/Meter **Example** ```js -toSyllabicSymbols( 'ਪ੍ਰਭੂ ਪ੍ਰੇਮੀ ਪੜ੍ਹ ਚੜ੍ਹ ਦ੍ਵੈਤ' ) -// expected output: '12 22 11 11 21' +toSyllabicSymbols( 'ਪ੍ਰਭੂ ਪ੍ਰੇਮੀ ਪੜ੍ਹ ਚੜ੍ਹ ਦ੍ਵੈਤ' ) // expected output: '12 22 11 11 21' ``` ### toUnicode(text) ⇒ String Converts ASCII text used in the GurmukhiAkhar font to Unicode. @@ -281,8 +267,7 @@ Converts ASCII text used in the GurmukhiAkhar font to Unicode. **Example** ```js -toUnicode('kul jn mDy imil´o swrg pwn ry ]') // => ਕੁਲ ਜਨ ਮਧੇ ਮਿਲੵੋਿ ਸਾਰਗ ਪਾਨ ਰੇ ॥ -toUnicode('su bYiT iekMqR ]578]') // => ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥ +toUnicode('kul jn mDy imil´o swrg pwn ry ]') // => ਕੁਲ ਜਨ ਮਧੇ ਮਿਲੵੋਿ ਸਾਰਗ ਪਾਨ ਰੇ ॥ toUnicode('su bYiT iekMqR ]578]') // => ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥ ``` ## Community @@ -292,7 +277,6 @@ Get updates on Shabad OS and chat with the project maintainers and community mem - [![Instagram][instagram-image]][instagram-url] Follow Shabad OS on Instagram - [![Twitter][twitter-image]][twitter-url] Follow Shabad OS on Twitter. - [![Chat][chat-image]][chat-url] Join the official Slack channel. -- [![WhatsApp][whatsapp-image]][whatsapp-url] Direct message us on WhatsApp. Or chat with fellow Shabad OS community members in the WhatsApp group chat. ## Contributing @@ -315,7 +299,7 @@ The original author and current lead maintainer of Gurmukhi Utils is Harjot Sing ## Feedback -- Ask a question via [Slack][chat-url] or [WhatsApp][whatsapp-url] +- Ask a question via [Slack][chat-url] - [Upvote popular feature requests][upvote-tracker-url] using the thumbs-up/+1 reaction on the first post of a feature request - Follow [@shabad_os on Instagram](instagram-url) and [@shabad_os on Twitter](twitter-url) and let us know what you think! @@ -323,10 +307,10 @@ The original author and current lead maintainer of Gurmukhi Utils is Harjot Sing Projects in the Shabad OS ecosystem of free and open source software which use the `gurmukhi-utils` package include: -- [Database](https://github.com/ShabadOS/database) -- [Viewer](https://github.com/ShabadOS/viewer) -- [Presenter](https://github.com/ShabadOS/presenter) -- [Mobile](https://github.com/ShabadOS/mobile) +- [Database](https://github.com/shabados/database) +- [Viewer](https://github.com/shabados/viewer) +- [Presenter](https://github.com/shabados/presenter) +- [Mobile](https://github.com/shabados/mobile) ## Code of Conduct @@ -354,12 +338,12 @@ The Shabad OS Docs repo is under v3 of the [GPL](LICENSE.md). It is similar to t [npm-url]: https://npmjs.org/package/gurmukhi-utils [downloads-image]: https://img.shields.io/npm/dm/gurmukhi-utils.svg [downloads-url]: https://npmcharts.com/compare/gurmukhi-utils?minimal=true -[release-image]: https://img.shields.io/circleci/project/github/ShabadOS/gurmukhi-utils/main.svg?label=release -[release-url]: https://circleci.com/gh/ShabadOS/gurmukhi-utils/tree/main -[next-image]: https://img.shields.io/circleci/project/github/ShabadOS/gurmukhi-utils/dev.svg?label=next%20release -[next-url]: https://circleci.com/gh/ShabadOS/gurmukhi-utils/tree/dev -[coveralls-image]: https://img.shields.io/coveralls/github/ShabadOS/gurmukhi-utils.svg?label=test%20coverage -[coveralls-url]: https://coveralls.io/github/ShabadOS/gurmukhi-utils +[release-image]: https://img.shields.io/circleci/project/github/shabados/gurmukhi-utils/main.svg?label=release +[release-url]: https://circleci.com/gh/shabados/gurmukhi-utils/tree/main +[next-image]: https://img.shields.io/circleci/project/github/shabados/gurmukhi-utils/dev.svg?label=next%20release +[next-url]: https://circleci.com/gh/shabados/gurmukhi-utils/tree/dev +[coveralls-image]: https://img.shields.io/coveralls/github/shabados/gurmukhi-utils.svg?label=test%20coverage +[coveralls-url]: https://coveralls.io/github/shabados/gurmukhi-utils [instagram-image]: https://img.shields.io/badge/Instagram-%40shabad__os-C13584.svg?logo=instagram&logoColor=white [instagram-url]: https://www.instagram.com/shabad_os/ @@ -367,10 +351,8 @@ The Shabad OS Docs repo is under v3 of the [GPL](LICENSE.md). It is similar to t [twitter-url]: https://www.twitter.com/shabad_os/ [chat-image]: https://img.shields.io/badge/Chat-Public%20Slack%20Channels-1264a3.svg?logo=slack [chat-url]: https://chat.shabados.com -[whatsapp-image]: https://img.shields.io/badge/WhatsApp-%2B1%20516%20619%206059-128C7E.svg?logo=whatsapp&logoColor=white -[whatsapp-url]: https://wa.me/15166196059 -[new-issue-url]: https://github.com/ShabadOS/gurmukhi-utils/issues/new +[new-issue-url]: https://github.com/shabados/gurmukhi-utils/issues/new [contributor-url]: https://github.com/shabados/gurmukhi-utils/graphs/contributors -[upvote-tracker-url]: https://github.com/ShabadOS/gurmukhi-utils/issues?q=is%3Aopen+is%3Aissue+label%3A%22Type%3A+Feature%2FEnhancement%22+sort%3Areactions-%2B1-desc +[upvote-tracker-url]: https://github.com/shabados/gurmukhi-utils/issues?q=is%3Aopen+is%3Aissue+label%3A%22Type%3A+Feature%2FEnhancement%22+sort%3Areactions-%2B1-desc [contributor-covenant-url]: https://www.contributor-covenant.org/version/2/0/code_of_conduct/ diff --git a/lib/stripEndings.js b/lib/stripEndings.js index 6338d22..dc8bd2c 100644 --- a/lib/stripEndings.js +++ b/lib/stripEndings.js @@ -21,11 +21,14 @@ const numberClass = getRegexClass( [ // Rahao in English, ASCII, Unicode const pauseGroup = getRegexGroup( [ 'ਰਹਾਉ', toAscii( 'ਰਹਾਉ' ), 'Pause' ] ) +// Matchers to strip out of input string const matchers = [ - // || Rahao || style endings - ` ?${endingClass} ?${pauseGroup}( .*)?${endingClass}`, - // Endings followed by any number => match the rest of the line - ` ?(${endingClass}|${optionalEndingClass}?)${numberClass}.*`, + // Any pause (ending + pause word) => match the rest of the line + ` ?${endingClass} ?${pauseGroup}.*`, + // Any ending followed by any number => match the rest of the line + ` ?(${endingClass}|${optionalEndingClass})${numberClass}.*`, + // Any sequence at the end of a line with numbers, periods, and spaces beginning with a number + ` ?${numberClass}(${numberClass}|[. ])*$`, // Clean up any lingering ending characters ` ?${brokenEndingClass}`, ` ?${endingClass}`, diff --git a/test/stripEndings.spec.js b/test/stripEndings.spec.js index 5fa7464..6ce2a0f 100644 --- a/test/stripEndings.spec.js +++ b/test/stripEndings.spec.js @@ -3,24 +3,57 @@ const { stripEndings, toAscii } = require( '..' ) const gurmukhiPassages = [ [ 'ਸੋ ਘਰੁ ਰਾਖੁ; ਵਡਾਈ ਤੋਇ ॥੧॥ ਰਹਾਉ ॥', 'ਸੋ ਘਰੁ ਰਾਖੁ; ਵਡਾਈ ਤੋਇ' ], [ 'ਹੁਕਮੁ ਪਛਾਣਿ; ਤਾ ਖਸਮੈ ਮਿਲਣਾ ॥੧॥ ਰਹਾਉ ਦੂਜਾ ॥', 'ਹੁਕਮੁ ਪਛਾਣਿ; ਤਾ ਖਸਮੈ ਮਿਲਣਾ' ], - [ 'ਨਾਮੁ ਅਧਾਰੁ ਦੀਜੈ. ਨਾਨਕ ਕਉ; ਆਨਦ ਸੂਖ ਘਨੇਰੈ ॥੨॥੧੨॥ ਛਕੇ ੨ ॥', 'ਨਾਮੁ ਅਧਾਰੁ ਦੀਜੈ. ਨਾਨਕ ਕਉ; ਆਨਦ ਸੂਖ ਘਨੇਰੈ' ], - [ 'ਜਪਿ ਜਪਿ ਨਾਮੁ ਜੀਵਾ ਤੇਰੀ ਬਾਣੀ; ਨਾਨਕ ਦਾਸ ਬਲਿਹਾਰੇ ॥੨॥੧੮॥ ਛਕੇ ੩ ॥', 'ਜਪਿ ਜਪਿ ਨਾਮੁ ਜੀਵਾ ਤੇਰੀ ਬਾਣੀ; ਨਾਨਕ ਦਾਸ ਬਲਿਹਾਰੇ' ], - [ 'ਸਹਸ ਸਿਆਣਪ ਨਹ ਮਿਲੈ, ਮੇਰੀ ਜਿੰਦੁੜੀਏ; ਜਨ ਨਾਨਕ. ਗੁਰਮੁਖਿ ਜਾਤਾ ਰਾਮ ॥੪॥੬॥ ਛਕਾ ੧ ॥', 'ਸਹਸ ਸਿਆਣਪ ਨਹ ਮਿਲੈ, ਮੇਰੀ ਜਿੰਦੁੜੀਏ; ਜਨ ਨਾਨਕ. ਗੁਰਮੁਖਿ ਜਾਤਾ ਰਾਮ' ], - [ 'ਆਇ ਮਿਲੁ ਗੁਰਸਿਖ. ਆਇ ਮਿਲੁ; ਤੂ ਮੇਰੇ ਗੁਰੂ ਕੇ ਪਿਆਰੇ ॥ ਰਹਾਉ ॥', 'ਆਇ ਮਿਲੁ ਗੁਰਸਿਖ. ਆਇ ਮਿਲੁ; ਤੂ ਮੇਰੇ ਗੁਰੂ ਕੇ ਪਿਆਰੇ' ], + [ + 'ਨਾਮੁ ਅਧਾਰੁ ਦੀਜੈ. ਨਾਨਕ ਕਉ; ਆਨਦ ਸੂਖ ਘਨੇਰੈ ॥੨॥੧੨॥ ਛਕੇ ੨ ॥', + 'ਨਾਮੁ ਅਧਾਰੁ ਦੀਜੈ. ਨਾਨਕ ਕਉ; ਆਨਦ ਸੂਖ ਘਨੇਰੈ', + ], + [ + 'ਜਪਿ ਜਪਿ ਨਾਮੁ ਜੀਵਾ ਤੇਰੀ ਬਾਣੀ; ਨਾਨਕ ਦਾਸ ਬਲਿਹਾਰੇ ॥੨॥੧੮॥ ਛਕੇ ੩ ॥', + 'ਜਪਿ ਜਪਿ ਨਾਮੁ ਜੀਵਾ ਤੇਰੀ ਬਾਣੀ; ਨਾਨਕ ਦਾਸ ਬਲਿਹਾਰੇ', + ], + [ + 'ਸਹਸ ਸਿਆਣਪ ਨਹ ਮਿਲੈ, ਮੇਰੀ ਜਿੰਦੁੜੀਏ; ਜਨ ਨਾਨਕ. ਗੁਰਮੁਖਿ ਜਾਤਾ ਰਾਮ ॥੪॥੬॥ ਛਕਾ ੧ ॥', + 'ਸਹਸ ਸਿਆਣਪ ਨਹ ਮਿਲੈ, ਮੇਰੀ ਜਿੰਦੁੜੀਏ; ਜਨ ਨਾਨਕ. ਗੁਰਮੁਖਿ ਜਾਤਾ ਰਾਮ', + ], + [ + 'ਆਇ ਮਿਲੁ ਗੁਰਸਿਖ. ਆਇ ਮਿਲੁ; ਤੂ ਮੇਰੇ ਗੁਰੂ ਕੇ ਪਿਆਰੇ ॥ ਰਹਾਉ ॥', + 'ਆਇ ਮਿਲੁ ਗੁਰਸਿਖ. ਆਇ ਮਿਲੁ; ਤੂ ਮੇਰੇ ਗੁਰੂ ਕੇ ਪਿਆਰੇ', + ], [ 'ਜਹਾ ਤੇ ਉਪਜਿਆ; ਫਿਰਿ ਤਹਾ ਸਮਾਵੈ ।੪੯।੧। ਇਕੁ ।', 'ਜਹਾ ਤੇ ਉਪਜਿਆ; ਫਿਰਿ ਤਹਾ ਸਮਾਵੈ' ], - [ 'ਇਸੁ ਬੰਦੇ ਸਿਰਿ ਜੁਲਮੁ ਹੋਤ ਹੈ; ਜਮੁ. ਨਹੀ ਹਟੈ ਗੁਸਾਈ ॥੪॥੯॥ ਦੁਤੁਕੇ', 'ਇਸੁ ਬੰਦੇ ਸਿਰਿ ਜੁਲਮੁ ਹੋਤ ਹੈ; ਜਮੁ. ਨਹੀ ਹਟੈ ਗੁਸਾਈ' ], - [ 'ਨਾਨਕ. ਮਨਿ ਤਨਿ ਚਾਉ ਏਹੁ; ਨਿਤ ਪ੍ਰਭ ਕਉ ਲੋੜੇ ॥੨੧॥੧॥ ਸੁਧੁ ਕੀਚੇ', 'ਨਾਨਕ. ਮਨਿ ਤਨਿ ਚਾਉ ਏਹੁ; ਨਿਤ ਪ੍ਰਭ ਕਉ ਲੋੜੇ' ], + [ + 'ਇਸੁ ਬੰਦੇ ਸਿਰਿ ਜੁਲਮੁ ਹੋਤ ਹੈ; ਜਮੁ. ਨਹੀ ਹਟੈ ਗੁਸਾਈ ॥੪॥੯॥ ਦੁਤੁਕੇ', + 'ਇਸੁ ਬੰਦੇ ਸਿਰਿ ਜੁਲਮੁ ਹੋਤ ਹੈ; ਜਮੁ. ਨਹੀ ਹਟੈ ਗੁਸਾਈ', + ], + [ + 'ਨਾਨਕ. ਮਨਿ ਤਨਿ ਚਾਉ ਏਹੁ; ਨਿਤ ਪ੍ਰਭ ਕਉ ਲੋੜੇ ॥੨੧॥੧॥ ਸੁਧੁ ਕੀਚੇ', + 'ਨਾਨਕ. ਮਨਿ ਤਨਿ ਚਾਉ ਏਹੁ; ਨਿਤ ਪ੍ਰਭ ਕਉ ਲੋੜੇ', + ], [ 'ਤਿਸੀ ਪ੍ਰਕਾਰ ਹੀ ਗੁਰੂ ਸੇਵਾ ਤਥਾ ਨਾਮ ਵਿਖੇ ਪਿੰਡ ਸਰੀਰ ਦੇ ਪਰਚੇ ਬਿਨਾਂ ਜੋ ਸਿੱਖਾਂ ਦੀ ਭਿਛ੍ਯਾ ਖਾਵੇ ਅਰਥਾਤ ਓਨਾਂ ਦੀ ਕਾਰ ਭੇਟ ਦਾ ਆਯਾ ਪਦਾਰਥ ਖਾਏ ਤਾਂ ਅੰਤ ਕਾਲ ਨੂੰ ਔਕੜ ਹੋਯਾ ਕਰਦੀ ਹੈ, ਤੇ ਜਮ ਲੋਕ ਨਰਕ ਨੂੰ ਜਾਣਾ ਪੈਂਦਾ ਹੈ ॥੫੧੭॥ ਪੜ੍ਹੋ ਵੀਚਾਰ ਕਬਿੱਤ ੫੦੬', 'ਤਿਸੀ ਪ੍ਰਕਾਰ ਹੀ ਗੁਰੂ ਸੇਵਾ ਤਥਾ ਨਾਮ ਵਿਖੇ ਪਿੰਡ ਸਰੀਰ ਦੇ ਪਰਚੇ ਬਿਨਾਂ ਜੋ ਸਿੱਖਾਂ ਦੀ ਭਿਛ੍ਯਾ ਖਾਵੇ ਅਰਥਾਤ ਓਨਾਂ ਦੀ ਕਾਰ ਭੇਟ ਦਾ ਆਯਾ ਪਦਾਰਥ ਖਾਏ ਤਾਂ ਅੰਤ ਕਾਲ ਨੂੰ ਔਕੜ ਹੋਯਾ ਕਰਦੀ ਹੈ, ਤੇ ਜਮ ਲੋਕ ਨਰਕ ਨੂੰ ਜਾਣਾ ਪੈਂਦਾ ਹੈ', ], - [ 'ਸ੍ਰੀ ਗੁਰੂ ਜੀ ਕਹਤੇ ਹੈਂ: ਜੋ ਰਾਤ ਦਿਨ ਨਾਮ ਜਪਤੇ ਹੈਂ ਐਸੇ ਗੁਰੋਂ ਕੇ ਮੁਖ ਸੇ ਵਾਹੁ ਵਾਹੁ ਬਾਣੀ ਪ੍ਰਾਪਤ ਹੋਤੀ ਹੈ॥੧॥', 'ਸ੍ਰੀ ਗੁਰੂ ਜੀ ਕਹਤੇ ਹੈਂ: ਜੋ ਰਾਤ ਦਿਨ ਨਾਮ ਜਪਤੇ ਹੈਂ ਐਸੇ ਗੁਰੋਂ ਕੇ ਮੁਖ ਸੇ ਵਾਹੁ ਵਾਹੁ ਬਾਣੀ ਪ੍ਰਾਪਤ ਹੋਤੀ ਹੈ' ], - [ 'ਹੇ ਨਾਨਕ! ਜੋ ਮਨੁੱਖ ਗੁਰੂ ਦੇ ਹੁਕਮ ਵਿਚ ਤੁਰਦਾ ਹੈ ਉਸ ਨੂੰ ਸਿਫ਼ਤ-ਸਾਲਾਹ ਦੀ ਦਾਤ ਮਿਲਦੀ ਹੈ, ਉਹ ਹਰ ਵੇਲੇ ਪ੍ਰਭੂ ਦਾ ਨਾਮ ਜਪਦਾ ਹੈ ॥੧॥', 'ਹੇ ਨਾਨਕ! ਜੋ ਮਨੁੱਖ ਗੁਰੂ ਦੇ ਹੁਕਮ ਵਿਚ ਤੁਰਦਾ ਹੈ ਉਸ ਨੂੰ ਸਿਫ਼ਤ-ਸਾਲਾਹ ਦੀ ਦਾਤ ਮਿਲਦੀ ਹੈ, ਉਹ ਹਰ ਵੇਲੇ ਪ੍ਰਭੂ ਦਾ ਨਾਮ ਜਪਦਾ ਹੈ' ], - [ 'ਸ੍ਰੀ ਗੁਰੂ ਜੀ ਕਹਤੇ ਹੈਂ: ਸੋ ਹਰਿ ਨਾਮ ਕਾ ਜੋ ਰਾਤ ਦਿਨ ਭਜਨ ਕਰਤਾ ਹੈ ਤਿਸ ਕੇ ਸਭ ਕਾਮ ਸਫਲ ਹੋਤੇ ਹੈਂ ਅਰਥਾਤ ਪੂਰਨ ਕਾਮ ਹੋਤਾ ਹੈ॥੨੦', 'ਸ੍ਰੀ ਗੁਰੂ ਜੀ ਕਹਤੇ ਹੈਂ: ਸੋ ਹਰਿ ਨਾਮ ਕਾ ਜੋ ਰਾਤ ਦਿਨ ਭਜਨ ਕਰਤਾ ਹੈ ਤਿਸ ਕੇ ਸਭ ਕਾਮ ਸਫਲ ਹੋਤੇ ਹੈਂ ਅਰਥਾਤ ਪੂਰਨ ਕਾਮ ਹੋਤਾ ਹੈ' ], + [ + 'ਸ੍ਰੀ ਗੁਰੂ ਜੀ ਕਹਤੇ ਹੈਂ: ਜੋ ਰਾਤ ਦਿਨ ਨਾਮ ਜਪਤੇ ਹੈਂ ਐਸੇ ਗੁਰੋਂ ਕੇ ਮੁਖ ਸੇ ਵਾਹੁ ਵਾਹੁ ਬਾਣੀ ਪ੍ਰਾਪਤ ਹੋਤੀ ਹੈ॥੧॥', + 'ਸ੍ਰੀ ਗੁਰੂ ਜੀ ਕਹਤੇ ਹੈਂ: ਜੋ ਰਾਤ ਦਿਨ ਨਾਮ ਜਪਤੇ ਹੈਂ ਐਸੇ ਗੁਰੋਂ ਕੇ ਮੁਖ ਸੇ ਵਾਹੁ ਵਾਹੁ ਬਾਣੀ ਪ੍ਰਾਪਤ ਹੋਤੀ ਹੈ', + ], + [ + 'ਹੇ ਨਾਨਕ! ਜੋ ਮਨੁੱਖ ਗੁਰੂ ਦੇ ਹੁਕਮ ਵਿਚ ਤੁਰਦਾ ਹੈ ਉਸ ਨੂੰ ਸਿਫ਼ਤ-ਸਾਲਾਹ ਦੀ ਦਾਤ ਮਿਲਦੀ ਹੈ, ਉਹ ਹਰ ਵੇਲੇ ਪ੍ਰਭੂ ਦਾ ਨਾਮ ਜਪਦਾ ਹੈ ॥੧॥', + 'ਹੇ ਨਾਨਕ! ਜੋ ਮਨੁੱਖ ਗੁਰੂ ਦੇ ਹੁਕਮ ਵਿਚ ਤੁਰਦਾ ਹੈ ਉਸ ਨੂੰ ਸਿਫ਼ਤ-ਸਾਲਾਹ ਦੀ ਦਾਤ ਮਿਲਦੀ ਹੈ, ਉਹ ਹਰ ਵੇਲੇ ਪ੍ਰਭੂ ਦਾ ਨਾਮ ਜਪਦਾ ਹੈ', + ], + [ + 'ਸ੍ਰੀ ਗੁਰੂ ਜੀ ਕਹਤੇ ਹੈਂ: ਸੋ ਹਰਿ ਨਾਮ ਕਾ ਜੋ ਰਾਤ ਦਿਨ ਭਜਨ ਕਰਤਾ ਹੈ ਤਿਸ ਕੇ ਸਭ ਕਾਮ ਸਫਲ ਹੋਤੇ ਹੈਂ ਅਰਥਾਤ ਪੂਰਨ ਕਾਮ ਹੋਤਾ ਹੈ॥੨੦', + 'ਸ੍ਰੀ ਗੁਰੂ ਜੀ ਕਹਤੇ ਹੈਂ: ਸੋ ਹਰਿ ਨਾਮ ਕਾ ਜੋ ਰਾਤ ਦਿਨ ਭਜਨ ਕਰਤਾ ਹੈ ਤਿਸ ਕੇ ਸਭ ਕਾਮ ਸਫਲ ਹੋਤੇ ਹੈਂ ਅਰਥਾਤ ਪੂਰਨ ਕਾਮ ਹੋਤਾ ਹੈ', + ], [ '॥ ਜਪੁ ॥', 'ਜਪੁ' ], [ 'ਸੋ ਦਰੁ ਰਾਗੁ ਆਸਾ ਮਹਲਾ ੧', 'ਸੋ ਦਰੁ ਰਾਗੁ ਆਸਾ ਮਹਲਾ' ], - [ 'ਸੂਰਜੁ; ਏਕੋ ਰੁਤਿ ਅਨੇਕ ॥ ਨਾਨਕ ਕਰਤੇ ਕੇ ਕੇਤੇ ਵੇਸ ॥੨॥੨॥', 'ਸੂਰਜੁ; ਏਕੋ ਰੁਤਿ ਅਨੇਕ ਨਾਨਕ ਕਰਤੇ ਕੇ ਕੇਤੇ ਵੇਸ' ], - [ 'ਭਇਓ ਕ੍ਰਿਪਾਲੁ. ਦੀਨ ਦੁਖ ਭੰਜਨੁ; ਹਰਿ ਹਰਿ ਕੀਰਤਨਿ ਇਹੁ ਮਨੁ ਰਾਤਾ ॥ ਰਹਾਉ ਦੂਜਾ ॥੧॥੩॥', 'ਭਇਓ ਕ੍ਰਿਪਾਲੁ. ਦੀਨ ਦੁਖ ਭੰਜਨੁ; ਹਰਿ ਹਰਿ ਕੀਰਤਨਿ ਇਹੁ ਮਨੁ ਰਾਤਾ' ], + [ + 'ਸੂਰਜੁ; ਏਕੋ ਰੁਤਿ ਅਨੇਕ ॥ ਨਾਨਕ ਕਰਤੇ ਕੇ ਕੇਤੇ ਵੇਸ ॥੨॥੨॥', + 'ਸੂਰਜੁ; ਏਕੋ ਰੁਤਿ ਅਨੇਕ ਨਾਨਕ ਕਰਤੇ ਕੇ ਕੇਤੇ ਵੇਸ', + ], + [ + 'ਭਇਓ ਕ੍ਰਿਪਾਲੁ. ਦੀਨ ਦੁਖ ਭੰਜਨੁ; ਹਰਿ ਹਰਿ ਕੀਰਤਨਿ ਇਹੁ ਮਨੁ ਰਾਤਾ ॥ ਰਹਾਉ ਦੂਜਾ ॥੧॥੩॥', + 'ਭਇਓ ਕ੍ਰਿਪਾਲੁ. ਦੀਨ ਦੁਖ ਭੰਜਨੁ; ਹਰਿ ਹਰਿ ਕੀਰਤਨਿ ਇਹੁ ਮਨੁ ਰਾਤਾ', + ], [ 'ਕਿ ਹਰ ਹਸ਼ਤੋ ਸ਼ਸਤ ਆਮਦਾ ਚਾਕਰਸ਼ ।੧੪੮।', 'ਕਿ ਹਰ ਹਸ਼ਤੋ ਸ਼ਸਤ ਆਮਦਾ ਚਾਕਰਸ਼' ], ] @@ -30,31 +63,77 @@ const asciiPassages = gurmukhiPassages.map( ( [ input, output ] ) => [ ] ) const translationPassages = [ - [ 'True Here And Now. O Nanak, Forever And Ever True. ||1||', 'True Here And Now. O Nanak, Forever And Ever True.' ], + [ + 'True Here And Now. O Nanak, Forever And Ever True. ||1||', + 'True Here And Now. O Nanak, Forever And Ever True.', + ], [ "By Guru's Grace, the supreme status is obtained, and the dry wood blossoms forth again in lush greenery. ||1||Pause||", "By Guru's Grace, the supreme status is obtained, and the dry wood blossoms forth again in lush greenery.", ], - [ 'He puts on various ornaments and many decorations, but it is like dressing a corpse. ||Pause||', 'He puts on various ornaments and many decorations, but it is like dressing a corpse.' ], - [ 'Servant Nanak is devoted, dedicated, forever a sacrifice to You, Lord. Your Expanse has no limit, no boundary. ||4||5||', 'Servant Nanak is devoted, dedicated, forever a sacrifice to You, Lord. Your Expanse has no limit, no boundary.' ], - [ 'lifts him to the divine level of supreme consciousness. (103', 'lifts him to the divine level of supreme consciousness.' ], - [ 'What is the purpose of my life (it became worthless) without your reminiscence.(1) (3)', 'What is the purpose of my life (it became worthless) without your reminiscence.' ], + [ + 'He puts on various ornaments and many decorations, but it is like dressing a corpse. ||Pause||', + 'He puts on various ornaments and many decorations, but it is like dressing a corpse.', + ], + [ + 'Servant Nanak is devoted, dedicated, forever a sacrifice to You, Lord. Your Expanse has no limit, no boundary. ||4||5||', + 'Servant Nanak is devoted, dedicated, forever a sacrifice to You, Lord. Your Expanse has no limit, no boundary.', + ], + [ + 'lifts him to the divine level of supreme consciousness. (103', + 'lifts him to the divine level of supreme consciousness.', + ], + [ + 'What is the purpose of my life (it became worthless) without your reminiscence.(1) (3)', + 'What is the purpose of my life (it became worthless) without your reminiscence.', + ], [ 'Just one of his (blessed) looks, that prolongs life instantly, is enough for me." (2) (2)\nSometimes, he acts like a mystic, sometimes like a meditator, and other times like a carefree recluse;\nHe is our pilot steering our way; he operates in numerous different postures. (2) (3)', 'Just one of his (blessed) looks, that prolongs life instantly, is enough for me."\nSometimes, he acts like a mystic, sometimes like a meditator, and other times like a carefree recluse;\nHe is our pilot steering our way; he operates in numerous different postures.', ], [ 'always I live within the Khalsa. 519', 'always I live within the Khalsa.' ], - [ 'Salutation to Thee O Abodeless Lord! 5', 'Salutation to Thee O Abodeless Lord!' ], - [ 'Thy Virtues like Generosity are countless.91', 'Thy Virtues like Generosity are countless.' ], + [ + 'Salutation to Thee O Abodeless Lord! 5', + 'Salutation to Thee O Abodeless Lord!', + ], + [ + 'Thy Virtues like Generosity are countless.91', + 'Thy Virtues like Generosity are countless.', + ], [ 'It was Bikrami Samvat 1753', 'It was Bikrami Samvat' ], - [ 'He also forgot the unmanifested Brahmin and said this583', 'He also forgot the unmanifested Brahmin and said this' ], - [ 'Somewhere Thou art manifesting the mode of Tamas in a kingly mood! 16. 106', 'Somewhere Thou art manifesting the mode of Tamas in a kingly mood!' ], - [ 'He is Without blemish and stain and be visualised as consisting of Indestructible Glory .16.176', 'He is Without blemish and stain and be visualised as consisting of Indestructible Glory .' ], - [ 'He is the Sustainer of all the beings and creatures!9. 239', 'He is the Sustainer of all the beings and creatures!' ], + [ + 'He also forgot the unmanifested Brahmin and said this583', + 'He also forgot the unmanifested Brahmin and said this', + ], + [ + 'Somewhere Thou art manifesting the mode of Tamas in a kingly mood! 16. 106', + 'Somewhere Thou art manifesting the mode of Tamas in a kingly mood!', + ], + [ + 'He is Without blemish and stain and be visualised as consisting of Indestructible Glory .16.176', + 'He is Without blemish and stain and be visualised as consisting of Indestructible Glory .', + ], + [ + 'He is the Sustainer of all the beings and creatures!9. 239', + 'He is the Sustainer of all the beings and creatures!', + ], [ 'Thee as the Abode of Dharma.2.254', 'Thee as the Abode of Dharma.' ], - [ 'He said to the warriors fighting near him,1069', 'He said to the warriors fighting near him,' ], - [ 'Noche y día oh, dice Nanak, quien medite y vibre en el Nombre del Señor, ve cómo todos sus esfuerzos dan fruto. (20)', 'Noche y día oh, dice Nanak, quien medite y vibre en el Nombre del Señor, ve cómo todos sus esfuerzos dan fruto.' ], - [ 'A tal ser el Señor lo encuentra y nunca más lo abandona, ya que lo inmerge en Su Paz Maravillosa. ()1', 'A tal ser el Señor lo encuentra y nunca más lo abandona, ya que lo inmerge en Su Paz Maravillosa.' ], + [ + 'He said to the warriors fighting near him,1069', + 'He said to the warriors fighting near him,', + ], + [ + 'Through 8.4 million incarnations you have wandered', + 'Through 8.4 million incarnations you have wandered', + ], + [ + 'Noche y día oh, dice Nanak, quien medite y vibre en el Nombre del Señor, ve cómo todos sus esfuerzos dan fruto. (20)', + 'Noche y día oh, dice Nanak, quien medite y vibre en el Nombre del Señor, ve cómo todos sus esfuerzos dan fruto.', + ], + [ + 'A tal ser el Señor lo encuentra y nunca más lo abandona, ya que lo inmerge en Su Paz Maravillosa. ()1', + 'A tal ser el Señor lo encuentra y nunca más lo abandona, ya que lo inmerge en Su Paz Maravillosa.', + ], [ 'Misteriosa es la manera de los verdaderos Discípulos, porque no solamente escuchan la Instrucción del Guru, sino que se encuentran totalmente sobrellevados por ella. 25', 'Misteriosa es la manera de los verdaderos Discípulos, porque no solamente escuchan la Instrucción del Guru, sino que se encuentran totalmente sobrellevados por ella.', @@ -63,23 +142,28 @@ const translationPassages = [ 'El mundo ha nacido para morir y es siempre destruido, una, otra, y otra vez; solamente uno se vuelve Eterno aferrándose a los Pies del Guru. (4‑6‑13', 'El mundo ha nacido para morir y es siempre destruido, una, otra, y otra vez; solamente uno se vuelve Eterno aferrándose a los Pies del Guru.', ], - [ 'Toda la Maya es Tu Deleite. Nanak, Tu Esclavo, ofrece su ser en sacrificio a Ti. (4-2-9)', 'Toda la Maya es Tu Deleite. Nanak, Tu Esclavo, ofrece su ser en sacrificio a Ti.' ], - [ 'ese hombre ha recibido la Aprobación de Dios. (4-40-47)', 'ese hombre ha recibido la Aprobación de Dios.' ], - [ 'स्री गुरू जी कहते हैं: जो रात दिन नाम जपते हैं ऐसे गुरों के मुख से वाहु वाहु बाणी प्रापत होती है॥१॥', 'स्री गुरू जी कहते हैं: जो रात दिन नाम जपते हैं ऐसे गुरों के मुख से वाहु वाहु बाणी प्रापत होती है' ], - [ 'नानक. मनि तनि चाउ एहु; नित प्रभ कउ लोड़े ॥२१॥१॥ सुधु कीचे', 'नानक. मनि तनि चाउ एहु; नित प्रभ कउ लोड़े' ], + [ + 'Toda la Maya es Tu Deleite. Nanak, Tu Esclavo, ofrece su ser en sacrificio a Ti. (4-2-9)', + 'Toda la Maya es Tu Deleite. Nanak, Tu Esclavo, ofrece su ser en sacrificio a Ti.', + ], + [ + 'ese hombre ha recibido la Aprobación de Dios. (4-40-47)', + 'ese hombre ha recibido la Aprobación de Dios.', + ], + [ + 'स्री गुरू जी कहते हैं: जो रात दिन नाम जपते हैं ऐसे गुरों के मुख से वाहु वाहु बाणी प्रापत होती है॥१॥', + 'स्री गुरू जी कहते हैं: जो रात दिन नाम जपते हैं ऐसे गुरों के मुख से वाहु वाहु बाणी प्रापत होती है', + ], + [ + 'नानक. मनि तनि चाउ एहु; नित प्रभ कउ लोड़े ॥२१॥१॥ सुधु कीचे', + 'नानक. मनि तनि चाउ एहु; नित प्रभ कउ लोड़े', + ], ] -const passages = [ - ...gurmukhiPassages, - ...asciiPassages, - ...translationPassages, -] +const passages = [ ...gurmukhiPassages, ...asciiPassages, ...translationPassages ] describe( 'stripEndings()', () => { - passages.map( ( [ line, result ] ) => it( - `should transform '${line}' to '${result}'`, - () => { - expect( stripEndings( line ) ).toBe( result ) - }, - ) ) + passages.map( ( [ line, result ] ) => it( `should transform '${line}' to '${result}'`, () => { + expect( stripEndings( line ) ).toBe( result ) + } ) ) } )