From 5a0359dceacc05271b243cb85fc4d750ede56e38 Mon Sep 17 00:00:00 2001 From: Sahatsawat Kanpai Date: Wed, 15 Jan 2025 15:34:07 +0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=AA=91=20table=20style=20pre-processing?= =?UTF-8?q?=20before=20inquiries=20for=20docx,=20with=20time=20table=20exa?= =?UTF-8?q?mples=20=E2=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sample/index.html | 64 +++++++++++++++++++++++++++++++++++++---------- src/export.ts | 29 +++++++++++++++++++++ 2 files changed, 80 insertions(+), 13 deletions(-) diff --git a/sample/index.html b/sample/index.html index 1d4b06e..ac31c8f 100644 --- a/sample/index.html +++ b/sample/index.html @@ -26,26 +26,64 @@

ถ้าจะต้องรายงานค่าเฉลี่ยของการวัดความยาวครั้งนี้  - + style="font-size:16pt;">   +    และรายงานความคลายเคลื่อนของความยาวเฉลี่ย  - -  ด้วยสูตร

+ style="font-family:'Angsana New', serif;font-size:16pt;">และรายงานความคลายเคลื่อนของความยาวเฉลี่ย    +   + ด้วยสูตร

- +     

-

เมื่อ  - -  และ  - -  คือ ค่าที่มากที่สุด +

เมื่อ    +   + และ    +   + คือ ค่าที่มากที่สุด และค่าที่น้อยที่สุดของข้อมูล ตามลำดับ

ข้อใดแสดงผลการรายงานการวัดความยาวได้ถูกต้อง

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ตารางเรียนปีการศึกษา 2567 ภาคปลาย (Spring2024)
วันเวลา0900 - 12001300 - 16001630 - 1900
วันพฤหัสProb StatSeminarComSys Security
lathmive + + + + + +
+
diff --git a/src/export.ts b/src/export.ts index fd00d7a..19e2b03 100644 --- a/src/export.ts +++ b/src/export.ts @@ -52,12 +52,41 @@ export default class Export extends Plugin { const parser = new DOMParser(); const doc = parser.parseFromString(this.editor.getData(), "text/html"); + // pre-process mathlive script to html MathML tag with the help of temml for (const mathliveElement of doc.querySelectorAll('script[type="math/tex"]')) { const temmlWrapperElement = document.createElement('span'); const temmlMathMLString = Temml.render(mathliveElement.textContent ?? "", temmlWrapperElement); mathliveElement.replaceWith(temmlWrapperElement); } + // pre-process for table + for (const table of doc.querySelectorAll('table')) { + // pre-process table for border and centering and inner border + table.style.borderCollapse = 'collapse'; + table.style.borderSpacing = '0'; + table.style.border = '1px solid #b3b3b3'; + table.style.margin = 'auto'; + // pre-process table for padding + for (const td of table.querySelectorAll('td')) { + td.style.padding = '8px'; + } + // pre-process table for inner border + for (const tr of table.querySelectorAll('tr')) { + for (const td of tr.querySelectorAll('td')) { + td.style.border = '1px solid #b3b3b3'; + } + } + // pre-process table for header background color rgba(0,0,0,.05) to hex #f2f2f2 + // and it's own border + // and padding + const ths = table.querySelectorAll('th'); + for (const th of ths) { + th.style.backgroundColor = '#f2f2f2'; + th.style.border = '1px solid #b3b3b3'; + th.style.padding = '8px'; + } + } + console.log(doc.body.innerHTML); fetch('http://localhost:8080/aspose/html-to-word', {