You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by go...@apache.org on 2004/04/20 18:27:24 UTC
cvs commit: jakarta-lucene/src/demo/org/apache/lucene/demo/html HTMLParser.java HTMLParser.jj
goller 2004/04/20 09:27:24
Modified: src/demo/org/apache/lucene/demo/html HTMLParser.java
HTMLParser.jj
Log:
fix for bug 27423
slightly modified version of Daniel?s patch
Revision Changes Path
1.5 +22 -13 jakarta-lucene/src/demo/org/apache/lucene/demo/html/HTMLParser.java
Index: HTMLParser.java
===================================================================
RCS file: /home/cvs/jakarta-lucene/src/demo/org/apache/lucene/demo/html/HTMLParser.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- HTMLParser.java 23 Nov 2003 18:37:32 -0000 1.4
+++ HTMLParser.java 20 Apr 2004 16:27:24 -0000 1.5
@@ -10,7 +10,8 @@
StringBuffer title = new StringBuffer(SUMMARY_LENGTH);
StringBuffer summary = new StringBuffer(SUMMARY_LENGTH * 2);
Properties metaTags=new Properties();
- String currentMetaTag="";
+ String currentMetaTag=null;
+ String currentMetaContent=null;
int length = 0;
boolean titleComplete = false;
boolean inTitle = false;
@@ -120,11 +121,6 @@
void addText(String text) throws IOException {
if (inStyle)
return;
- if (inMetaTag)
- {
- metaTags.setProperty(currentMetaTag, text);
- return;
- }
if (inTitle)
title.append(text);
else {
@@ -143,6 +139,13 @@
afterSpace = false;
}
+ void addMetaTag() throws IOException {
+ metaTags.setProperty(currentMetaTag, currentMetaContent);
+ currentMetaTag = null;
+ currentMetaContent = null;
+ return;
+ }
+
void addSpace() throws IOException {
if (!afterSpace) {
if (inTitle)
@@ -262,11 +265,17 @@
&& t2 != null)
{
currentMetaTag=t2.image.toLowerCase();
+ if(currentMetaTag != null && currentMetaContent != null) {
+ addMetaTag();
+ }
}
if(inMetaTag && t1.image.equalsIgnoreCase("content") && t2 !=
null)
{
- addText(t2.image);
+ currentMetaContent=t2.image.toLowerCase();
+ if(currentMetaTag != null && currentMetaContent != null) {
+ addMetaTag();
+ }
}
break;
default:
@@ -441,15 +450,15 @@
finally { jj_save(1, xla); }
}
- final private boolean jj_3_2() {
- if (jj_scan_token(ArgQuote2)) return true;
- if (jj_scan_token(CloseQuote2)) return true;
- return false;
- }
-
final private boolean jj_3_1() {
if (jj_scan_token(ArgQuote1)) return true;
if (jj_scan_token(CloseQuote1)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_2() {
+ if (jj_scan_token(ArgQuote2)) return true;
+ if (jj_scan_token(CloseQuote2)) return true;
return false;
}
1.6 +16 -7 jakarta-lucene/src/demo/org/apache/lucene/demo/html/HTMLParser.jj
Index: HTMLParser.jj
===================================================================
RCS file: /home/cvs/jakarta-lucene/src/demo/org/apache/lucene/demo/html/HTMLParser.jj,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- HTMLParser.jj 23 Nov 2003 18:37:32 -0000 1.5
+++ HTMLParser.jj 20 Apr 2004 16:27:24 -0000 1.6
@@ -74,7 +74,8 @@
StringBuffer title = new StringBuffer(SUMMARY_LENGTH);
StringBuffer summary = new StringBuffer(SUMMARY_LENGTH * 2);
Properties metaTags=new Properties();
- String currentMetaTag="";
+ String currentMetaTag=null;
+ String currentMetaContent=null;
int length = 0;
boolean titleComplete = false;
boolean inTitle = false;
@@ -184,11 +185,6 @@
void addText(String text) throws IOException {
if (inStyle)
return;
- if (inMetaTag)
- {
- metaTags.setProperty(currentMetaTag, text);
- return;
- }
if (inTitle)
title.append(text);
else {
@@ -206,6 +202,13 @@
afterSpace = false;
}
+
+ void addMetaTag() throws IOException {
+ metaTags.setProperty(currentMetaTag, currentMetaContent);
+ currentMetaTag = null;
+ currentMetaContent = null;
+ return;
+ }
void addSpace() throws IOException {
if (!afterSpace) {
@@ -284,11 +287,17 @@
&& t2 != null)
{
currentMetaTag=t2.image.toLowerCase();
+ if(currentMetaTag != null && currentMetaContent != null) {
+ addMetaTag();
+ }
}
if(inMetaTag && t1.image.equalsIgnoreCase("content") && t2 !=
null)
{
- addText(t2.image);
+ currentMetaContent=t2.image.toLowerCase();
+ if(currentMetaTag != null && currentMetaContent != null) {
+ addMetaTag();
+ }
}
}
)?
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org