# HG changeset patch # User ReimarBauer # Date 1167887793 -3600 # Node ID adffe242a432ccb4219950cfd1c05abea0285733 # Parent 3c6f59cafbbe442f90171a8b0680be67eb320a67 added get_process_instruction and get_parser diff -r 3c6f59cafbbe -r adffe242a432 MoinMoin/wikiutil.py --- a/MoinMoin/wikiutil.py Thu Dec 21 03:39:57 2006 +0100 +++ b/MoinMoin/wikiutil.py Thu Jan 04 06:16:33 2007 +0100 @@ -1643,3 +1643,36 @@ def checkTicket(request, ticket): ourticket = createTicket(request, timestamp_str) return ticket == ourticket + +def get_process_instruction(text): + """Creates dict of process instructions""" + lines = text.split('\n') + dict = {} + dict["processing_instructions"] = False + for line in lines: + for pi in ("#format", "#refresh", "#redirect", "#deprecated", + "#pragma", "#form", "#acl", "#language"): + if line.lower().startswith(pi): + value = (line.split(pi))[1] + dict[str(pi[1:].lower())] = value.strip() + dict["processing_instructions"] = True + break + return dict + + +def get_parser(request, text): + """gets the parser used from text""" + pi = get_process_instruction(text) + pi_format = request.cfg.default_markup or "wiki" + + # check for XML content + if text and text[:5] == '