intro-irre: แปลงตำราวิศวกรรมชลประทานเบื้องต้นเป็นเว็บเอกสาร 10 บท

- tools/extract.py: PDF 300 หน้า -> extracted/pages.json + crop ภาพ/ตาราง/สมการ 423 รูป
  (ถอด PUA วรรณยุกต์ไทย, รวมสระอำ, แยกหัวข้อที่ระดับ span)
- tools/build.py: generator หน้า docs แบบ static (สารบัญซ้าย/เนื้อหา/ในหน้านี้)
- index.html + chapters/ch01..10.html + css/docs.css + js/docs.js
  (ธีม K2D, ค้นหาเต็มเล่มผ่าน data/search.json, dark mode, drawer มือถือ)
- README.md: วิธี build และข้อจำกัดที่รู้อยู่
This commit is contained in:
Bkk1234 committed 2026-11-19 01:34:49 +07:00
1 parent 22c28f0708
commit 4f74a509d5
454 files changed
+21280

No files matched your search

+57
View File
@@ -0,0 +1,57 @@
# intro-irre — วิศวกรรมชลประทานเบื้องต้น (เว็บเอกสาร)
แปลงตำราต้นฉบับ `Intro-Irri-Eng.pdf` (300 หน้า, 10 บท) เป็นเว็บเอกสารแบบ static
โครงหน้าตาล้อกับ docs.julialang.org: สารบัญซ้าย · เนื้อหากลาง · "ในหน้านี้" ขวา · ค้นหาเต็มเล่ม
```
index.html หน้าปก + สารบัญการ์ด + สถิติ
chapters/ch01..10.html หนึ่งไฟล์ต่อหนึ่งบท (หัวข้อเป็น anchor ไม่ reload)
css/docs.css ธีมทั้งหมด (โทเคนสี/ฟอนต์/สเปซที่หัวไฟล์)
js/docs.js theme, drawer มือถือ, search modal, scrollspy
data/search.json ดัชนีค้นหา (ระดับย่อหน้า 1,489 รายการ)
data/nav.json สารบัญแบบ tree
assets/figures/*.jpg ภาพ/ตาราง/สมการที่ crop จาก PDF (423 รูป)
assets/cover.jpg หน้าปกที่ render จากหน้าแรก
fonts/k2d-*.woff2 ฟอนต์ K2D (ไทย+ละติน) ฝังในโปรเจกต์
extracted/pages.json ผลถอดข้อความดิบ (แหล่งข้อมูลของ build)
tools/extract.py PDF → pages.json + ภาพ
tools/build.py pages.json → HTML/ดัชนี
```
## สร้างใหม่
```bash
python tools/extract.py # ~2 นาที (ต้องมี pymupdf: uv pip install pymupdf)
python tools/build.py # ไม่กี่วินาที
python -m http.server 8090 # เปิด http://localhost:8090
```
`extract.py` อ่าน PDF จาก path คงที่ (`DEFAULT_PDF`) — แก้ที่หัวไฟล์ถ้าย้ายไฟล์ต้นฉบับ
## หลักการถอดข้อความ
ต้นฉบับพิมพ์ด้วยฟอนต์ไทยรุ่นเก่า (AngsanaNew / EucrosiaUPC) มี 3 กับดักที่ต้องจัดการ:
1. **วรรณยุกต์กลายเป็น PUA** — subset font จ่ายรหัส `U+F70A…` แทน ่ ้ ๊ ๋ ็ ์ ิ ี ั
→ แปลงกลับด้วย `PUA_MAP` ใน `norm()` ก่อนอย่างอื่นทั้งหมด
2. **สระอำแตกเป็น นิคหิต + า** — รวมกลับเป็น U+0E33
3. **สมการ/ตารางเส้น/ภาพ อ่านเป็นข้อความไม่ได้** (`64)5.5(2×π`)
→ ตรวจ "band" จาก image block + drawing + block สมการ แล้ว render เป็น JPEG
แปะกลับในลำดับอ่าน พร้อม caption ที่ผูกกับรูปที่อยู่ใกล้ที่สุด
หัวข้อผ่าที่ระดับ **span** ไม่ใช่บรรทัด เพราะบท 5–10 พิมพ์หัวข้อไว้บรรทัดเดียวกับเนื้อเรื่อง
(`5.1. หัวใจ…` ตามด้วยเนื้อหาทันที) — ใช้ run ตัวหนาที่ขึ้นต้นบรรทัดเป็นตัวแบ่ง
## ข้อจำกัดที่รู้อยู่
- หัวข้อบท 5–10 ที่ไม่ได้ทำตัวหนาและไม่ขึ้นบรรทัดใหม่ จะตกไปเป็นย่อหน้าธรรมดา
(เช่น `5.2 คุณสมบัติของดิน…` หายจากสารบัญ) — ถ้าได้ไฟล์ `.docx` ต้นฉบับจะแก้ได้ตรงจุด
- ตารางและสมการเป็น **ภาพ** ค้นหาข้อความในตารางไม่ได้
- ภาพเป็น JPEG 90% ที่ ~185 dpi (รวม ~30 MB) — ลดคุณภาพได้ที่ `render_band()` ถ้าต้องการเบาลง
- ยังไม่มี offline/PWA และไม่มี dark-mode ตามระบบของตำรา (มีปุ่มสลับจำค่าใน localStorage)
## ดีไซน์
ฐานจาก `ui-ux-pro-max` → style "Swiss Modernism 2.0" + พาเลตต์ knowledge-blue
โทเคนจริงอยู่ใน `css/docs.css` หัวไฟล์ (`--brand #1e3a8a`, `--bg #f8fafc`, ฯลฯ)
ตัวอักษรเนื้อหา 17px/1.95 เพื่อความอ่านสบายของภาษาไทย · ทุกคู่สีหลักผ่าน WCAG AA
Binary file not shown.

After

Width:  |  Height:  |  Size: 221 KiB

+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><rect width="24" height="24" rx="6" fill="#1e3a8a"/><path d="M12 4.5c3 3.7 5.4 6.7 5.4 9.3a5.4 5.4 0 0 1-10.8 0c0-2.6 2.4-5.6 5.4-9.3Z" fill="none" stroke="#fff" stroke-width="1.6" stroke-linejoin="round"/></svg>

After

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 591 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 328 KiB

Loaded 100 of 454 files, more files were not shown because too many files have changed in this diff. Show more