tidy常用參數

來源:互聯網
上載者:User

JTidy提供了一個語法檢查器和標籤補償器,能夠對各種亂七八糟的html進行修複,使之符合xhtml標準。

其一些常用的參數設定:

setAltText(java.lang.String altText)
加上預設的alt屬性值
setBreakBeforeBR(boolean breakBeforeBR)
在換行
之前加一空行
setCharEncoding(int charencoding)
已廢棄
setConfigurationFromFile(java.lang.String filename)
從檔案中讀取配置資訊
setConfigurationFromProps(java.util.Properties props)
從properties中讀取配置資訊
setErrfile(java.lang.String errfile)
錯誤輸出檔案
setFixBackslash(boolean fixBackslash)
URL中用/取代/
setForceOutput(boolean forceOutput)
不管產生的xml是否有錯,強制輸出。
setHideComments(boolean hideComments)
結果中不產生注釋
setInputEncoding(java.lang.String encoding)
輸入編碼
setLogicalEmphasis(boolean logicalEmphasis)
用em替代i,strong替代b
setMessageListener(TidyMessageListener listener)
加入一個TidyMessageListener監聽器
setOnlyErrors(boolean onlyErrors)
只輸出錯誤檔案
setOutputEncoding(java.lang.String encoding)
輸出編碼
setPrintBodyOnly(boolean bodyOnly)
只輸出body中的部分
setRepeatedAttributes(int repeatedAttributes)
重複屬性的處理
setSpaces(int spaces)
每行前的空格數,就是縮排格式
setTidyMark(boolean tidyMark)
是否產生tidy標記
setTrimEmptyElements(boolean trimEmpty)
不輸出空元素
setUpperCaseAttrs(boolean upperCaseAttrs)
屬性變大寫
setUpperCaseTags(boolean upperCaseTags)
標記變大寫
setWraplen(int wraplen)
多長換行
setXHTML(boolean xhtml)
輸出xhtml
setXmlOut(boolean xmlOut)
輸出xml
setXmlPi(boolean xmlPi)
檔案頭輸出xml標記
setXmlSpace(boolean xmlSpace)
加入xml名字空間屬性

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.