Update of
/var/cvs/contributions/CMSContainer_Modules/glossary/src/java/com/finalist/cmsc/module/glossary
In directory
james.mmbase.org:/tmp/cvs-serv15443/glossary/src/java/com/finalist/cmsc/module/glossary
Modified Files:
Glossary.java
Log Message:
CMSC-1304 Backfixed the stuff I fixed in the 1.5 branch
See also:
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer_Modules/glossary/src/java/com/finalist/cmsc/module/glossary
See also: http://www.mmbase.org/jira/browse/CMSC-1304
Index: Glossary.java
===================================================================
RCS file:
/var/cvs/contributions/CMSContainer_Modules/glossary/src/java/com/finalist/cmsc/module/glossary/Glossary.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- Glossary.java 20 Feb 2009 14:22:57 -0000 1.9
+++ Glossary.java 4 Mar 2009 15:16:00 -0000 1.10
@@ -7,7 +7,7 @@
import java.util.regex.Pattern;
public class Glossary {
- public static final String LINKPATTERN = "<span class=\"glossaryWord\"
title=\"%s\" id=\"_glossary_%s\">%s</span>";
+ public static final String LINKPATTERN = "<dfn class=\"glossaryWord\"
title=\"%2$s - %s\" id=\"_glossary_%2$s\">%2$s</dfn>";
public static final String GLOSSARY = "glossary";
private final Map<String, String> terms = new HashMap<String, String>();
private static Glossary glossary = null;
@@ -34,7 +34,7 @@
int end = matcher.end();
String found = material.substring(start, end);
if (!isInFormatedFragment(material, word, start)) {
- String highlight = String.format(LINKPATTERN, terms.get(word),
found, found);
+ String highlight = String.format(LINKPATTERN, terms.get(word),
found);
material = (new StringBuilder()).append(material.substring(0,
start)).append(highlight).append(
material.substring(end, material.length())).toString();
break;
@@ -46,17 +46,21 @@
}
- private boolean isInFormatedFragment(String material, String keywords, int
keywordStartPosition) {
- Pattern pattern = Pattern.compile(String.format("<[abh][^</]*%s[^>]*>",
keywords));
- Matcher matcher = pattern.matcher(material);
+ private boolean isInFormatedFragment(String material, String keyword, int
keywordStartPosition) {
+ String materialBefore = material.substring(0, keywordStartPosition);
- while (matcher.find()) {
- int start = matcher.start();
- int end = matcher.end();
+ int openA = materialBefore.lastIndexOf("<a");
+ int closeA = materialBefore.lastIndexOf("/a>");
+ if(openA > closeA) {
+ return true;
+ }
- if (keywordStartPosition + keywords.length() < end &&
keywordStartPosition > start)
+ int openInput = materialBefore.lastIndexOf("<input");
+ int closeInput = materialBefore.lastIndexOf(">");
+ if(openInput > closeInput) {
return true;
}
+
return false;
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs