Commit 867a0f2b authored by Aurore Mo-Ma's avatar Aurore Mo-Ma

Revert "[wiki] ajout de la macro ("

This reverts commit e7d9593a06a54b57d3946ecfdeb8613264ea9196.
parent 7e6d2ba3
# Include is now a standard macro
MoinMoin - Include macro
Copyright (c) 2000 by Richard Jones <>
Copyright (c) 2000 by Jürgen Hermann <>
All rights reserved, see COPYING for details.
This macro includes the formatted content of the given page, following recursive
includes if encountered. Cycles are detected!
pagename Name of the page to include
heading Text for the generated heading (optional)
level Level (1..5) of the generated heading (optional)
[[Include(FooBar)]] -- include the text of FooBar in the current paragraph.
[[Include(FooBar, heading)]] -- add a H1 of 'Foo Bar' followed by the text
[[Include(FooBar, heading, 2]] -- add a H2 of 'Foo Bar'
[[Include(FooBar, 'All about Foo Bar', 2]] -- add a H2 of 'All about Foo Bar'
import sys, string, re, StringIO
from MoinMoin.Page import Page
args_re_pattern = r'(?P<name>\w+)(,\s*(?P<heading>(heading|[\'"](?P<htext>.+)[\'"]))(,\s*(?P<level>\d+))?)?'
def execute(macro, text, args_re=re.compile(args_re_pattern)):
ret = ''
# parse and check arguments
m = args_re.match(text)
if not m:
ret = ret + '<strong class="error">Invaild include arguments "%s"</strong>'%text
# get the Page
name ='name')
this_page =
if not hasattr(this_page, 'included'):
this_page.included = {}
if this_page.included.has_key(name):
ret = ret + '<strong class="error">Recursive include of "%s" forbidden</strong>'%name
inc_page = Page(name)
inc_page.included = this_page.included
# do headings
level = None
level = 1
heading ='htext')
heading = page.split_title()
level = int('level'))
ret = ret + macro.formatter.url(name, macro.formatter.heading(level, heading))
# output the Page
this_page.included[name] = 1
stdout = sys.stdout
# python... I love you
sys.stdout = StringIO.StringIO()
inc_page.send_page(macro.form, content_only=1)
ret = ret + sys.stdout.getvalue()
sys.stdout = stdout
# if not printable, then output a helper link
if not level and (not macro.form.has_key('print') or
not macro.form['print'].value):
ret = ret + macro.formatter.url(name, '<small>[goto %s]</small>'%name)
del this_page.included[name]
return ret
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment