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


Java Tidy.setSmartIndent方法代碼示例

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


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

示例1: cleanNfo

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
/**
 * Try to clean the NFO(XML) content with JTidy.
 * 
 * @param sourceNfoContent
 *          the XML content to be cleaned
 * @return the cleaned XML content (or the source, if any Exceptions occur)
 */
public static String cleanNfo(String sourceNfoContent) {
  try {
    Tidy tidy = new Tidy();
    tidy.setInputEncoding("UTF-8");
    tidy.setOutputEncoding("UTF-8");
    tidy.setWraplen(Integer.MAX_VALUE);
    tidy.setXmlOut(true);
    tidy.setSmartIndent(true);
    tidy.setXmlTags(true);
    tidy.setMakeClean(true);
    tidy.setForceOutput(true);
    tidy.setQuiet(true);
    tidy.setShowWarnings(false);
    StringReader in = new StringReader(sourceNfoContent);
    StringWriter out = new StringWriter();
    tidy.parse(in, out);

    return out.toString();
  }
  catch (Exception e) {
  }
  return sourceNfoContent;
}
 
開發者ID:tinyMediaManager,項目名稱:tinyMediaManager,代碼行數:31,代碼來源:ParserUtils.java

示例2: 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);
    }
 
開發者ID:finanzer,項目名稱:epubfx,代碼行數:22,代碼來源:JTidyBookProcessor.java

示例3: cleanupHtml

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
private String cleanupHtml(String story) {
    Tidy tidy = new Tidy();
    tidy.setInputEncoding(ENCODING);
    tidy.setOutputEncoding(ENCODING);
    tidy.setPrintBodyOnly(true);
    tidy.setXmlOut(true);
    tidy.setSmartIndent(false);
    tidy.setBreakBeforeBR(false);
    tidy.setMakeBare(true);
    tidy.setMakeClean(true);
    tidy.setNumEntities(true);
    tidy.setWraplen(0);

    StringWriter writer = new StringWriter();
    StringReader reader = new StringReader(story);
    tidy.parse(reader, writer);
    return writer.toString();
}
 
開發者ID:getconverge,項目名稱:converge-1.x,代碼行數:19,代碼來源:NewsItemPlacementToAtomConverter.java

示例4: cleanXMLData

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
public static String cleanXMLData(String data) throws UnsupportedEncodingException {
   // data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+data;

	Tidy tidy = new Tidy();
    tidy.setInputEncoding("UTF-8");
    tidy.setOutputEncoding("UTF-8");
    tidy.setWraplen(Integer.MAX_VALUE);
  //  tidy.setPrintBodyOnly(true);
    tidy.setXmlOut(true);
    tidy.setXmlTags(true);
    tidy.setSmartIndent(true);
    tidy.setMakeClean(true);
    tidy.setForceOutput(true);
    ByteArrayInputStream inputStream = new ByteArrayInputStream(data.getBytes("UTF-8"));
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    tidy.parseDOM(inputStream, outputStream);
    return outputStream.toString("UTF-8");
}
 
開發者ID:karutaproject,項目名稱:karuta-backend,代碼行數:19,代碼來源:DomUtils.java

示例5: formatXml

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
public static String formatXml(@NotNull String xml) throws TransformerException {
    StringReader stringReader = new StringReader(xml);
    Tidy tidy = new Tidy();
    tidy.setXmlOut(true);
    tidy.setInputEncoding("UTF-8");
    tidy.setOutputEncoding("UTF-8");
    tidy.setTidyMark(false);
    tidy.setForceOutput(true);
    tidy.setSmartIndent(true);
    tidy.setShowWarnings(false);
    tidy.setQuiet(true);
    StringWriter stringWriter = new StringWriter();
    tidy.parse(stringReader, stringWriter);
    return stringWriter.toString();
}
 
開發者ID:FingerArt,項目名稱:ApiDebugger,代碼行數:16,代碼來源:StringUtils.java

示例6: formatHtml

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
public static String formatHtml(String html) {
    StringReader stringReader = new StringReader(html);
    Tidy tidy = new Tidy();
    tidy.setXHTML(true);
    tidy.setInputEncoding("UTF-8");
    tidy.setOutputEncoding("UTF-8");
    tidy.setTidyMark(false);
    tidy.setSmartIndent(true);
    tidy.setForceOutput(true);
    tidy.setShowWarnings(false);
    tidy.setQuiet(true);
    StringWriter stringWriter = new StringWriter();
    tidy.parse(stringReader, stringWriter);
    return stringWriter.toString();
}
 
開發者ID:FingerArt,項目名稱:ApiDebugger,代碼行數:16,代碼來源:StringUtils.java

示例7: beautyHTML

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
private String beautyHTML(String html) throws UnsupportedEncodingException {
	Tidy tidy = new Tidy();
	tidy.setInputEncoding("UTF-8");
    tidy.setOutputEncoding("UTF-8");
    tidy.setWraplen(Integer.MAX_VALUE);
    tidy.setXmlOut(true);
    tidy.setXmlTags(true);
    tidy.setSmartIndent(true);
    ByteArrayInputStream inputStream = new ByteArrayInputStream(html.getBytes("UTF-8"));
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    Document doc = tidy.parseDOM(inputStream, null);
    tidy.pprint(doc, outputStream);
    return outputStream.toString("UTF-8");
}
 
開發者ID:sinnlabs,項目名稱:dbvim,代碼行數:15,代碼來源:ModelTree.java

示例8: handleResponse

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
protected void handleResponse(String responseText) throws Exception {
    if (responseText == null) {
        setResponseHtml(null);
    } else {
        try {
            //apparently JTidy isn't escaping content within <script> blocks.
            //time to get a little dirty
            StringBuffer buffer = new StringBuffer(responseText);
            int startIndex = 0;
            while ((startIndex = buffer.indexOf("<script", startIndex)) != -1) {
                startIndex = buffer.indexOf(">", startIndex) + 1;
                int endIndex = buffer.indexOf("</script>", startIndex);
                String temp = buffer.substring(startIndex, endIndex);
                if (temp.contains("&") && !temp.startsWith("<![CDATA[")) {
                    temp = "<![CDATA[" + temp + "]]>";
                    buffer.replace(startIndex, endIndex, temp);
                }
            }
            responseText = buffer.toString();
            
            Tidy tidy = new Tidy();
            tidy.setXHTML(true);
            tidy.setSmartIndent(true);
            tidy.setQuoteAmpersand(true);
            ByteArrayInputStream in = new ByteArrayInputStream(responseText.getBytes());
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            tidy.parse(in, out);
            DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
            SimpleDocumentBuilder builder = new SimpleDocumentBuilder(f);
            SimpleDocument dom = builder.parseString(out.toString());
            setResponseHtml(dom);
        }  catch (Exception e) {
            setResponseHtml(null);
            throw e;
        }
    }
}
 
開發者ID:3dcitydb,項目名稱:swingx-ws,代碼行數:38,代碼來源:HtmlHttpRequest.java

示例9: createTidy

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
public static Tidy createTidy() {
    Tidy tidy = new Tidy();
    tidy.setQuiet(true);
    // tidy.setMakeClean(true);
    // tidy.setIndentContent(true);
    tidy.setSmartIndent(true);
    // tidy.setXmlOut(true);
    tidy.setXHTML(true);
    tidy.setWraplen(Integer.MAX_VALUE);

    // tidy.setDocType("omit");
    // tidy.setNumEntities(true);
    return tidy;
}
 
開發者ID:cobbzilla,項目名稱:cobbzilla-utils,代碼行數:15,代碼來源:TidyUtil.java

示例10: 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

示例11: convertToXMLOLD

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
public static String convertToXMLOLD(String xml){
	//======================================
//	String newXML = xml;
//	String xml1 = "";
//	String xml2 = "";
//	String html = "";
//	if (xml.indexOf("<text>")>-1) {
//	xml1 = xml.substring(0,xml.indexOf("<text>")+6);
//	xml2 = xml.substring(xml.indexOf("</text>"));
//	html = xml.substring(xml.indexOf("<text>")+6,xml.indexOf("</text>"));
//	}
//	if (xml.indexOf("<comment>")>-1) {
//	xml1 = xml.substring(0,xml.indexOf("<comment>")+9);
//	xml2 = xml.substring(xml.indexOf("</comment>"));
//	html = xml.substring(xml.indexOf("<comment>")+9,xml.indexOf("</comment>"));
//	}
//	if (xml.indexOf("<description>")>-1) {
//	xml1 = xml.substring(0,xml.indexOf("<description>")+13);
//	xml2 = xml.substring(xml.indexOf("</description>"));
//	html = xml.substring(xml.indexOf("<description>")+13,xml.indexOf("</description>"));
//	}
//	if (html.length()>0) {  // xml is html
//	html = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'><head><title></title></head><body>" +html+"</body>";
	StringReader in = new StringReader(xml);
	StringWriter out = new StringWriter();
	Tidy tidy = new Tidy();
	tidy.setInputEncoding("UTF-8");
    tidy.setOutputEncoding("UTF-8");
    tidy.setWraplen(Integer.MAX_VALUE);
    tidy.setPrintBodyOnly(true);
	tidy.setMakeClean(true);
//	tidy.setForceOutput(true);
    tidy.setSmartIndent(true);
    tidy.setXmlTags(true);
	tidy.setXmlOut(true);

//	tidy.setWraplen(0);
	tidy.parseDOM(in, out);
	String newXML = out.toString();
//	newXML = xml1+newHTML.substring(newHTML.indexOf("<body>")+6,newHTML.indexOf("</body>"))+xml2;
//	} else {
//	newXML =xml;
//	}
//	return newXML;
	return newXML;
	}
 
開發者ID:karutaproject,項目名稱:karuta-backend,代碼行數:47,代碼來源:DomUtils.java

示例12: main

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException, ParserConfigurationException, DocumentException
   {
       if (args.length != 2)
       {
           System.out.println("Error: You should type as: convertToPDF htmlFile pdfOut");
           System.exit(1);
       }

       String htmlFile = args[0];
       String pdfOutFile = args[1];//"/home/sardor/Downloads/CV_B/test.pdf";

       FileInputStream input = reOpenStream(htmlFile);


       //Append required HTML elements via JSoup
       HtmlValidator validator = new HtmlValidator(input, htmlFile);
       if(validator.hasError()==1)
       {
           System.out.println("Error: Something wrong with HTML file");
           System.exit(1);
       }

       //Redefine file stream
       input = reOpenStream(htmlFile);

       //Validate out html document
       Tidy tidy=new Tidy();
       tidy.setInputEncoding("UTF-8");
       tidy.setOutputEncoding("UTF-8");
       tidy.setIndentCdata(true);
       tidy.setQuiet(true);
       tidy.setForceOutput(true);
       tidy.setTidyMark(false);
       tidy.setXHTML(true);
       tidy.setJoinClasses(true);
       tidy.setSmartIndent(true);

       //Convert to XML view
       Document xhtmlDoc = tidy.parseDOM(input, null);

       //Create PDF file
       OutputStream os = new FileOutputStream(pdfOutFile);

       //Render pdf doc
       ITextRenderer renderer = new ITextRenderer();
       renderer.setDocument(xhtmlDoc,null);
       renderer.layout();
       renderer.createPDF(os);

       os.close();
}
 
開發者ID:snavruzov,項目名稱:HTML2PDF,代碼行數:52,代碼來源:Html2PDF.java

示例13: main

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException, FileNotFoundException, DocumentException, ParserConfigurationException, com.itextpdf.text.DocumentException
{
    int width = PAGE_WIDTH;
    if (args.length != 2)
    {
        System.out.println("Error: You should type as: convertToPDF htmlFile pdfOut");
        System.exit(1);
    }

    String htmlFile = args[0];
    String pdfOutFile = args[1];

    FileInputStream input = null;
    try
    {
        input = new FileInputStream(htmlFile);
    } catch (java.io.FileNotFoundException e)
    {
        System.out.println("File not found: " + htmlFile);
    }

    Tidy tidy=new Tidy();
    tidy.setInputEncoding("UTF-8");
    tidy.setOutputEncoding("UTF-8");
    tidy.setQuiet(true);
    tidy.setXHTML(true);

    tidy.setJoinClasses(true);
    tidy.setSmartIndent(true);

    Document xhtmlDoc = tidy.parseDOM(input, null);
    xhtmlDoc.normalizeDocument();
    OutputStream os = new FileOutputStream(pdfOutFile);

    Java2DRenderer renderer = new Java2DRenderer(xhtmlDoc, width, -1);
    BufferedImage img = renderer.getImage();
    int height = img.getHeight();
    width = (int) Math.round(height * PAGE_WIDTH / PAGE_LENGTH);

    renderer = new Java2DRenderer(xhtmlDoc, width, height);
    img = renderer.getImage();

    com.itextpdf.text.Document pdf = new com.itextpdf.text.Document(com.itextpdf.text.PageSize.A4);
    pdf.setMargins(MARGIN, MARGIN, MARGIN, MARGIN);
    PdfWriter.getInstance(pdf, os);
    pdf.open();
    com.itextpdf.text.Image pdfImage = com.itextpdf.text.Image.getInstance(img, Color.WHITE);
    com.itextpdf.text.Rectangle ps = pdf.getPageSize();
    pdfImage.scaleAbsolute(ps.getWidth() - pdf.leftMargin() - pdf.rightMargin(), ps.getHeight() - pdf.topMargin() - pdf.bottomMargin());
    pdf.add(pdfImage);
    pdf.close();
    os.close();


}
 
開發者ID:snavruzov,項目名稱:HTML2PDF,代碼行數:56,代碼來源:HtmlToImgPDF.java


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