Attachment 'wikiutil_20070104_patch.txt'
Download 1 # HG changeset patch
2 # User ReimarBauer <R.Bauer@fz-juelich.de>
3 # Date 1167887793 -3600
4 # Node ID adffe242a432ccb4219950cfd1c05abea0285733
5 # Parent 3c6f59cafbbe442f90171a8b0680be67eb320a67
6 added get_process_instruction and get_parser
7
8 diff -r 3c6f59cafbbe -r adffe242a432 MoinMoin/wikiutil.py
9 --- a/MoinMoin/wikiutil.py Thu Dec 21 03:39:57 2006 +0100
10 +++ b/MoinMoin/wikiutil.py Thu Jan 04 06:16:33 2007 +0100
11 @@ -1643,3 +1643,36 @@ def checkTicket(request, ticket):
12 ourticket = createTicket(request, timestamp_str)
13 return ticket == ourticket
14
15 +
16 +def get_process_instruction(text):
17 + """Creates dict of process instructions"""
18 + lines = text.split('\n')
19 + dict = {}
20 + dict["processing_instructions"] = False
21 + for line in lines:
22 + for pi in ("#format", "#refresh", "#redirect", "#deprecated",
23 + "#pragma", "#form", "#acl", "#language"):
24 + if line.lower().startswith(pi):
25 + value = (line.split(pi))[1]
26 + dict[str(pi[1:].lower())] = value.strip()
27 + dict["processing_instructions"] = True
28 + break
29 + return dict
30 +
31 +
32 +def get_parser(request, text):
33 + """gets the parser used from text"""
34 + pi = get_process_instruction(text)
35 + pi_format = request.cfg.default_markup or "wiki"
36 +
37 + # check for XML content
38 + if text and text[:5] == '<?xml':
39 + pi_format = "xslt"
40 +
41 + # check processing instructions
42 + if pi.has_key('format'):
43 + pi_format = (pi["format"])
44 + pi_format = pi_format.lower()
45 +
46 + Parser = searchAndImportPlugin(request.cfg, "parser", pi_format)
47 + return Parser
48 \ No newline at end of file
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.