@@ -49,17 +49,77 @@ else if (lang_code.startsWith("de"))
4949 }
5050 }
5151
52- public static int findValidEqualSign (String parameter ) {//find position of = sign outside html tag
53- if (parameter == null || parameter .isEmpty ()) return -1 ;
54- int idx = parameter .indexOf ("=" );
55- if (idx == -1 )
56- return idx ;
57- int idx2 = parameter .indexOf ("<" );
58- if ((idx2 == -1 ) || (idx < idx2 ))
59- return idx ;
52+ public static int findValidEqualSign (String str ) {//find valid position of = sign
53+ if (str == null || str .isEmpty ()) return -1 ;
54+ int len = str .length ();
55+ int noc = 2 ; //number of open curls
56+ int i = 0 ;
57+ while (i < len ) {
58+ char ch = str .charAt (i );
59+ switch (ch ) {
60+ case '{' :
61+ boolean found = false ;
62+ while (++i < len && ((ch = str .charAt (i )) == '{' )) {
63+ noc ++; found = true ;
64+ }
65+ if (found )
66+ noc ++;
67+ continue ;
68+ case '}' :
69+ boolean found2 = false ;
70+ while (noc > 0 && (++i < len ) && ((ch = str .charAt (i )) == '}' )) {
71+ noc --; found2 = true ;
72+ }
73+ if (found2 ) {
74+ if (noc > 0 )
75+ noc --;
76+ if (noc == 0 )
77+ return -1 ;
78+ continue ;
79+ }
80+ if (noc > 0 ) continue ;
81+ break ;
82+ case '<' :
83+ if (str .startsWith ("<nowiki>" , i )) {
84+ int end = str .indexOf ("</nowiki>" , i + 8 );
85+ if (end != -1 ) {
86+ i = end + 9 ;//go after tag "</nowiki>"
87+ continue ;
88+ }
89+ } else if (str .startsWith ("<code>" , i )) {
90+ int end = str .indexOf ("</code>" , i + 6 );
91+ if (end != -1 ) {
92+ i = end + 7 ;//go after tag "</code>"
93+ continue ;
94+ }
95+ } else if (str .startsWith ("<math>" , i )) {
96+ int end = str .indexOf ("</math>" , i + 6 );
97+ if (end != -1 ) {
98+ i = end + 7 ;//go after tag "</math>"
99+ continue ;
100+ }
101+ }
102+ int end = str .indexOf (">" , i );
103+ if (end != -1 ) {
104+ i = end + 1 ;// go after ">"
105+ continue ;
106+ }
107+ break ;
108+ case '|' :
109+ if (noc < 3 )
110+ return -1 ;
111+ break ;
112+ case '=' :
113+ if (noc < 3 )
114+ return i ;
115+ break ;
116+ }
117+ i ++;
118+ }
60119 return -1 ;
61120 }
62121
122+
63123 public static boolean checkInteger (String str ) {//check that string str is an unsigned integer number
64124 for (char c : str .trim ().toCharArray ()) {
65125 if (!Character .isDigit (c )) {
0 commit comments