📄 configuration.java
字号:
/*
* @(#)Configuration.java 1.11 2000/08/16
*
*/
package org.w3c.tidy;
/**
*
* Read configuration file and manage configuration properties.
*
* (c) 1998-2000 (W3C) MIT, INRIA, Keio University
* See Tidy.java for the copyright notice.
* Derived from <a href="http://www.w3.org/People/Raggett/tidy">
* HTML Tidy Release 4 Aug 2000</a>
*
* @author Dave Raggett <dsr@w3.org>
* @author Andy Quick <ac.quick@sympatico.ca> (translation to Java)
* @version 1.0, 1999/05/22
* @version 1.0.1, 1999/05/29
* @version 1.1, 1999/06/18 Java Bean
* @version 1.2, 1999/07/10 Tidy Release 7 Jul 1999
* @version 1.3, 1999/07/30 Tidy Release 26 Jul 1999
* @version 1.4, 1999/09/04 DOM support
* @version 1.5, 1999/10/23 Tidy Release 27 Sep 1999
* @version 1.6, 1999/11/01 Tidy Release 22 Oct 1999
* @version 1.7, 1999/12/06 Tidy Release 30 Nov 1999
* @version 1.8, 2000/01/22 Tidy Release 13 Jan 2000
* @version 1.9, 2000/06/03 Tidy Release 30 Apr 2000
* @version 1.10, 2000/07/22 Tidy Release 8 Jul 2000
* @version 1.11, 2000/08/16 Tidy Release 4 Aug 2000
*/
/*
Configuration files associate a property name with a value.
The format is that of a Java .properties file.
*/
import java.util.Enumeration;
import java.util.Properties;
import java.util.StringTokenizer;
import java.io.FileInputStream;
import java.io.IOException;
public class Configuration implements java.io.Serializable {
/* character encodings */
public static final int RAW = 0;
public static final int ASCII = 1;
public static final int LATIN1 = 2;
public static final int UTF8 = 3;
public static final int ISO2022 = 4;
public static final int MACROMAN = 5;
/* mode controlling treatment of doctype */
public static final int DOCTYPE_OMIT = 0;
public static final int DOCTYPE_AUTO = 1;
public static final int DOCTYPE_STRICT= 2;
public static final int DOCTYPE_LOOSE = 3;
public static final int DOCTYPE_USER = 4;
protected int spaces = 2; /* default indentation */
protected int wraplen = 68; /* default wrap margin */
protected int CharEncoding = ASCII;
protected int tabsize = 4;
protected int docTypeMode = DOCTYPE_AUTO; /* see doctype property */
protected String altText = null; /* default text for alt attribute */
protected String slidestyle = null; /* style sheet for slides */
protected String docTypeStr = null; /* user specified doctype */
protected String errfile = null; /* file name to write errors to */
protected boolean writeback = false; /* if true then output tidied markup */
protected boolean OnlyErrors = false; /* if true normal output is suppressed */
protected boolean ShowWarnings = true; /* however errors are always shown */
protected boolean Quiet = false; /* no 'Parsing X', guessed DTD or summary */
protected boolean IndentContent = false; /* indent content of appropriate tags */
protected boolean SmartIndent = false; /* does text/block level content effect indentation */
protected boolean HideEndTags = false; /* suppress optional end tags */
protected boolean XmlTags = false; /* treat input as XML */
protected boolean XmlOut = false; /* create output as XML */
protected boolean xHTML = false; /* output extensible HTML */
protected boolean XmlPi = false; /* add <?xml?> for XML docs */
protected boolean RawOut = false; /* avoid mapping values > 127 to entities */
protected boolean UpperCaseTags = false; /* output tags in upper not lower case */
protected boolean UpperCaseAttrs = false; /* output attributes in upper not lower case */
protected boolean MakeClean = false; /* remove presentational clutter */
protected boolean LogicalEmphasis = false; /* replace i by em and b by strong */
protected boolean DropFontTags = false; /* discard presentation tags */
protected boolean DropEmptyParas = true; /* discard empty p elements */
protected boolean FixComments = true; /* fix comments with adjacent hyphens */
protected boolean BreakBeforeBR = false; /* o/p newline before <br> or not? */
protected boolean BurstSlides = false; /* create slides on each h2 element */
protected boolean NumEntities = false; /* use numeric entities */
protected boolean QuoteMarks = false; /* output " marks as " */
protected boolean QuoteNbsp = true; /* output non-breaking space as entity */
protected boolean QuoteAmpersand = true; /* output naked ampersand as & */
protected boolean WrapAttVals = false; /* wrap within attribute values */
protected boolean WrapScriptlets = false; /* wrap within JavaScript string literals */
protected boolean WrapSection = true; /* wrap within <![ ... ]> section tags */
protected boolean WrapAsp = true; /* wrap within ASP pseudo elements */
protected boolean WrapJste = true; /* wrap within JSTE pseudo elements */
protected boolean WrapPhp = true; /* wrap within PHP pseudo elements */
protected boolean FixBackslash = true; /* fix URLs by replacing \ with / */
protected boolean IndentAttributes = false; /* newline+indent before each attribute */
protected boolean XmlPIs = false; /* if set to yes PIs must end with ?> */
protected boolean XmlSpace = false; /* if set to yes adds xml:space attr as needed */
protected boolean EncloseBodyText = false; /* if yes text at body is wrapped in <p>'s */
protected boolean EncloseBlockText = false; /* if yes text in blocks is wrapped in <p>'s */
protected boolean KeepFileTimes = true; /* if yes last modied time is preserved */
protected boolean Word2000 = false; /* draconian cleaning for Word2000 */
protected boolean TidyMark = true; /* add meta element indicating tidied doc */
protected boolean Emacs = false; /* if true format error output for GNU Emacs */
protected boolean LiteralAttribs = false; /* if true attributes may use newlines */
private transient Properties _properties = new Properties();
public Configuration()
{
}
public void addProps( Properties p )
{
Enumeration enum = p.propertyNames();
while (enum.hasMoreElements())
{
String key = (String) enum.nextElement();
String value = p.getProperty(key);
_properties.put(key, value);
}
parseProps();
}
public void parseFile( String filename )
{
try
{
_properties.load( new FileInputStream( filename ) );
}
catch (IOException e)
{
System.err.println(filename + e.toString());
return;
}
parseProps();
}
private void parseProps()
{
String value;
value = _properties.getProperty("indent-spaces");
if (value != null)
spaces = parseInt(value);
value = _properties.getProperty("wrap");
if (value != null)
wraplen = parseInt(value);
value = _properties.getProperty("wrap-attributes");
if (value != null)
WrapAttVals = parseBool(value);
value = _properties.getProperty("wrap-script-literals");
if (value != null)
WrapScriptlets = parseBool(value);
value = _properties.getProperty("wrap-sections");
if (value != null)
WrapSection = parseBool(value);
value = _properties.getProperty("wrap-asp");
if (value != null)
WrapAsp = parseBool(value);
value = _properties.getProperty("wrap-jste");
if (value != null)
WrapJste = parseBool(value);
value = _properties.getProperty("wrap-php");
if (value != null)
WrapPhp = parseBool(value);
value = _properties.getProperty("literal-attributes");
if (value != null)
LiteralAttribs = parseBool(value);
value = _properties.getProperty("tab-size");
if (value != null)
tabsize = parseInt(value);
value = _properties.getProperty("markup");
if (value != null)
OnlyErrors = parseInvBool(value);
value = _properties.getProperty("quiet");
if (value != null)
Quiet = parseBool(value);
value = _properties.getProperty("tidy-mark");
if (value != null)
TidyMark = parseBool(value);
value = _properties.getProperty("indent");
if (value != null)
IndentContent = parseIndent(value);
value = _properties.getProperty("indent-attributes");
if (value != null)
IndentAttributes = parseBool(value);
value = _properties.getProperty("hide-endtags");
if (value != null)
HideEndTags = parseBool(value);
value = _properties.getProperty("input-xml");
if (value != null)
XmlTags = parseBool(value);
value = _properties.getProperty("output-xml");
if (value != null)
XmlOut = parseBool(value);
value = _properties.getProperty("output-xhtml");
if (value != null)
xHTML = parseBool(value);
value = _properties.getProperty("add-xml-pi");
if (value != null)
XmlPi = parseBool(value);
value = _properties.getProperty("add-xml-decl");
if (value != null)
XmlPi = parseBool(value);
value = _properties.getProperty("assume-xml-procins");
if (value != null)
XmlPIs = parseBool(value);
value = _properties.getProperty("raw");
if (value != null)
RawOut = parseBool(value);
value = _properties.getProperty("uppercase-tags");
if (value != null)
UpperCaseTags = parseBool(value);
value = _properties.getProperty("uppercase-attributes");
if (value != null)
UpperCaseAttrs = parseBool(value);
value = _properties.getProperty("clean");
if (value != null)
MakeClean = parseBool(value);
value = _properties.getProperty("logical-emphasis");
if (value != null)
LogicalEmphasis = parseBool(value);
value = _properties.getProperty("word-2000");
if (value != null)
Word2000 = parseBool(value);
value = _properties.getProperty("drop-empty-paras");
if (value != null)
DropEmptyParas = parseBool(value);
value = _properties.getProperty("drop-font-tags");
if (value != null)
DropFontTags = parseBool(value);
value = _properties.getProperty("enclose-text");
if (value != null)
EncloseBodyText = parseBool(value);
value = _properties.getProperty("enclose-block-text");
if (value != null)
EncloseBlockText = parseBool(value);
value = _properties.getProperty("alt-text");
if (value != null)
altText = new String(value);
value = _properties.getProperty("add-xml-space");
if (value != null)
XmlSpace = parseBool(value);
value = _properties.getProperty("fix-bad-comments");
if (value != null)
FixComments = parseBool(value);
value = _properties.getProperty("split");
if (value != null)
BurstSlides = parseBool(value);
value = _properties.getProperty("break-before-br");
if (value != null)
BreakBeforeBR = parseBool(value);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -