當前位置: 首頁>>代碼示例>>Java>>正文


Java Tidy.setShowErrors方法代碼示例

本文整理匯總了Java中org.w3c.tidy.Tidy.setShowErrors方法的典型用法代碼示例。如果您正苦於以下問題:Java Tidy.setShowErrors方法的具體用法?Java Tidy.setShowErrors怎麽用?Java Tidy.setShowErrors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.w3c.tidy.Tidy的用法示例。


在下文中一共展示了Tidy.setShowErrors方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: tidy_init

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
public void tidy_init() {
	long bgn = System_.Ticks();
	wtr = new ByteArrayOutputStream();
	System.setProperty("line.separator", "\n");
	tidy = new Tidy(); // obtain a new Tidy instance
	tidy.setInputEncoding("utf-8");			// -utf8
	tidy.setOutputEncoding("utf-8");		// -utf8
	tidy.setDocType("\"\"");				// --doctype \"\"; set to empty else some wikis will show paragraph text with little vertical gap; PAGE:tr.b:
	tidy.setForceOutput(true);				// --force-output y 
	tidy.setQuiet(true);					// --quiet y
	tidy.setTidyMark(false);				// --tidy-mark n
	tidy.setWraplen(0);						// --wrap 0
	tidy.setIndentContent(true);			// --indent y; NOTE: true indents all content in edit box
	tidy.setQuoteNbsp(true);				// --quote-nbsp y
	tidy.setLiteralAttribs(true);			// --literal-attributes y
	tidy.setWrapAttVals(false);				// --wrap-attributes n
	tidy.setFixUri(false);					// --fix-url n
	tidy.setFixBackslash(false);			// --fix-backslash n
	tidy.setEncloseBlockText(true);			// --enclose-block-text y; NOTE: true creates extra <p>; very noticeable in sidebar
	tidy.setNumEntities(false);				// NOTE: true will convert all UTF-8 chars to &#val; which ruins readability
	tidy.setTrimEmptyElements(true);		// NOTE: tidy always trims (not even an option)
	tidy.setShowWarnings(false);			// NOTE: otherwise warnings printed to output window
	tidy.setShowErrors(0);					// NOTE: otherwise errors printed to output window; EX: Error: <time> is not recognized!
	app.Usr_dlg().Log_many("", "", "jtidy.init; elapsed=~{0}", System_.Ticks__elapsed_in_frac(bgn));
}
 
開發者ID:gnosygnu,項目名稱:xowa_android,代碼行數:26,代碼來源:Xoh_tidy_wkr_jtidy.java

示例2: getXHTML

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
public static String getXHTML(String html){
	
	Tidy tidy = new Tidy();

	tidy.setXHTML(true);
	tidy.setMakeClean(true);
	tidy.setShowWarnings(false);
	tidy.setShowErrors(0);
	tidy.setQuiet(true);
	tidy.setPrintBodyOnly(true);
	tidy.setOutputEncoding("ISO-8859-1");
	
	StringWriter stringWriter = new StringWriter();
	
	tidy.parse(new StringReader(html), stringWriter);
	
	return stringWriter.toString();
}
 
開發者ID:Sundsvallskommun,項目名稱:Open-ePlatform,代碼行數:19,代碼來源:JTidyUtils.java

示例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;
}
 
開發者ID:cursem,項目名稱:ScriptCompressor,代碼行數:36,代碼來源:HTMLParser.java

示例4: valueOf

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
public String valueOf(final String string) {
    if (StringUtils.isBlank(string)) {
        return removeBlankspaces ? null : string;
    }

    final Tidy tidy = new Tidy(); // obtain a new Tidy instance
    tidy.setXHTML(false); // set desired config options using tidy setters
    tidy.setQuiet(true);
    tidy.setShowErrors(0);
    tidy.setShowWarnings(false);
    tidy.setIndentContent(false);
    tidy.setXmlOut(true);

    final Document document = tidy.parseDOM(new StringReader(string), null);
    removeBadNodes(document);

    final NodeList bodies = document.getElementsByTagName("body");
    if (bodies.getLength() == 0) {
        // No body element? return null
        return null;
    } else {
        // Result will contain the xml header plus the body element itself. We need to body content only
        String result = XmlHelper.toString(bodies.item(0));
        result = result.substring(result.indexOf("<body>") + "<body>".length(), result.indexOf("</body>"));
        // Remove the nbsps
        if (removeBlankspaces) {
            int begin = 0;
            while (result.charAt(begin) == NBSP) {
                begin++;
                if (begin == result.length()) {
                    // All the string was NBSPs
                    return null;
                }
            }
            int end = result.length();
            while (result.charAt(end - 1) == NBSP) {
                end--;
            }
            return StringUtils.trimToNull(result.substring(begin, end));
        } else {
            return StringUtils.trimToNull(result);
        }
    }
}
 
開發者ID:mateli,項目名稱:OpenCyclos,代碼行數:45,代碼來源:HtmlConverter.java

示例5: 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;
	}
}
 
開發者ID:OpenBD,項目名稱:openbd-core,代碼行數:70,代碼來源:HtmlCleanUp.java


注:本文中的org.w3c.tidy.Tidy.setShowErrors方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。