drupal6: ปรับปรุงการใช้งานมอดูล geshifilter
โพสต์นี้ อย่าเชื่อมาก เป็นแค่การทดลองเท่านั้น
พบว่ามอดูล geshifilter เขาแปลงรหัส entity ให้โดยอัตโนมัติ
ทำให้การโพสต์เนื้อความ ไม่ยืดหยุ่นเท่าที่ควร
เที่ยวนี้เราจะตั้งค่าใหม่ ให้การใช้งานมีความยืดหยุ่นสูงสุด
- ตั้งค่าการใช้งาน geshifilter ผ่าน URL:
admin/settings/geshifilter- Generic syntax highlighting tags: เพิ่มแท็ก
pre - Code container: เลือก
Use <div> container
- Generic syntax highlighting tags: เพิ่มแท็ก
- แก้มอดูลเล็กน้อย เพื่อยกเลิกการแปลง entities อัตโนมัติ
$ vi sites/all/modules/geshifilter/geshifilter.pages.incเพิ่มการ decode สองครั้ง (โดยเพิ่มบรรทัดที่เป็นตัวหนา)
:129... $source_code = decode_entities($source_code); $source_code = decode_entities($source_code); ...
เสร็จแล้ว
เสร็จแล้ว แต่ยังงง ๆ กับผลลัพธ์อยู่ รอดูอีกสักพัก
เริ่มเข้าใจแล้ว
แท็กที่เราจะทำพิเศษเพิ่มในบล๊อกของโค๊ด ไม่สามารถทำได้ เพราะ GeSHi จะแปลงเป็น entities ทั้งหมด
ต้องหาทางอื่นในการเน้นประโยคแทน เช่นทำบรรทัดคอมเมนต์เป็นต้น
เช่น
... $source_code = decode_entities($source_code); $source_code = decode_entities($source_code); //ADD THIS LINE ...
ตัวอย่างข้างต้น ต้องกรอกในฟอร์มว่า
<div class="geshifilter"> <pre language="drupal6"> ... $source_code = decode_entities($source_code); $source_code = decode_entities($source_code); //ADD THIS LINE ... </pre> </div>
มอดูลนี้ใหญ่และซับซ้อนมาก แฮ็กไม่ไหว เอาเท่าที่ได้แล้วกันครับ
update
ลองใช้งาน geshifilter แล้วมันทำให้โค๊ดในงานเก่าดูเพี้ยนไปหมด
ทางแก้คือสร้าง Input format ใหม่ ผ่าน admin/settings/filters
ตั้งให้สามารถใช้งาน GeSHi ได้ (โดยยกเลิกการใช้งาน GeSHi กับ Input Format อันเก่า เพื่อให้ไม่ต้องตามไปแก้งานเก่า)
ตั้งชื่อว่า GeSHi Filtered HTML
สำหรับงานใหม่ที่จะต้องการใช้ Syntax Highlight ก็ค่อยมาเลือกใช้ Input format แบบนี้
- Printer-friendly version
- Login or register to post comments







Recent comments
9 weeks 5 days ago
9 weeks 6 days ago
9 weeks 6 days ago
11 weeks 20 hours ago
11 weeks 1 day ago
11 weeks 1 day ago
14 weeks 12 hours ago
14 weeks 4 days ago
14 weeks 4 days ago
14 weeks 4 days ago