[Htmlparser-cvs] htmlparser/src/org/htmlparser/tags CompositeTag.java,1.81,1.82 ScriptTag.java,1.38,
Brought to you by:
derrickoswald
From: Derrick O. <der...@us...> - 2006-05-31 02:10:20
|
Update of //cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv27353/tags Modified Files: CompositeTag.java ScriptTag.java Log Message: implement task #93148 toHtml(boolean verbatim) To avoid printing generated end tags use toHtml(true). Index: ScriptTag.java =================================================================== RCS file: //cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/ScriptTag.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** ScriptTag.java 10 Apr 2005 23:20:45 -0000 1.38 --- ScriptTag.java 31 May 2006 02:10:15 -0000 1.39 *************** *** 142,148 **** /** * Places the script contents into the provided buffer. * @param sb The buffer to add the script to. */ ! protected void putChildrenInto (StringBuffer sb) { Node node; --- 142,150 ---- /** * Places the script contents into the provided buffer. + * @param verbatim If <code>true</code> return as close to the original + * page text as possible. * @param sb The buffer to add the script to. */ ! protected void putChildrenInto (StringBuffer sb, boolean verbatim) { Node node; *************** *** 155,160 **** node = e.nextNode (); // eliminate virtual tags ! // if (!(node.getStartPosition () == node.getEndPosition ())) ! sb.append (node.toHtml ()); } } --- 157,162 ---- node = e.nextNode (); // eliminate virtual tags ! if (!verbatim || !(node.getStartPosition () == node.getEndPosition ())) ! sb.append (node.toHtml (verbatim)); } } Index: CompositeTag.java =================================================================== RCS file: //cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/CompositeTag.java,v retrieving revision 1.81 retrieving revision 1.82 diff -C2 -d -r1.81 -r1.82 *** CompositeTag.java 20 Jun 2005 01:56:32 -0000 1.81 --- CompositeTag.java 31 May 2006 02:10:15 -0000 1.82 *************** *** 143,149 **** /** * Add the textual contents of the children of this node to the buffer. * @param sb The buffer to append to. */ ! protected void putChildrenInto(StringBuffer sb) { Node node; --- 143,151 ---- /** * Add the textual contents of the children of this node to the buffer. + * @param verbatim If <code>true</code> return as close to the original + * page text as possible. * @param sb The buffer to append to. */ ! protected void putChildrenInto (StringBuffer sb, boolean verbatim) { Node node; *************** *** 152,156 **** node = e.nextNode (); // eliminate virtual tags ! // if (!(node.getStartPosition () == node.getEndPosition ())) sb.append (node.toHtml ()); } --- 154,158 ---- node = e.nextNode (); // eliminate virtual tags ! if (!verbatim || !(node.getStartPosition () == node.getEndPosition ())) sb.append (node.toHtml ()); } *************** *** 159,186 **** /** * Add the textual contents of the end tag of this node to the buffer. * @param sb The buffer to append to. */ ! protected void putEndTagInto(StringBuffer sb) { // eliminate virtual tags ! // if (!(endTag.getStartPosition () == endTag.getEndPosition ())) ! sb.append(getEndTag ().toHtml()); } /** * Return this tag as HTML code. * @return This tag and it's contents (children) and the end tag * as HTML code. */ ! public String toHtml() { ! StringBuffer sb = new StringBuffer(); ! sb.append (super.toHtml ()); ! if (!isEmptyXmlTag()) { ! putChildrenInto(sb); if (null != getEndTag ()) ! putEndTagInto(sb); } ! return sb.toString(); } --- 161,195 ---- /** * Add the textual contents of the end tag of this node to the buffer. + * @param verbatim If <code>true</code> return as close to the original + * page text as possible. * @param sb The buffer to append to. */ ! protected void putEndTagInto (StringBuffer sb, boolean verbatim) { // eliminate virtual tags ! if (!verbatim || !(mEndTag.getStartPosition () == mEndTag.getEndPosition ())) ! sb.append (getEndTag ().toHtml()); } /** * Return this tag as HTML code. + * @param verbatim If <code>true</code> return as close to the original + * page text as possible. * @return This tag and it's contents (children) and the end tag * as HTML code. */ ! public String toHtml (boolean verbatim) ! { ! StringBuffer ret; ! ! ret = new StringBuffer (); ! ret.append (super.toHtml (verbatim)); ! if (!isEmptyXmlTag ()) { ! putChildrenInto (ret, verbatim); if (null != getEndTag ()) ! putEndTagInto (ret, verbatim); } ! return (ret.toString ()); } *************** *** 566,570 **** String ret; ! ret = super.toHtml (); ret = ret.substring (1, ret.length () - 1); --- 575,579 ---- String ret; ! ret = super.toHtml (true); // need TagNode.toHtml(boolean) ret = ret.substring (1, ret.length () - 1); |