From 76925a687018fd7c6a5e22ab35ec5695f5068755 Mon Sep 17 00:00:00 2001 From: "Bhajneet S.K" Date: Tue, 3 Nov 2020 13:24:38 -0500 Subject: [PATCH] fix(toEnglish): properly detect word boundaries (#177) #Patch release Co-authored-by: Harjot Singh --- lib/toEnglish.js | 2 +- test/toEnglish.spec.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/toEnglish.js b/lib/toEnglish.js index e931c6b..31d271f 100644 --- a/lib/toEnglish.js +++ b/lib/toEnglish.js @@ -106,7 +106,7 @@ const replacements = [ [ /mÚ/g, 'mhlw' ], // Mehla replcement [ /i(.)/g, '$1i' ], // Place sihari in correct position [ /(.)[i]([R®H§´ÍÏ眘†])/ug, '$1$2i' ], // Move sihari in front of pairin akhars - [ new RegExp( `(\\S[^ha])([iu])([\\s$${vishraams.join( '' )}])`, 'ug' ), '$1$3' ], // Remove trailing Aunkar (u) and Sihari (i) except when on Haha (h), Ooraa (a), or on a standalone akhar + [ new RegExp( `(\\S[^ha])[iu]([${vishraams.join( '' )}]|\\b)`, 'ug' ), '$1$2' ], // Remove trailing Aunkar (u) and Sihari (i) except when on Haha (h), Ooraa (a), or on a standalone akhar [ new RegExp( `(\\b\\S)h([^iIuUyYwWoONM§¨®´µÍÏçüœˆ˜†]\\b|[${vishraams.join( '' )}])`, 'ug' ), '$1yh$2' ], // Add y to three consonant letter words with haha in middle per issue #123 ] diff --git a/test/toEnglish.spec.js b/test/toEnglish.spec.js index fbec496..d46152c 100644 --- a/test/toEnglish.spec.js +++ b/test/toEnglish.spec.js @@ -24,6 +24,12 @@ const transliterations = [ [ 'ਸਹਜ; ਸਸਹਜ ਅਨਹਦ ਰਹਤ ਕਹਤ ਪਹਰ, ਸਹਸ ਮਹਲ ਟਹਲ ਕਹਨਨ ਕਹਨ', 'sehaj; sasahaj anahad rehat kehat pehar, sehas mehal ttehal kahanan kehan' ], [ 'ਸਭ ਭਇਓ ਪਰਾਇਓ', 'sabh bheo paraaeo' ], [ 'ਆਸਾ ਮਹਲਾ ੫ ਪੰਚਪਦੇ₃ ॥', 'aasaa mahalaa 5 panchapade₃ |' ], + [ 'ਹਰਿ', 'har' ], + [ 'ਸਚੁ', 'sach' ], + [ 'ਰਾਹੁ', 'raahu' ], + [ 'ਭਾਉ', 'bhaau' ], + [ 'ਸਤਿਗੁਰੁ ਸਤਿਗੁਰੁ ਸਚੁ; ਸਚੁ ਹਰਿ ਹਰਿ ਹਿੰਙੁ', 'satigur satigur sach; sach har har hing' ], + [ 'ਸੁ ਉ ਜੁ', 'su u ju' ], ] describe( 'toEnglish()', () => {