Changeset 14532
- Timestamp:
- 2007-09-17T15:43:24+12:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
greenstone3/trunk/src/java/org/greenstone/gsdl3/util/GS2MacroResolver.java
r11264 r14532 20 20 21 21 import java.util.ArrayList; 22 import java.util.regex.Matcher; 23 import java.util.regex.Pattern; 24 import java.net.URLDecoder; 22 25 23 26 public class GS2MacroResolver 24 extends MacroResolver 27 extends MacroResolver 25 28 { 26 29 … … 71 74 // the (?s) treats the string as a single line, cos . 72 75 // doesn't necessarily match line breaks 73 if (text.matches("(?s).*"+m.macro+".*")) { 76 //if (text.matches("(?s).*"+m.macro+".*")) { 77 Pattern p_text = Pattern.compile(".*" + m.macro + ".*",Pattern.DOTALL); 78 Matcher match_text = p_text.matcher(text); 79 if (match_text.matches()) { 74 80 if (m.resolve) { 75 81 new_text = this.resolve(m.text, lang, scope, doc_oid); … … 78 84 } 79 85 text = text.replaceAll(m.macro, new_text); 86 if (m.macro.endsWith("\\\\")){ // to get rid of "\" from the string likes: "src="http://www.greenstone.org:80/.../mw.gif\">" 87 Pattern p_back_slash = Pattern.compile("\\\"");// create a pattern "\\\"", but it matches both " and \" 88 Matcher m_slash = p_back_slash.matcher(text); 89 String clean_str = ""; 90 int s=0; 91 while (m_slash.find()){ 92 if (!text.substring(m_slash.end()-2,m_slash.end()-1).equals("\\")){ 93 clean_str = clean_str + text.substring(s,m_slash.end()-1); // it matches ", so get a substring before " 94 }else{ 95 clean_str = clean_str + text.substring(s,m_slash.end()-2);// it matches \", so get a substring before \ 96 } 97 s = m_slash.end();// get the index of the last match 98 clean_str = clean_str + "\""; 99 } 100 text = clean_str + text.substring(s,text.length()); 101 } 80 102 } 81 103 break; 82 104 case TYPE_META: 83 if (text.matches(".*"+m.macro+".*")) { 105 Pattern p = Pattern.compile(".*" + m.macro + ".*",Pattern.DOTALL); 106 Matcher match = p.matcher(text); 107 if (match.matches()) { 84 108 if (node_info == null) { 85 109 node_info = gdbm_src.getInfo(doc_oid);
Note:
See TracChangeset
for help on using the changeset viewer.