本文整理匯總了Java中org.w3c.tidy.Tidy.setTidyMark方法的典型用法代碼示例。如果您正苦於以下問題:Java Tidy.setTidyMark方法的具體用法?Java Tidy.setTidyMark怎麽用?Java Tidy.setTidyMark使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.w3c.tidy.Tidy
的用法示例。
在下文中一共展示了Tidy.setTidyMark方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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));
}
示例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);
}
示例3: 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();
}
示例4: 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();
}
示例5: ConverterXhtml
import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
public void ConverterXhtml(String fileHtml, String fileXhtmlAux) throws Exception {
Tidy tidy = new Tidy();
FileInputStream in = new FileInputStream(fileHtml);
FileOutputStream out = new FileOutputStream(fileXhtmlAux);
tidy.setTidyMark(false);
tidy.setDocType("omit");
tidy.setAltText("");
tidy.setFixBackslash(true);
tidy.setFixComments(true);
tidy.setXmlPi(true);
tidy.setQuoteAmpersand(true);
tidy.setQuoteNbsp(true);
tidy.setNumEntities(true);
tidy.setXmlOut(true);
tidy.setWraplen(999);
tidy.setWriteback(true);
tidy.setQuoteMarks(true);
tidy.setLogicalEmphasis(true);
tidy.setEncloseText(true);
tidy.setHideEndTags(true);
tidy.setShowWarnings(false);
tidy.setQuiet(true);
tidy.setXHTML(true);
tidy.parse(in, out);
in.close();
out.close();
}
示例6: ConverterXhtml
import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
/**
* Method used to transform the data from the html file given as parameter to
* xhtml format file which will be stored in the second file given.
* @param fileHtml input html file path.
* @param fileXhtmlAux output xhtml file path.
* @throws Exception if the files can not be read or written.
*/
public void ConverterXhtml(String fileHtml, String fileXhtmlAux) throws Exception {
Tidy tidy = new Tidy();
FileInputStream in = new FileInputStream(fileHtml);
FileOutputStream out = new FileOutputStream(fileXhtmlAux);
tidy.setTidyMark(false);
tidy.setDocType("omit");
tidy.setAltText("");
tidy.setFixBackslash(true);
tidy.setFixComments(true);
tidy.setXmlPi(true);
tidy.setQuoteAmpersand(true);
tidy.setQuoteNbsp(true);
tidy.setNumEntities(true);
tidy.setXmlOut(true);
tidy.setWraplen(999);
tidy.setWriteback(true);
tidy.setQuoteMarks(true);
tidy.setLogicalEmphasis(true);
tidy.setEncloseText(true);
tidy.setHideEndTags(true);
tidy.setShowWarnings(false);
tidy.setQuiet(true);
tidy.setXHTML(true);
tidy.parse(in, out);
in.close();
out.close();
}
示例7: 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
}
示例8: HtmlToXml_Tidy
import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
public
HtmlToXml_Tidy()
{
tidy_ = new Tidy();
tidy_.setTidyMark(false);
configuration_ = tidy_.getConfiguration();
Properties properties = new Properties();
// SAX parser requires XML
properties.put("output-xml", "true");
// No need to add document generator to output
properties.put("tidy-mark", "false");
// Request that entities be output in their numeric form
// rather than the character mnemonics: some browsers don't
// understand all the mnemonics. Unfortunately this forces
// all entities except for , <, >, and &
// to be output as numerics, even if they were input as
// characters.
properties.put("numeric-entities", "true");
// Tell Tidy not to perform any line wrapping.
// Otherwise the browser whitespace bug may reappear
// if the line gets too long.
properties.put("wrap", "0");
// Tell Tidy not to output messages that aren't errors.
// This makes builds look cleaner.
properties.put("quiet", "true");
configuration_.addProps(properties);
}
示例9: parseFileToDocument
import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
/**
* Return a document based on file,
* Document tpe
*
* @param file
* @return
*/
public Document parseFileToDocument(File file, Boolean setXML, Boolean setXHTML, Boolean setParseMark, String docType){
tidy = new Tidy();
//default format is XML
tidy.setXmlOut(setXML);
//set if extensible html
tidy.setXHTML(setXHTML);
//this removes the tidy meta tag in the header
tidy.setTidyMark(setParseMark);
tidy.setDocType(docType);
FileInputStream fis;
Document document = null;
try {
fis = new FileInputStream(file);
//parse input stream and return a DOM Document
document = tidy.parseDOM(fis, null);
fis.close();
} catch (Exception e) {
throw new RuntimeException("Unable to parse the file :" + file.getAbsolutePath() + " throws", e);
}
return document;
}
示例10: 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();
}
示例11: parseInputStreamToDocument
import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
/**
* Return a document from the input stream
*
* @param is
* @return
*/
public Document parseInputStreamToDocument(InputStream is, Boolean setXML, Boolean setXHTML, Boolean setParseMark, String docType){
tidy = new Tidy();
//default format is XML
tidy.setXmlOut(setXML);
//set if extensible html
tidy.setXHTML(setXHTML);
//this removes the tidy meta tag in the header
tidy.setTidyMark(setParseMark);
tidy.setDocType(docType);
Document document = null;
try {
//parse input stream and return a DOM Document
document = tidy.parseDOM(is, null);
} catch (Exception e) {
throw new RuntimeException("Unable to parse the given input stream ");
}
return document;
}