Hướng dẫn dùng html tidy trong PHP

Tôi đã không tìm thấy khả năng "chỉ reindent - mà không có bất kỳ thay đổi nào". Tệp cấu hình tiếp theo sẽ "sửa chữa" ở mức thấp nhất có thể và [hầu hết] chỉ thụt lề lại html. Tidyvẫn đang sửa một số điều kiện sai, chẳng hạn như các thuộc tính trùng lặp [lặp lại].

#based on //tidy.sourceforge.net/docs/quickref.html #HTML, XHTML, XML Options Reference anchor-as-name: no #? doctype: omit drop-empty-paras: no fix-backslash: no fix-bad-comments: no fix-uri:no hide-endtags: yes #? #input-xml: yes #? join-styles: no literal-attributes: yes lower-literals: no merge-divs: no merge-spans: no output-html: yes preserve-entities: yes quote-ampersand: no quote-nbsp: no show-body-only: auto #Diagnostics Options Reference show-errors: 0 show-warnings: 0 #Pretty Print Options Reference break-before-br: yes indent: yes indent-attributes: no #default indent-spaces: 4 tab-size: 4 wrap: 132 wrap-asp: no wrap-jste: no wrap-php: no wrap-sections: no #Character Encoding Options Reference char-encoding: utf8 #Miscellaneous Options Reference force-output: yes quiet: yes tidy-mark: no

Ví dụ, đoạn html tiếp theo

not closed para

h2 head

  • not closed li
  • closed li
some text

sẽ thay đổi thành

not closed para

h2 head

  • not closed li
  • closed li
some text

Như bạn có thể nhận thấy, hide-endtags: yesdấu đóng từ dấu đầu dòng thứ hai trong đầu vào. Đặt hide-endtags: no- sẽ nhận được tiếp theo:

not closed para

h2 head

  • not closed li
  • closed li
some text

vì vậy, tidythêm đóng

và đóng vào dấu đầu dòng đầu tiên.

Tôi không tìm thấy khả năng bảo tồn mọi thứ trên đầu vào và chỉ nhập lại tệp.

24 hữu ích 3 bình luận chia sẻ

Chủ Đề