sunflower 0.3 → 0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -1,4 +1,4 @@
1
- Version: 0.2 alpha
1
+ Version: 0.4 alpha
2
2
 
3
3
  >>> English:
4
4
 
@@ -1,251 +1,266 @@
1
- # coding: utf-8
2
- # extends Page with some methods letting easily perform common tasks
3
-
4
- class Page
5
- def execute commands
6
- # executes methods on self
7
- # "commands" is array of arrays
8
- # page.execute([
9
- # [:replace, 'something', 'whatever'],
10
- # [:append, 'some things']
11
- # ])
12
- # equals to
13
- # page.replace('something', 'whatever')
14
- # page.append('some things')
15
-
16
- # allowed modifiers:
17
- # r, required
18
- # oi:module, only-if:module
19
- # !oi:module, only-if-not:module
20
- # s:append to summary, summary:append to summary
21
- originalText = self.text.dup
22
-
23
- commands.each do |cmd|
24
- f=cmd.shift
25
- if f.class==Array
26
- methodName=f.shift
27
- modifiers=f.map{|i|
28
- i+=':' if !i.include? ':'
29
- i=i.split(':',-1)
30
- i[0]=i[0].downcase.gsub(/[^a-z!]/,'')
31
-
32
- i[0]='r' if i[0]=='required'
33
- i[0]='oi' if i[0]=='onlyif'
34
- i[0]='!oi' if i[0]=='onlyifnot'
35
- i[0]='s' if i[0]=='summary'
36
-
37
- type=i.shift
38
- i=i.join(':')
39
-
40
- [type,i]
41
- }
42
- modifiers=Hash[*(modifiers.flatten)]
43
- else
44
- methodName=f
45
- modifiers={}
46
- end
47
-
48
- if modifiers['oi']
49
- if !@modulesExecd.index(modifiers['oi'].strip)
50
- next #skip this command
51
- end
52
- end
53
- if modifiers['!oi']
54
- if @modulesExecd.index(modifiers['oi'].strip)
55
- next #skip this command
56
- end
57
- end
58
-
59
- oldText=self.text
60
- self.method(methodName).call(*cmd)
61
- newText=self.text
62
-
63
- @modulesExecd<<methodName if oldText!=newText
64
-
65
- if modifiers['s'] && oldText!=newText
66
- @summaryAppend<<modifiers['s'].strip
67
- end
68
-
69
- if modifiers['r'] && oldText==newText
70
- self.text = originalText
71
- break #reset text and stop executing commands
72
- end
73
- end
74
- end
75
-
76
-
77
-
78
- def replace from, to, once=false
79
- # replaces "from" with "to" in page text
80
- # "from" may be regex
81
- self.text = self.text.send( (once ? 'sub' : 'gsub'), from, to )
82
- end
83
- def gsub from, to
84
- self.replace from, to
85
- end
86
- def sub from, to
87
- self.replace from, to, true
88
- end
89
-
90
- def append txt, newlines=2
91
- # appends newlines and text
92
- # by default - 2 newlines
93
- self.text = self.text.rstrip + ("\n"*newlines) + txt
94
- end
95
-
96
- def prepend txt, newlines=2
97
- # prepends text and newlines
98
- # by default - 2 newlines
99
- self.text = txt + ("\n"*newlines) + self.text.lstrip
100
- end
101
-
102
- def code_cleanup
103
- # simple, safe code cleanup
104
- # use Sunflower.always_do_code_cleanup=true to do it automatically just before saving page
105
- # based on Nux's cleaner: http://pl.wikipedia.org/wiki/Wikipedysta:Nux/wp_sk.js
106
- str=self.text.gsub(/\r\n/,"\n")
107
-
108
- str.gsub!(/\{\{\s*([^|{}]+ |uni|)stub2?(\|[^{}]+)?\}\}/i){
109
- if $1=='sekcja '
110
- '{{sekcja stub}}'
111
- else
112
- '{{stub}}'
113
- end
114
- }
115
- str.gsub!(/\{\{\{(?:poprzednik|następca|pop|nast|lata|info|lang)\|(.+?)\}\}\}/i,'\1')
116
- str.gsub!(/(={1,5})\s*Przypisy\s*\1\s*<references\s?\/>/){
117
- if $1=='=' || $1=='=='
118
- '{{Przypisy}}'
119
- else
120
- '{{Przypisy|stopień= '+$1+'}}'
121
- end
122
- }
123
-
124
- # sklejanie skrótów linkowych
125
- str.gsub!(/m\.? ?\[\[n\.? ?p\.? ?m\.?\]\]/, 'm [[n.p.m.]]');
126
-
127
- # korekty dat - niepotrzebny przecinek
128
- str.gsub!(/(\[\[[0-9]+ (stycznia|lutego|marca|kwietnia|maja|czerwca|lipca|sierpnia|września|października|listopada|grudnia)\]\]), (\[\[[0-9]{4}\]\])/i, '\1 \3');
129
-
130
- # linkowanie do wieków
131
- str.gsub!(/\[\[([XVI]{1,5}) [wW]\.?\]\]/, '[[\1 wiek|\1 w.]]');
132
- str.gsub!(/\[\[([XVI]{1,5}) [wW]\.?\|/, '[[\1 wiek|');
133
- str.gsub!(/\[\[(III|II|IV|VIII|VII|VI|IX|XIII|XII|XI|XIV|XV|XVIII|XVII|XVI|XIX|XXI|XX)\]\]/, '[[\1 wiek|\1]]');
134
- str.gsub!(/\[\[(III|II|IV|VIII|VII|VI|IX|XIII|XII|XI|XIV|XV|XVIII|XVII|XVI|XIX|XXI|XX)\|/, '[[\1 wiek|');
135
-
136
- # rozwijanie typowych linków
137
- str.gsub!(/\[\[ang\.\]\]/, '[[język angielski|ang.]]');
138
- str.gsub!(/\[\[cz\.\]\]/, '[[język czeski|cz.]]');
139
- str.gsub!(/\[\[fr\.\]\]/, '[[język francuski|fr.]]');
140
- str.gsub!(/\[\[łac\.\]\]/, '[[łacina|łac.]]');
141
- str.gsub!(/\[\[niem\.\]\]/, '[[język niemiecki|niem.]]');
142
- str.gsub!(/\[\[pol\.\]\]/, '[[język polski|pol.]]');
143
- str.gsub!(/\[\[pl\.\]\]/, '[[język polski|pol.]]');
144
- str.gsub!(/\[\[ros\.\]\]/, '[[język rosyjski|ros.]]');
145
- str.gsub!(/\[\[(((G|g)iga|(M|m)ega|(K|k)ilo)herc|[GMk]Hz)\|/, '[[herc|');
146
-
147
- # unifikacja nagłówkowa
148
- str.gsub!(/[ \n\t]*\n'''? *(Zobacz|Patrz) (też|także):* *'''?[ \n\t]*/i, "\n\n== Zobacz też ==\n");
149
- str.gsub!(/[ \n\t]*\n(=+) *(Zobacz|Patrz) (też|także):* *=+[ \n\t]*/i, "\n\n\\1 Zobacz też \\1\n");
150
- str.gsub!(/[ \n\t]*\n'''? *((Zewnętrzn[ey] )?(Linki?|Łącza|Stron[ay]|Zobacz w (internecie|sieci))( zewn[eę]trzn[aey])?):* *'''?[ \n\t]*/i, "\n\n== Linki zewnętrzne ==\n");
151
- str.gsub!(/[ \n\t]*\n(=+) *((Zewnętrzn[ey] )?(Linki?|Łącza|Stron[ay]|Zobacz w (internecie|sieci))( zewn[eę]trzn[aey])?):* *=+[ \n\t]*/i, "\n\n\\1 Linki zewnętrzne \\1\n");
152
-
153
- # nagłówki
154
- str.gsub!(/(^|\n)(=+) *([^=\n]*[^ :=\n])[ :]*=/, '\1\2 \3 ='); # =a= > = a =, =a:= > = a =
155
- str.gsub!(/(^|\n)(=+[^=\n]+=+)[\n]{2,}/, "\\1\\2\n"); # jeden \n
156
-
157
- # listy ze spacjami
158
- str.gsub!(/(\n[#*:;]+)([^ \t\n#*:;{])/, '\1 \2');
159
-
160
- # poprawa nazw przestrzeni i drobne okoliczne
161
- str.gsub!(/\[\[(:?) *(image|grafika|file|plik) *: *([^ ])/i){'[['+$1+'Plik:'+$3.upcase}
162
- str.gsub!(/\[\[(:?) *(category|kategoria) *: *([^ ])/i){'[['+$1+'Kategoria:'+$3.upcase}
163
- str.gsub!(/\[\[ *(:?) *(template|szablon) *: *([^ ])/i){'[['+'Szablon:'+$3.upcase}
164
- str.gsub!(/\[\[ *(:?) *(special|specjalna) *: *([^ ])/i){'[['+'Specjalna:'+$3.upcase}
165
-
166
- 3.times { str.gsub!('{{stub}}{{stub}}', '{{stub}}') }
167
-
168
- self.text = str
169
- end
170
-
171
- def friendly_infobox
172
- # cleans up infoboxes
173
- # might make mistakes! use at your own risk!
174
- def makeFriendly(nazwa,zaw)
175
- zaw.gsub!(/<!--.+?-->/,'')
176
- nazwa=nazwa.gsub('_',' ').strip
177
-
178
- #escapowanie parametrów
179
- zaw.gsub!(/<<<(#+)>>>/,"<<<#\\1>>>")
180
- #wewnętrzne szablony
181
- while zaw=~/\{\{[^}]+\|[^}]+\}\}/
182
- zaw.gsub!($&,$&.gsub(/\|/,'<<<#>>>'))
183
- end
184
- #wewnętrzne linki
185
- while zaw=~/\[\[[^\]]+\|[^\]]+\]\]/
186
- zaw.gsub!($&,$&.gsub(/\|/,'<<<#>>>'))
187
- end
188
-
189
- zaw.sub!(/\A\s*\|\s*/,'') #usunięcie pierwszego pipe'a
190
- lines=zaw.split('|')
191
-
192
- # te tablice przechowują odpowiednio nazwy i wartości kolejnych parametrów
193
- names=[]
194
- values=[]
195
-
196
- for line in lines
197
- line.gsub!(/<<<#>>>/,'|')
198
- line.gsub!(/<<<#(#+)>>>/,"<<<\\1>>>") #odescapowanie
199
-
200
- line=~/\A\s*(.+?)\s*=\s*([\s\S]*?)\s*\Z/
201
- if $&==nil
202
- next
203
- end
204
- name=$1.strip
205
- value=$2.strip
206
-
207
- names<<name
208
- values<<value
209
- end
210
-
211
- zaw=''
212
- names.each_index{|i|
213
- zaw+=' | '+names[i]+' = '+values[i]+"\n"
214
- }
215
-
216
- # grupowane koordynaty
217
- zaw.gsub!(/\s*\| minut/, ' | minut')
218
- zaw.gsub!(/\s*\| sekund/, ' | sekund')
219
-
220
- return '{{'+nazwa[0,1].upcase+nazwa[1,999]+"\n"+zaw+'}}'+"\n"
221
- end
222
-
223
- nstr=''
224
- while str!=''
225
- str=~/(\s*)\{\{([^|}]+[ _]infobo[^|}]+|[wW]ładca)((?:[^{}]|[^{}][{}][^{}]|\{\{(?:[^{}]|[^{}][{}][^{}]|\{\{[^{}]+\}\})+\}\})+)\}\}(?:\s*)/
226
-
227
- spaces=($1!='' ? "\n" : '')
228
- before=($`==nil ? '' : $`)
229
- name=$2
230
- inner=$3
231
- match=$&
232
- if match!=nil
233
- result=makeFriendly(name,inner)
234
- nstr+=before+spaces+result
235
- else
236
- nstr+=str
237
- break
238
- end
239
-
240
- str=str.sub(before+match,'')
241
- end
242
-
243
- self.text = nstr
244
- end
245
-
246
- def change_category from, to
247
- from=from.sub(/\A\s*([cC]ategory|[kK]ategoria):/, '').strip
248
- to=to.sub(/\A\s*([cC]ategory|[kK]ategoria):/, '').strip
249
- self.text = self.text.gsub!(/\[\[ *(?:[cC]ategory|[kK]ategoria) *: *#{Regexp.escape from} *(\|[^\]]+ *|)\]\]/){'[[Kategoria:'+to+$1.rstrip+']]'}
250
- end
1
+ # coding: utf-8
2
+ # extends Page with some methods letting easily perform common tasks
3
+
4
+ class Page
5
+ def execute commands
6
+ # executes methods on self
7
+ # "commands" is array of arrays
8
+ # page.execute([
9
+ # [:replace, 'something', 'whatever'],
10
+ # [:append, 'some things']
11
+ # ])
12
+ # equals to
13
+ # page.replace('something', 'whatever')
14
+ # page.append('some things')
15
+
16
+ # allowed modifiers:
17
+ # r, required
18
+ # oi:module, only-if:module
19
+ # !oi:module, only-if-not:module
20
+ # s:append to summary, summary:append to summary
21
+ originalText = self.text.dup
22
+
23
+ commands.each do |cmd|
24
+ f=cmd.shift
25
+ if f.class==Array
26
+ methodName=f.shift
27
+ modifiers=f.map{|i|
28
+ i+=':' if !i.include? ':'
29
+ i=i.split(':',-1)
30
+ i[0]=i[0].downcase.gsub(/[^a-z!]/,'')
31
+
32
+ i[0]='r' if i[0]=='required'
33
+ i[0]='oi' if i[0]=='onlyif'
34
+ i[0]='!oi' if i[0]=='onlyifnot'
35
+ i[0]='s' if i[0]=='summary'
36
+
37
+ type=i.shift
38
+ i=i.join(':')
39
+
40
+ [type,i]
41
+ }
42
+ modifiers=Hash[*(modifiers.flatten)]
43
+ else
44
+ methodName=f
45
+ modifiers={}
46
+ end
47
+
48
+ if modifiers['oi']
49
+ if !@modulesExecd.index(modifiers['oi'].strip)
50
+ next #skip this command
51
+ end
52
+ end
53
+ if modifiers['!oi']
54
+ if @modulesExecd.index(modifiers['oi'].strip)
55
+ next #skip this command
56
+ end
57
+ end
58
+
59
+ oldText=self.text
60
+ self.method(methodName).call(*cmd)
61
+ newText=self.text
62
+
63
+ @modulesExecd<<methodName if oldText!=newText
64
+
65
+ if modifiers['s'] && oldText!=newText
66
+ @summaryAppend<<modifiers['s'].strip
67
+ end
68
+
69
+ if modifiers['r'] && oldText==newText
70
+ self.text = originalText
71
+ break #reset text and stop executing commands
72
+ end
73
+ end
74
+ end
75
+
76
+
77
+
78
+ def replace from, to, once=false
79
+ # replaces "from" with "to" in page text
80
+ # "from" may be regex
81
+ self.text = self.text.send( (once ? 'sub' : 'gsub'), from, to )
82
+ end
83
+ def gsub from, to
84
+ self.replace from, to
85
+ end
86
+ def sub from, to
87
+ self.replace from, to, true
88
+ end
89
+
90
+ def append txt, newlines=2
91
+ # appends newlines and text
92
+ # by default - 2 newlines
93
+ self.text = self.text.rstrip + ("\n"*newlines) + txt
94
+ end
95
+
96
+ def prepend txt, newlines=2
97
+ # prepends text and newlines
98
+ # by default - 2 newlines
99
+ self.text = txt + ("\n"*newlines) + self.text.lstrip
100
+ end
101
+
102
+ def code_cleanup
103
+ # simple, safe code cleanup
104
+ # use Sunflower.always_do_code_cleanup=true to do it automatically just before saving page
105
+ # based on Nux's cleaner: http://pl.wikipedia.org/wiki/Wikipedysta:Nux/wp_sk.js
106
+ str=self.text.gsub(/\r\n/,"\n")
107
+
108
+ str.gsub!(/\{\{\s*([^|{}]+ |uni|)stub2?(\|[^{}]+)?\}\}/i){
109
+ if $1=='sekcja '
110
+ '{{sekcja stub}}'
111
+ else
112
+ '{{stub}}'
113
+ end
114
+ }
115
+ str.gsub!(/\{\{\{(?:poprzednik|następca|pop|nast|lata|info|lang)\|(.+?)\}\}\}/i,'\1')
116
+ str.gsub!(/(={1,5})\s*Przypisy\s*\1\s*<references\s?\/>/i){
117
+ if $1=='=' || $1=='=='
118
+ '{{Przypisy}}'
119
+ else
120
+ '{{Przypisy|stopień= '+$1+'}}'
121
+ end
122
+ }
123
+
124
+ str.gsub!(/\[\[([^\|#\]]*)([^\|\]]*)(\||\]\])/){
125
+ name, anchor, _end = $1, $2, $3
126
+
127
+ begin
128
+ name=CGI.unescape(name)
129
+ anchor=CGI.unescape((anchor||'').gsub(/\.([0-9A-F]{2})/,'%\1'))
130
+ a='[['+name+anchor+(_end||'')
131
+ a=a.gsub '_', ' '
132
+ rescue
133
+ a=('[['+name+(anchor||'')+(_end||'')).gsub '_', ' '
134
+ end
135
+
136
+ a
137
+ }
138
+
139
+ # sklejanie skrótów linkowych
140
+ str.gsub!(/m\.? ?\[\[n\.? ?p\.? ?m\.?\]\]/, 'm [[n.p.m.]]');
141
+
142
+ # korekty dat - niepotrzebny przecinek
143
+ str.gsub!(/(\[\[[0-9]+ (stycznia|lutego|marca|kwietnia|maja|czerwca|lipca|sierpnia|września|października|listopada|grudnia)\]\]), (\[\[[0-9]{4}\]\])/i, '\1 \3');
144
+
145
+ # linkowanie do wieków
146
+ str.gsub!(/\[\[([XVI]{1,5}) [wW]\.?\]\]/, '[[\1 wiek|\1 w.]]');
147
+ str.gsub!(/\[\[([XVI]{1,5}) [wW]\.?\|/, '[[\1 wiek|');
148
+ str.gsub!(/\[\[(III|II|IV|VIII|VII|VI|IX|XIII|XII|XI|XIV|XV|XVIII|XVII|XVI|XIX|XXI|XX)\]\]/, '[[\1 wiek|\1]]');
149
+ str.gsub!(/\[\[(III|II|IV|VIII|VII|VI|IX|XIII|XII|XI|XIV|XV|XVIII|XVII|XVI|XIX|XXI|XX)\|/, '[[\1 wiek|');
150
+
151
+ # rozwijanie typowych linków
152
+ str.gsub!(/\[\[ang\.\]\]/, '[[język angielski|ang.]]');
153
+ str.gsub!(/\[\[cz\.\]\]/, '[[język czeski|cz.]]');
154
+ str.gsub!(/\[\[fr\.\]\]/, '[[język francuski|fr.]]');
155
+ str.gsub!(/\[\[łac\.\]\]/, '[[łacina|łac.]]');
156
+ str.gsub!(/\[\[niem\.\]\]/, '[[język niemiecki|niem.]]');
157
+ str.gsub!(/\[\[pol\.\]\]/, '[[język polski|pol.]]');
158
+ str.gsub!(/\[\[pl\.\]\]/, '[[język polski|pol.]]');
159
+ str.gsub!(/\[\[ros\.\]\]/, '[[język rosyjski|ros.]]');
160
+ str.gsub!(/\[\[(((G|g)iga|(M|m)ega|(K|k)ilo)herc|[GMk]Hz)\|/, '[[herc|');
161
+
162
+ # unifikacja nagłówkowa
163
+ str.gsub!(/[ \n\t]*\n'''? *(Zobacz|Patrz) (też|także):* *'''?[ \n\t]*/i, "\n\n== Zobacz też ==\n");
164
+ str.gsub!(/[ \n\t]*\n(=+) *(Zobacz|Patrz) (też|także):* *=+[ \n\t]*/i, "\n\n\\1 Zobacz też \\1\n");
165
+ str.gsub!(/[ \n\t]*\n'''? *((Zewnętrzn[ey] )?(Linki?|Łącza|Stron[ay]|Zobacz w (internecie|sieci))( zewn[eę]trzn[aey])?):* *'''?[ \n\t]*/i, "\n\n== Linki zewnętrzne ==\n");
166
+ str.gsub!(/[ \n\t]*\n(=+) *((Zewnętrzn[ey] )?(Linki?|Łącza|Stron[ay]|Zobacz w (internecie|sieci))( zewn[eę]trzn[aey])?):* *=+[ \n\t]*/i, "\n\n\\1 Linki zewnętrzne \\1\n");
167
+
168
+ # nagłówki
169
+ str.gsub!(/(^|\n)(=+) *([^=\n]*[^ :=\n])[ :]*=/, '\1\2 \3 ='); # =a= > = a =, =a:= > = a =
170
+ str.gsub!(/(^|\n)(=+[^=\n]+=+)[\n]{2,}/, "\\1\\2\n"); # jeden \n
171
+
172
+ # listy ze spacjami
173
+ str.gsub!(/(\n[#*:;]+)([^ \t\n#*:;{])/, '\1 \2');
174
+
175
+ # poprawa nazw przestrzeni i drobne okoliczne
176
+ str.gsub!(/\[\[(:?) *(image|grafika|file|plik) *: *([^ ])/i){'[['+$1+'Plik:'+$3.upcase}
177
+ str.gsub!(/\[\[(:?) *(category|kategoria) *: *([^ ])/i){'[['+$1+'Kategoria:'+$3.upcase}
178
+ str.gsub!(/\[\[ *(:?) *(template|szablon) *: *([^ ])/i){'[['+'Szablon:'+$3.upcase}
179
+ str.gsub!(/\[\[ *(:?) *(special|specjalna) *: *([^ ])/i){'[['+'Specjalna:'+$3.upcase}
180
+
181
+ 3.times { str.gsub!('{{stub}}{{stub}}', '{{stub}}') }
182
+
183
+ self.text = str
184
+ end
185
+
186
+ def friendly_infobox
187
+ # cleans up infoboxes
188
+ # might make mistakes! use at your own risk!
189
+ def makeFriendly(nazwa,zaw)
190
+ zaw.gsub!(/<!--.+?-->/,'')
191
+ nazwa=nazwa.gsub('_',' ').strip
192
+
193
+ #escapowanie parametrów
194
+ zaw.gsub!(/<<<(#+)>>>/,"<<<#\\1>>>")
195
+ #wewnętrzne szablony
196
+ while zaw=~/\{\{[^}]+\|[^}]+\}\}/
197
+ zaw.gsub!($&,$&.gsub(/\|/,'<<<#>>>'))
198
+ end
199
+ #wewnętrzne linki
200
+ while zaw=~/\[\[[^\]]+\|[^\]]+\]\]/
201
+ zaw.gsub!($&,$&.gsub(/\|/,'<<<#>>>'))
202
+ end
203
+
204
+ zaw.sub!(/\A\s*\|\s*/,'') #usunięcie pierwszego pipe'a
205
+ lines=zaw.split('|')
206
+
207
+ # te tablice przechowują odpowiednio nazwy i wartości kolejnych parametrów
208
+ names=[]
209
+ values=[]
210
+
211
+ for line in lines
212
+ line.gsub!(/<<<#>>>/,'|')
213
+ line.gsub!(/<<<#(#+)>>>/,"<<<\\1>>>") #odescapowanie
214
+
215
+ line=~/\A\s*(.+?)\s*=\s*([\s\S]*?)\s*\Z/
216
+ if $&==nil
217
+ next
218
+ end
219
+ name=$1.strip
220
+ value=$2.strip
221
+
222
+ names<<name
223
+ values<<value
224
+ end
225
+
226
+ zaw=''
227
+ names.each_index{|i|
228
+ zaw+=' | '+names[i]+' = '+values[i]+"\n"
229
+ }
230
+
231
+ # grupowane koordynaty
232
+ zaw.gsub!(/\s*\| minut/, ' | minut')
233
+ zaw.gsub!(/\s*\| sekund/, ' | sekund')
234
+
235
+ return '{{'+nazwa[0,1].upcase+nazwa[1,999]+"\n"+zaw+'}}'+"\n"
236
+ end
237
+
238
+ nstr=''
239
+ while str!=''
240
+ str=~/(\s*)\{\{([^|}]+[ _]infobo[^|}]+|[wW]ładca)((?:[^{}]|[^{}][{}][^{}]|\{\{(?:[^{}]|[^{}][{}][^{}]|\{\{[^{}]+\}\})+\}\})+)\}\}(?:\s*)/
241
+
242
+ spaces=($1!='' ? "\n" : '')
243
+ before=($`==nil ? '' : $`)
244
+ name=$2
245
+ inner=$3
246
+ match=$&
247
+ if match!=nil
248
+ result=makeFriendly(name,inner)
249
+ nstr+=before+spaces+result
250
+ else
251
+ nstr+=str
252
+ break
253
+ end
254
+
255
+ str=str.sub(before+match,'')
256
+ end
257
+
258
+ self.text = nstr
259
+ end
260
+
261
+ def change_category from, to
262
+ from=from.sub(/\A\s*([cC]ategory|[kK]ategoria):/, '').strip
263
+ to=to.sub(/\A\s*([cC]ategory|[kK]ategoria):/, '').strip
264
+ self.text = self.text.gsub(/\[\[ *(?:[cC]ategory|[kK]ategoria) *: *#{Regexp.escape from} *(\|[^\]]+ *|)\]\]/){'[[Kategoria:'+to+$1.rstrip+']]'}
265
+ end
251
266
  end