//get text from textarea let inputText = document.getElementById("thm").innerHTML; console.log(inputText); //splite new line by regex let newLineArr = inputText.split(/\n/g) //find length let newLineArrLen = newLineArr.length; //make variable let HTMLTableOutput = ""; // looping for create new line on display for (let i = 0; i < newLineArrLen; i++) { HTMLTableOutput += "
| /gm, ' | ");
HTMLTableOutput = HTMLTableOutput.replace(/1/g, 'ด');
HTMLTableOutput = HTMLTableOutput.replace(/%ด/g, '1');
HTMLTableOutput = HTMLTableOutput.replace(/2/g, 'ร');
HTMLTableOutput = HTMLTableOutput.replace(/3/g, 'ม');
HTMLTableOutput = HTMLTableOutput.replace(/4/g, 'ฟ');
HTMLTableOutput = HTMLTableOutput.replace(/5/g, 'ซ');
HTMLTableOutput = HTMLTableOutput.replace(/6/g, 'ล');
HTMLTableOutput = HTMLTableOutput.replace(/7/g, 'ท');
HTMLTableOutput = HTMLTableOutput.replace(/7/g, 'ท');
HTMLTableOutput = HTMLTableOutput.replace(/8/g, 'ดํ');
HTMLTableOutput = HTMLTableOutput.replace(/9/g, 'รํ');
// HTMLTableOutput = HTMLTableOutput.replace(/\+/g, 'มํ');
//สัญลักษณ์เสียงสูง
HTMLTableOutput = HTMLTableOutput.replace(/\*/g, 'ํ');
//สัญลักษณ์เสียงต่ำ
HTMLTableOutput = HTMLTableOutput.replace(/\./g, 'ฺ');
//ช่องว่าง
HTMLTableOutput = HTMLTableOutput.replace(/\\s/g, ' ');
HTMLTableOutput = HTMLTableOutput.replace(/\_/g, ' ');
//โน้ตตัวเล็ก >> สำหรับการวาดเส้นโค้งที่สื่อถึงการสะบัด
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํฺ]{1,5})<\/small>/g, '$1');
//คันชักออก
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํฺ])\{/g, '$1<');
//คันชักเข้า
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํฺ])\}/g, '$1>');
//เครื่องหมายโน้ตบวก
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลท])\+/g, '$1+');
//เครื่อหมายโน้ตลบ
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลท])\_/g, '$1-');
//เครื่องหมายโน้ตกลาง
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลท])\o/g, '$1º');
//เครื่องหมายพรม
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])t/g, '$1𝆱');
//ตัวเลขแสดงตำแหน่งนิ้วซอและจะเข้
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\\([๑๒๓๔๕๖๗๘๙๐ชกน])/g, '$1$2');
//ตัวเลขแสดงตำแหน่งนิ้วซอ เลขโรมัน
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\\(iiiii)/g, '$15');
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\\(iiii)/g, '$14');
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\\(iii)/g, '$13');
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\\(ii)/g, '$12');
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\\(i)/g, '$11');
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\\(0)/g, '$10');
//ตัวเลขแสดงตำแหน่งนิ้วซอ เลขโรมัน แสดงเลขด้านล่าง
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/(iiiiiiii)/g, '$18');
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/(e)/g, '$18');
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/(iiiiiii)/g, '$17');
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/(iiiiii)/g, '$16');
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/(s)/g, '$16');
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/(iiiii)/g, '$15');
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/(iiii)/g, '$14');
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/(f)/g, '$14');
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/(iii)/g, '$13');
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/(ii)/g, '$12');
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/(t)/g, '$12');
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/(i)/g, '$11');
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/([+])/g, '$1+');
//แสดงสายลวดจะเข้+มือซ้ายขิม
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\\([+])/g, '$1$2');
////ส่วนของการแปลงเลข สำหรับแสดงผลตัวเลข
//แปลงเลขไทยเป็นอาราบิก
HTMLTableOutput = HTMLTableOutput.replace(/๑/g, '1');
HTMLTableOutput = HTMLTableOutput.replace(/๒/g, '2');
HTMLTableOutput = HTMLTableOutput.replace(/๓/g, '3');
HTMLTableOutput = HTMLTableOutput.replace(/๔/g, '4');
HTMLTableOutput = HTMLTableOutput.replace(/๕/g, '5');
HTMLTableOutput = HTMLTableOutput.replace(/๖/g, '6');
HTMLTableOutput = HTMLTableOutput.replace(/๗/g, '7');
HTMLTableOutput = HTMLTableOutput.replace(/๘/g, '8');
HTMLTableOutput = HTMLTableOutput.replace(/๙/g, '9');
HTMLTableOutput = HTMLTableOutput.replace(/๐/g, '0');
//เครื่องหมายดีดเข้า
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])v/g, '$1𝆫');
//เครื่องหมายดีดออก
HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ๑๒๓๔๕๖๗๘๙๐])\^/g, '$1𝆫');
//แปลงคำ next เป็น tag page เพื่อสร้าง page break สาหรับการพิมพ์
HTMLTableOutput = HTMLTableOutput.replace(/| next<\/td><\/tr>/gm, " | repeat<\/td><\/tr>/g, ' | | | | | | | | กลับต้น | /gm, ' | <\/td><\/tr>/g, '<\/table> | |