~ubuntu-branches/ubuntu/gutsy/moin/gutsy

« back to all changes in this revision

Viewing changes to MoinMoin/formatter/base.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-02-14 16:09:24 UTC
  • mfrom: (0.2.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20060214160924-fyrx3gvknzqvt4vj
Tags: 1.5.2-1ubuntu1
Drop python2.3 package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
    def endDocument(self):
63
63
        return ""
64
64
 
65
 
    def startContent(self, content_id="content", **kwargs):
 
65
    def startContent(self, content_id="content", **kw):
66
66
        return ""
67
67
 
68
68
    def endContent(self):
87
87
        # call pagelink() for internal interwikilinks
88
88
        # to make shure they get counted for self.pagelinks
89
89
        wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_wiki(self.request, '%s:%s' % (interwiki, pagename))
90
 
        if wikitag=='Self' or wikitag==self.request.cfg.interwikiname:
 
90
        if wikitag == 'Self' or wikitag == self.request.cfg.interwikiname:
91
91
            if wikitail.find('#') > -1:
92
92
                wikitail, kw['anchor'] = wikitail.split('#', 1)
93
93
                wikitail = wikiutil.url_unquote(wikitail)
128
128
 
129
129
        return self.attachment_link(url, text)
130
130
 
131
 
 
132
131
    def anchordef(self, name):
133
132
        return ""
134
133
 
135
134
    def line_anchordef(self, lineno):
136
135
        return ""
137
136
 
138
 
    def anchorlink(self, on, name='', id=None):
 
137
    def anchorlink(self, on, name='', **kw):
139
138
        return ""
140
139
 
141
140
    def line_anchorlink(self, on, lineno=0):
142
141
        return ""
143
142
 
144
 
    def image(self, **kw):
145
 
        """ Take HTML <IMG> tag attributes in `attr`.
 
143
    def image(self, src=None, **kw):
 
144
        """An inline image.
146
145
 
147
 
        Attribute names have to be lowercase!
 
146
        Extra keyword arguments are according to the HTML <img> tag attributes.
 
147
        In particular an 'alt' or 'title' argument should give a description
 
148
        of the image.
148
149
        """
149
 
        attrstr = u''
150
 
        for attr, value in kw.items():
151
 
            if attr=='html_class':
152
 
                attr='class'
153
 
            attrstr = attrstr + u' %s="%s"' % (attr, wikiutil.escape(value))
154
 
        return u'<img%s>' % attrstr
 
150
        title = src
 
151
        for titleattr in ('title', 'html__title', 'alt', 'html__alt'):
 
152
            if kw.has_key(titleattr):
 
153
                title = kw[titleattr]
 
154
                break
 
155
        if title:
 
156
            return '[Image:%s]' % title
 
157
        return '[Image]'
155
158
 
156
159
    def smiley(self, text):
157
160
        return text
161
164
 
162
165
    # Text and Text Attributes ########################################### 
163
166
    
164
 
    def text(self, text):
 
167
    def text(self, text, **kw):
165
168
        if not self._highlight_re:
166
169
            return self._text(text)
167
170
            
185
188
    def _text(self, text):
186
189
        raise NotImplementedError
187
190
 
188
 
    def strong(self, on):
189
 
        raise NotImplementedError
190
 
 
191
 
    def emphasis(self, on):
192
 
        raise NotImplementedError
193
 
 
194
 
    def underline(self, on):
195
 
        raise NotImplementedError
196
 
 
197
 
    def highlight(self, on):
198
 
        raise NotImplementedError
199
 
 
200
 
    def sup(self, on):
201
 
        raise NotImplementedError
202
 
 
203
 
    def sub(self, on):
204
 
        raise NotImplementedError
205
 
 
206
 
    def strike(self, on):
 
191
    def strong(self, on, **kw):
 
192
        raise NotImplementedError
 
193
 
 
194
    def emphasis(self, on, **kw):
 
195
        raise NotImplementedError
 
196
 
 
197
    def underline(self, on, **kw):
 
198
        raise NotImplementedError
 
199
 
 
200
    def highlight(self, on, **kw):
 
201
        raise NotImplementedError
 
202
 
 
203
    def sup(self, on, **kw):
 
204
        raise NotImplementedError
 
205
 
 
206
    def sub(self, on, **kw):
 
207
        raise NotImplementedError
 
208
 
 
209
    def strike(self, on, **kw):
207
210
        raise NotImplementedError
208
211
 
209
212
    def code(self, on, **kw):
210
213
        raise NotImplementedError
211
214
 
212
 
    def preformatted(self, on):
 
215
    def preformatted(self, on, **kw):
213
216
        self.in_pre = on != 0
214
217
 
215
 
    def small(self, on):
 
218
    def small(self, on, **kw):
216
219
        raise NotImplementedError
217
220
 
218
 
    def big(self, on):
 
221
    def big(self, on, **kw):
219
222
        raise NotImplementedError
220
223
 
221
224
    # special markup for syntax highlighting #############################
222
225
 
223
 
    def code_area(self, on, code_id, **kwargs):
 
226
    def code_area(self, on, code_id, **kw):
224
227
        raise NotImplementedError
225
228
 
226
229
    def code_line(self, on):
234
237
    def linebreak(self, preformatted=1):
235
238
        raise NotImplementedError
236
239
 
237
 
    def paragraph(self, on):
238
 
        self.in_p = (on != 0)
 
240
    def paragraph(self, on, **kw):
 
241
        self.in_p = on != 0
239
242
 
240
 
    def rule(self, size=0):
 
243
    def rule(self, size=0, **kw):
241
244
        raise NotImplementedError
242
245
 
243
246
    def icon(self, type):
245
248
 
246
249
    # Lists ##############################################################
247
250
 
248
 
    def number_list(self, on, type=None, start=None):
 
251
    def number_list(self, on, type=None, start=None, **kw):
249
252
        raise NotImplementedError
250
253
 
251
 
    def bullet_list(self, on):
 
254
    def bullet_list(self, on, **kw):
252
255
        raise NotImplementedError
253
256
 
254
257
    def listitem(self, on, **kw):
255
258
        raise NotImplementedError
256
259
 
257
 
    def definition_list(self, on):
258
 
        raise NotImplementedError
259
 
 
260
 
    def definition_term(self, on, compact=0):
261
 
        raise NotImplementedError
262
 
 
263
 
    def definition_desc(self, on):
 
260
    def definition_list(self, on, **kw):
 
261
        raise NotImplementedError
 
262
 
 
263
    def definition_term(self, on, compact=0, **kw):
 
264
        raise NotImplementedError
 
265
 
 
266
    def definition_desc(self, on, **kw):
264
267
        raise NotImplementedError
265
268
 
266
269
    def heading(self, on, depth, **kw):
268
271
 
269
272
    # Tables #############################################################
270
273
    
271
 
    def table(self, on, attrs={}):
272
 
        raise NotImplementedError
273
 
 
274
 
    def table_row(self, on, attrs={}):
275
 
        raise NotImplementedError
276
 
 
277
 
    def table_cell(self, on, attrs={}):
 
274
    def table(self, on, attrs={}, **kw):
 
275
        raise NotImplementedError
 
276
 
 
277
    def table_row(self, on, attrs={}, **kw):
 
278
        raise NotImplementedError
 
279
 
 
280
    def table_cell(self, on, attrs={}, **kw):
278
281
        raise NotImplementedError
279
282
 
280
283
    # Dynamic stuff / Plugins ############################################
284
287
        return macro_obj.execute(name, args)    
285
288
 
286
289
    def _get_bang_args(self, line):
287
 
        if line[:2]=='#!':
 
290
        if line[:2] == '#!':
288
291
            try:
289
292
                name, args = line[2:].split(None, 1)
290
293
            except ValueError:
293
296
                return args
294
297
        return None
295
298
 
296
 
    def processor(self, processor_name, lines, is_parser = 0):
 
299
    def processor(self, processor_name, lines, is_parser=0):
297
300
        """ processor_name MUST be valid!
298
301
            writes out the result instead of returning it!
299
302
        """
306
309
                                           processor_name, "Parser")
307
310
            args = self._get_bang_args(lines[0])
308
311
            if args is not None:
309
 
                lines=lines[1:]
310
 
            p = parser('\n'.join(lines), self.request, format_args = args)
 
312
                lines = lines[1:]
 
313
            p = parser('\n'.join(lines), self.request, format_args=args)
311
314
            p.format(self)
312
315
            del p
313
316
        return ''
314
317
 
315
 
    def dynamic_content(self, parser, callback, arg_list = [], arg_dict = {},
316
 
                        returns_content = 1):
 
318
    def dynamic_content(self, parser, callback, arg_list=[], arg_dict={},
 
319
                        returns_content=1):
317
320
        content = parser[callback](*arg_list, **arg_dict)
318
321
        if returns_content:
319
322
            return content
322
325
 
323
326
    # Other ##############################################################
324
327
    
 
328
    def div(self, on, **kw):
 
329
        """ open/close a blocklevel division """
 
330
        return ""
 
331
    
 
332
    def span(self, on, **kw):
 
333
        """ open/close a inline span """
 
334
        return ""
 
335
    
325
336
    def rawHTML(self, markup):
326
337
        """ This allows emitting pre-formatted HTML markup, and should be
327
338
            used wisely (i.e. very seldom).
342
353
 
343
354
        return self.text(f.getvalue())
344
355
 
345
 
    def escapedText(self, on):
 
356
    def escapedText(self, on, **kw):
346
357
        """ This allows emitting text as-is, anything special will
347
358
            be escaped (at least in HTML, some text output format
348
359
            would possibly do nothing here)
351
362
 
352
363
    def comment(self, text):
353
364
        return ""
 
365