-
-
Save AungWinnHtut/cbb97992313f5fb12a7b65f9b5057b82 to your computer and use it in GitHub Desktop.
Inserting ZWSP between every syllables for better text wrapping for Myanmar text.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html lang="en-US"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Break Wrap</title> | |
<style> | |
body { | |
background: #efefdd; | |
} | |
ul { | |
font: 15px/30px Myanmar3,TharLon,Yunghkio; | |
width: 360px; | |
margin: 20px auto; | |
padding: 25px 25px 25px 40px; | |
border: 4px solid #ddd; | |
border-radius: 5px; | |
background: #FFF; | |
} | |
</style> | |
<script> | |
window.onload = function() { | |
li = document.getElementsByTagName("li"); | |
for(var i=0; i < li.length; i++) { | |
li[i].innerHTML = insert_zwsp( li[i].innerHTML ); | |
} | |
}; | |
function insert_zwsp(str) { | |
var consonants = [ | |
"က","ခ","ဂ","ဃ","င", | |
"စ","ဆ","ဇ","ဈ","ည", | |
"ဍ","ဌ","ဋ","ဎ","ဏ", | |
"တ", "ထ","ဒ","ဓ","န", | |
"ပ","ဖ","ဗ","ဘ","မ", | |
"ယ","ရ","လ","ဝ","သ", | |
"ဟ","ဠ","အ", | |
"ဿ","ဦ","ဥ" ,"ဩ","ဣ" | |
]; | |
var len = str.length; | |
var new_str = ""; | |
for(var i=0; i<len; i++) { | |
chr = str.substr(i, 1); | |
if(inArray(chr,consonants)) { | |
if(str.substr(i + 1, 1) != "်" && | |
(str.substr(i + 1, 1) != "့" && str.substr(i + 2, 1) != "်")) { | |
new_str += "\u200B"; //ZWSP | |
} | |
} | |
new_str += chr; | |
} | |
return new_str; | |
} | |
function inArray(needle, haystack) { | |
var length = haystack.length; | |
for(var i = 0; i < length; i++) { | |
if(haystack[i] == needle) return true; | |
} | |
return false; | |
} | |
</script> | |
</head> | |
<body> | |
<ul> | |
<li>မြန်မာစာရေးရာတွင်စကားစုတစ်ခုနှင့်တစ်ခုကြားတွင်စပေ့များထည့်ရန်မလိုပေ။</li> | |
<li>ထို့ကြောင့်မြန်မာစာစကားစုပိုင်းဖြတ်ပုံကိုနားမလည်သည့်ကွန်ပျူတာနည်းပညာများသည်၊</li> | |
<li>မြန်မာစာစကားစုများကိုအဆင်ပြေချောမွေ့စွာညှိနှိုင်းစီစဉ်းပေးခြင်းများပြုလုပ်နိုင်လိမ့်မည်မဟုတ်ပါ။</li> | |
<li>ထို့ကြောင့်ရေးသားသူများကရေးသားစဉ်တွင်မကြာမကြာစပေ့များကိုလိုအပ်သလိုထည့်ပေးရန်အထူးသဖြင့်လိုအပ်မည်ဖြစ်သည်။ဤစမ်းသပ်မှု့သည်စကားစုဖြတ်ထုံးမလိုအပ်ပဲအိပ်ချ်တီအမ်အယ်လ်စာမျက်မှာပေါ်တွင်စာများကိုအလိုအလျှောက်စီစဉ်ပေးနိုင်မည့်စခရစ်ဖြစ်ပါသည်။</li> | |
</ul> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ေက်းဇူးတင္ပါတယ္ ခင္ဗ်ာ