本文整理匯總了Java中org.w3c.tidy.Tidy.setDropEmptyParas方法的典型用法代碼示例。如果您正苦於以下問題:Java Tidy.setDropEmptyParas方法的具體用法?Java Tidy.setDropEmptyParas怎麽用?Java Tidy.setDropEmptyParas使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.w3c.tidy.Tidy
的用法示例。
在下文中一共展示了Tidy.setDropEmptyParas方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: JTidyBookProcessor
import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
public JTidyBookProcessor()
{
tidy = new Tidy();
// tidy.setConfigurationFromFile(JTidyBookProcessor.class.getResource("/jtidy.properties").getFile());
tidy.setSpaces(2);
tidy.setIndentContent(true);
tidy.setSmartIndent(true);
tidy.setXHTML(true);
tidy.setQuoteMarks(false);
tidy.setQuoteAmpersand(true);
tidy.setDropEmptyParas(false);
tidy.setTidyMark(false);
tidy.setJoinClasses(true);
tidy.setJoinStyles(true);
tidy.setWraplen(0);
tidy.setDropProprietaryAttributes(true);
tidy.setEscapeCdata(true);
Properties props = new Properties();
props.put("new-blocklevel-tags", "svg image altGlyph altGlyphDef altGlyphItem animate animateColor animateMotion animateTransform circle clipPath color-profile cursor defs desc ellipse feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile feTurbulence filter font font-face font-face-format font-face-name font-face-src font-face-uri foreignObject g glyph glyphRef hkern image line linearGradient marker mask metadata missing-glyph mpath path pattern polygon polyline radialGradient rect script set stop style svg switch symbol text textPath title tref tspan use view vkern");
tidy.getConfiguration().addProps(props);
}
示例2: initializeTidyBuilder
import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
/**
* Initializes the tidy document builder.
*/
private void initializeTidyBuilder() {
tidyBuilder = new Tidy();
tidyBuilder.setInputEncoding("UTF-8");
tidyBuilder.setOutputEncoding("UTF-8");
tidyBuilder.setXmlOut(true);
tidyBuilder.setShowWarnings(false);
tidyBuilder.setQuiet(true);
tidyBuilder.setDropEmptyParas(false);
tidyBuilder.setTidyMark(false);
tidyBuilder.setFixComments(false);
tidyBuilder.setTrimEmptyElements(false);
tidyBuilder.setJoinStyles(false);
tidyBuilder.setXmlTags(true); // important, otherwise jtidy manipulates the markup
}
示例3: newTidy
import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
/**
* Configures a new JTidy instance.
*/
private static Tidy newTidy() {
Tidy tidy = new Tidy();
tidy.setMessageListener(new TidyMessageListener() {
@Override
public void messageReceived(TidyMessage msg) {
logger.warn(String.format("HTML warning at %s:%s: %s", msg.getLine(), msg.getColumn(), msg.getMessage()));
}
});
tidy.setDropEmptyParas(false);
tidy.setDropFontTags(false);
tidy.setDropProprietaryAttributes(false);
tidy.setTrimEmptyElements(false);
tidy.setXHTML(true);
tidy.setIndentAttributes(false);
tidy.setIndentCdata(false);
tidy.setIndentContent(false);
tidy.setQuiet(true);
tidy.setShowWarnings(!Options.isQuietEnabled());
tidy.setShowErrors(0);
tidy.setEncloseBlockText(false);
tidy.setEscapeCdata(false);
tidy.setDocType("omit");
tidy.setInputEncoding("UTF-8");
tidy.setRawOut(true);
tidy.setOutputEncoding("UTF-8");
tidy.setFixUri(false);
Properties prop = new Properties();
prop.put("new-blocklevel-tags", "canvas");
tidy.getConfiguration().addProps(prop);
return tidy;
}
示例4: execute
import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
public cfData execute(cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException {
try{
Tidy tidy = new Tidy();
final StringBuilder errors = new StringBuilder(32);
tidy.setMessageListener( new TidyMessageListener(){
public void messageReceived(TidyMessage mess) {
errors.append( "Line: " + mess.getLine() + "." + mess.getColumn() + "; " + mess.getMessage() + "\r\n" );
}
});
tidy.setSmartIndent( false );
tidy.setSpaces( 2 );
tidy.setTabsize( 2 );
tidy.setWraplen( 0 );
tidy.setLogicalEmphasis( true );
tidy.setMakeClean( true );
tidy.setQuiet( true );
tidy.setDropEmptyParas( true );
tidy.setXHTML( true );
tidy.setXmlSpace( true );
tidy.setTrimEmptyElements( true );
tidy.setBreakBeforeBR( false );
tidy.setUpperCaseTags( false );
tidy.setUpperCaseAttrs( false );
tidy.setWord2000( true );
tidy.setFixUri(false);
tidy.setFixBackslash( false );
tidy.setIndentAttributes( false );
tidy.setShowWarnings( false );
tidy.setShowErrors( 1 );
tidy.setOnlyErrors( false );
tidy.setPrintBodyOnly( false );
tidy.setJoinClasses( true );
tidy.setJoinStyles( true );
String inHtml = getNamedStringParam(argStruct,"string","");
StringReader reader = new StringReader( inHtml );
StringWriter writer = new StringWriter();
tidy.parse( reader, writer );
if ( errors.length() != 0 ){
throwException( _session, errors.toString() );
return null;
}else{
String outHtml = writer.toString();
int c1 = outHtml.indexOf("<body>");
if ( c1 >= 0 ){
outHtml = outHtml.substring( c1 + 6 );
c1 = outHtml.lastIndexOf("</body>");
if ( c1 >= 0 ){
outHtml = outHtml.substring( 0, c1 );
}
}
return new cfStringData( outHtml );
}
}catch( Exception e ){
throwException( _session, e.getMessage() );
return null;
}
}
示例5: tidyHTML
import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
private static String tidyHTML(String content)
throws IOException{
Tidy tidy = new Tidy();
// set configuration values
tidy.setDropEmptyParas(false); // drop empty P elements
tidy.setDocType("omit"); // omit the doctype
tidy.setEncloseBlockText(true); // wrap blocks of text in P elements
tidy.setEncloseText(true); // wrap text right under BODY element in P elements
tidy.setHideEndTags(false); // force optional end tags
tidy.setIndentContent(false); // indent content for easy reading
tidy.setLiteralAttribs(false); // no new lines in attributes
tidy.setLogicalEmphasis(false); // replace i and b by em and strong, respectively
tidy.setMakeClean(false); // strip presentational cruft
tidy.setNumEntities(true); // convert entities to their numeric form
tidy.setWord2000(true); // strip Word 2000 cruft
tidy.setXHTML(true); // output XHTML
tidy.setXmlPi(true); // add <?xml?> processing instruction
// parse
StringReader in = new StringReader(content);
StringWriter out = new StringWriter();
tidy.parse(in, out);
in.close();
out.close();
String results = out.toString();
// remove the XML namespace declaration,
// since it makes trouble for us in the XPath
// evaluator
// FIXME: this is ghetto and needs to be fixed
// with a namespace evaluator in the XPath section,
// but namespace evaluators are a pain in the butt
// to get working
// String.replace() does not work on 1.4 JVMs when compiled
// with 1.5 JVMs, even with target="1.4" (this is a known Java
// bug). Using workaround instead. -- Brad Neuberg
//results = results.replace("xmlns=\"http://www.w3.org/1999/xhtml\"", "");
StringBuffer buffer = new StringBuffer(results);
int startCut = buffer.indexOf("xmlns=\"http://www.w3.org/1999/xhtml\"");
if(startCut != -1){
buffer.replace(startCut,
startCut + "xmlns=\"http://www.w3.org/1999/xhtml\"".length(),
"");
results = buffer.toString();
}
//System.out.println("tidied results="+results);
return results;
}