[Moin-user] How can a macro output a wikitext together with another macro...

R.Bauer rb.proj at gmail.com
Thu Apr 2 04:06:02 EDT 2009


Mail at Heavy.ch schrieb:
> hi there
> 
> I made some small macro like:
> <<Licence(type="article",source="wikipedia",item="MoinMoin")>>
> 
> with should output some FootNote Macro with prefilled automatic
> generated footnote text/links, well see here for an example
> 
> http://rock.heavy.ch/Test
> 
> The problem is that the macro "FootNote" is not getting
> rendered/executed. How I can do this?
> 
> My source looks like this (in short):
> ********************************************
> from MoinMoin.parser.text_moin_wiki import Parser as WikiParser
>     request = macro.request
>     formatter = macro.formatter
>             wikitext = u'''
>              <<FootNote(
>              Diese Wikiseite basiert auf dem Artikel
> [[%(urlWikipedia)s/%(item)s|%(item)s]]
>              aus der freien Enzyklopädie Wikipedia und steht unter
> der [[%(urlGFDL)s|GFDL]]
>              In der Wikipedia ist eine Liste der
> [[%(urlWikipediaAuthor)s/index.php?title=%(item)s&action=history|Autoren]]
> verfügbar.
>              )>>
>         ''' % {
>             "item": item,
>             "urlWikipedia" : urlWikipedia,
>             "urlGFDL" : urlGFDL,
>             "urlWikipediaAuthor" : urlWikipediaAuthor,
>         }
>     wikitext = wikiutil.escape(wikitext)
>     WikiParser(wikitext,request).format(request.formatter)
> ********************************************
> 
> The output as a normal wiki text works but if you use some @PAGE@, <!>

Hi Marcel

That vars @ .. @ aren't parsed they are only replaced by PageEditor on
saving.

see PageEditor._expand_variables

also look at wikiutil.renderText


> or even another Macro it's not working.



> 
> Is there an example how I can call from a macro another marco and
> parse/render this? I was looking in other macros and in the source of
> moinmoin but couldn't find any examples how to do this. Any hints? :-)))

look at bottom of
http://moinmo.in/MacroMarket/SvgPlot-1.8

the unit tests are also a good source for examples.

(me will add that example later to the MoinAPI/Beipiele)

> 
> Btw. I tried first to directly return the text with a formatter but I
> was only able to this with text or rawHTML and not moin wiki text. Did I
> miss something?
> 
> --> Or would it better to do make this stuff with a parser like
> {{{#!License type=article,source=wikipedia,item=MoinMoin
> }}}

a macro is better and try to use the arg_parser for your arguments for
macro_license.py.

cheers
Reimar

> 
> bye
> Marcel
> 
> p.s.
> sended this already with the wrong from e-mail adress, so this is the
> right one, the other can be deleted.
> 
> 
> 
> ------------------------------------------------------------------------------





More information about the Moin-user mailing list