annotate MoinMoin/parser/text_moin_wiki.py @ 3077:66d35649ca99

add 'percent' kw to getText (must be True when using result as left side of % operator), refactored some code, better comments (ported from 1.6)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 22 Feb 2008 22:35:46 +0100
parents ed1a433803c6
children c6e39279f83b
rev   line source
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
2 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
3 MoinMoin - MoinMoin Wiki Markup Parser
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
4
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1868
diff changeset
5 @copyright: 2000-2002 Juergen Hermann <jh@web.de>,
2039
ca376b20b122 wiki parser: remove unneded non-capturing group, update (c) header
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2023
diff changeset
6 2006-2007 MoinMoin:ThomasWaldmann,
2016
e55ae6646935 text_moin_wiki: fixed nested {{{ bug
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1968
diff changeset
7 2007 by MoinMoin:ReimarBauer
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
8 @license: GNU GPL, see COPYING for details.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
9 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
10
1667
e3c56a97e30c wiki parser: removed unused imports, cosmetic changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1572
diff changeset
11 import re
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
12 import logging
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
13
635
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 569
diff changeset
14 from MoinMoin import config, wikiutil, macro
2755
7c8e3ce74202 wiki parser: using <object> for client side page transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2746
diff changeset
15 from MoinMoin.Page import Page
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
16 from MoinMoin.support.python_compatibility import rsplit, set
2567
b403a24f7c8f (xorAxAx, johill) make saner looking anchors, no more sha hash
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2566
diff changeset
17
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2263
diff changeset
18 Dependencies = ['user'] # {{{#!wiki comment ... }}} has different output depending on the user's profile settings
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
19
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
20
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
21 class Parser:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
22 """
2777
8e87182648f4 cleaned up wiki parser comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2771
diff changeset
23 Parse wiki format markup (and call the formatter to generate output).
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
24
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
25 All formatting commands can be parsed one line at a time, though
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
26 some state is carried over between lines.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
27
2777
8e87182648f4 cleaned up wiki parser comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2771
diff changeset
28 Methods named like _*_repl() are responsible to handle the named regex patterns.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
29 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
30
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
31 # allow caching
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
32 caching = 1
2196
45cf51902c61 wiki comment divs: fix caching behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2195
diff changeset
33 Dependencies = Dependencies
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
34
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
35 # some common strings
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
36 CHILD_PREFIX = wikiutil.CHILD_PREFIX
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
37 CHILD_PREFIX_LEN = wikiutil.CHILD_PREFIX_LEN
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
38 PARENT_PREFIX = wikiutil.PARENT_PREFIX
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
39 PARENT_PREFIX_LEN = wikiutil.PARENT_PREFIX_LEN
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
40
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
41 punct_pattern = re.escape(u'''"\'}]|:,.)?!''')
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
42 url_scheme = u'|'.join(config.url_schemas)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
43
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
44 # some common rules
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
45 url_rule = ur'''
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
46 (?:^|(?<=\W)) # require either beginning of line or some non-alphanum char (whitespace, punctuation) to the left
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
47 (?P<url_target> # capture whole url there
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
48 (?P<url_scheme>%(url_scheme)s) # some scheme
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
49 \:
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
50 \S+? # anything non-whitespace
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
51 )
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
52 (?:$|(?=\s|[%(punct)s]+(\s|$))) # require either end of line or some whitespace or some punctuation+blank/eol afterwards
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
53 ''' % {
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
54 'url_scheme': url_scheme,
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
55 'punct': punct_pattern,
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
56 }
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
57
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
58 # this is for a free (non-bracketed) interwiki link - to avoid false positives,
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
59 # we are rather restrictive here (same as in moin 1.5: require that the
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
60 # interwiki_wiki name starts with an uppercase letter A-Z. Later, the code
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
61 # also checks whether the wiki name is in the interwiki map (if not, it renders
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
62 # normal text, no link):
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
63 interwiki_rule = ur'''
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
64 (?:^|(?<=\W)) # require either beginning of line or some non-alphanum char (whitespace, punctuation) to the left
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
65 (?P<interwiki_wiki>[A-Z][a-zA-Z]+) # interwiki wiki name
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
66 \:
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
67 (?P<interwiki_page> # interwiki page name
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
68 (?=[^ ]*[%(u)s%(l)s0..9][^ ]*\ ) # make sure there is something non-blank with at least one alphanum letter following
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
69 [^\s%(punct)s]+ # we take all until we hit some blank or punctuation char ...
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
70 )
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
71 ''' % {
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
72 'u': config.chars_upper,
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
73 'l': config.chars_lower,
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
74 'punct': punct_pattern,
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
75 }
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
76
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
77 word_rule = ur'''
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
78 (?:
2744
e931f45fec3a wiki parser: support multiple parent prefixes, require no / directly before or after matched wikiwords
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2735
diff changeset
79 (?<![%(u)s%(l)s/]) # require anything not upper/lower/slash before
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
80 |
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
81 ^ # ... or beginning of line
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
82 )
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
83 (?P<word_bang>\!)? # configurable: avoid getting CamelCase rendered as link
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
84 (?P<word_name>
2744
e931f45fec3a wiki parser: support multiple parent prefixes, require no / directly before or after matched wikiwords
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2735
diff changeset
85 (?:
2778
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
86 (%(parent)s)* # there might be either ../ parent prefix(es)
2744
e931f45fec3a wiki parser: support multiple parent prefixes, require no / directly before or after matched wikiwords
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2735
diff changeset
87 |
e931f45fec3a wiki parser: support multiple parent prefixes, require no / directly before or after matched wikiwords
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2735
diff changeset
88 ((?<!%(child)s)%(child)s)? # or maybe a single / child prefix (but not if we already had it before)
e931f45fec3a wiki parser: support multiple parent prefixes, require no / directly before or after matched wikiwords
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2735
diff changeset
89 )
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
90 (
2744
e931f45fec3a wiki parser: support multiple parent prefixes, require no / directly before or after matched wikiwords
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2735
diff changeset
91 ((?<!%(child)s)%(child)s)? # there might be / child prefix (but not if we already had it before)
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
92 (?:[%(u)s][%(l)s]+){2,} # at least 2 upper>lower transitions make CamelCase
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
93 )+ # we can have MainPage/SubPage/SubSubPage ...
2778
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
94 (?:
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
95 \# # anchor separator TODO check if this does not make trouble at places where word_rule is used
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
96 (?P<word_anchor>\S+) # some anchor name
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
97 )?
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
98 )
2771
1134a5cc12c2 gui converter fixes for new markup, fix/extend tests, remove unused code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2762
diff changeset
99 (?:
1134a5cc12c2 gui converter fixes for new markup, fix/extend tests, remove unused code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2762
diff changeset
100 (?![%(u)s%(l)s/]) # require anything not upper/lower/slash following
1134a5cc12c2 gui converter fixes for new markup, fix/extend tests, remove unused code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2762
diff changeset
101 |
1134a5cc12c2 gui converter fixes for new markup, fix/extend tests, remove unused code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2762
diff changeset
102 $ # ... or end of line
1134a5cc12c2 gui converter fixes for new markup, fix/extend tests, remove unused code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2762
diff changeset
103 )
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
104 ''' % {
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
105 'u': config.chars_upper,
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
106 'l': config.chars_lower,
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
107 'child': re.escape(CHILD_PREFIX),
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
108 'parent': re.escape(PARENT_PREFIX),
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
109 }
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
110
2723
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
111 # link targets:
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
112 extern_rule = r'(?P<extern_addr>(?P<extern_scheme>%s)\:.*)' % url_scheme
2722
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
113 attach_rule = r'(?P<attach_scheme>attachment|drawing)\:(?P<attach_addr>.*)'
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
114 page_rule = r'(?P<page_name>.*)'
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
115
2723
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
116 link_target_rules = r'|'.join([
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
117 extern_rule,
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
118 attach_rule,
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
119 page_rule,
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
120 ])
2723
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
121 link_target_re = re.compile(link_target_rules, re.VERBOSE|re.UNICODE)
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
122
2809
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
123 link_rule = r"""
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
124 (?P<link>
2925
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
125 \[\[ # link target
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
126 \s* # strip space
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
127 (?P<link_target>[^|]+?)
2925
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
128 \s* # strip space
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
129 (
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
130 \| # link description
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
131 \s* # strip space
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
132 (?P<link_desc>
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
133 (?: # 1. we have either a transclusion here (usually a image)
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
134 \{\{
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
135 \s*[^|]+?\s* # usually image target (strip space)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
136 (\|\s*[^|]*?\s* # usually image alt text (optional, strip space)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
137 (\|\s*[^|]*?\s* # transclusion parameters (usually key="value" format, optional, strip space)
2925
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
138 )?
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
139 )?
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
140 \}\}
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
141 )
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
142 |
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
143 (?: # 2. or we have simple text here.
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
144 [^|]+?
2925
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
145 )
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
146 )?
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
147 \s* # strip space
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
148 (
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
149 \| # link parameters
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
150 \s* # strip space
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
151 (?P<link_params>[^|]+?)?
2925
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
152 \s* # strip space
2811
46dba22d0fdf wiki parser: introduce link and transclusion params, strip spaces with the regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2809
diff changeset
153 )?
46dba22d0fdf wiki parser: introduce link and transclusion params, strip spaces with the regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2809
diff changeset
154 )?
2809
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
155 \]\]
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
156 )
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
157 """
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
158
2723
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
159 transclude_rule = r"""
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
160 (?P<transclude>
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
161 \{\{
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
162 \s*(?P<transclude_target>[^|]+?)\s* # usually image target (strip space)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
163 (\|\s*(?P<transclude_desc>[^|]+?)?\s* # usually image alt text (optional, strip space)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
164 (\|\s*(?P<transclude_params>[^|]+?)?\s* # transclusion parameters (usually key="value" format, optional, strip space)
2811
46dba22d0fdf wiki parser: introduce link and transclusion params, strip spaces with the regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2809
diff changeset
165 )?
46dba22d0fdf wiki parser: introduce link and transclusion params, strip spaces with the regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2809
diff changeset
166 )?
2723
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
167 \}\}
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
168 )
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
169 """
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
170 text_rule = r"""
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
171 (?P<simple_text>
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
172 [^|]+ # some text (not empty, does not contain separator)
2723
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
173 )
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
174 """
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
175 # link descriptions:
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
176 link_desc_rules = r'|'.join([
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
177 transclude_rule,
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
178 text_rule,
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
179 ])
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
180 link_desc_re = re.compile(link_desc_rules, re.VERBOSE|re.UNICODE)
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
181
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
182 # transclude descriptions:
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
183 transclude_desc_rules = r'|'.join([
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
184 text_rule,
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
185 ])
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
186 transclude_desc_re = re.compile(transclude_desc_rules, re.VERBOSE|re.UNICODE)
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
187
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
188 # lists:
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
189 ol_rule = ur"""
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
190 ^\s+ # indentation
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
191 (?:[0-9]+|[aAiI])\. # arabic, alpha, roman counting
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
192 (?:\#\d+)? # optional start number
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
193 \s # require one blank afterwards
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
194 """
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
195 ol_re = re.compile(ol_rule, re.VERBOSE|re.UNICODE)
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
196
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
197 dl_rule = ur"""
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
198 ^\s+ # indentation
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
199 .*?:: # definition term::
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
200 \s # require on blank afterwards
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
201 """
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
202 dl_re = re.compile(dl_rule, re.VERBOSE|re.UNICODE)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
203
2779
c9dd12befda7 wiki parser: match everything looking like a macro and either execute it (macro imports ok) or render the macro markup as text (macro import fails, error msg is in title). This makes scan_rules independent of wiki, so we can move all re.compile time to Parser class (doing it only once on module import time).
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
204 # others
c9dd12befda7 wiki parser: match everything looking like a macro and either execute it (macro imports ok) or render the macro markup as text (macro import fails, error msg is in title). This makes scan_rules independent of wiki, so we can move all re.compile time to Parser class (doing it only once on module import time).
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
205 indent_re = re.compile(ur"^\s*", re.UNICODE)
c9dd12befda7 wiki parser: match everything looking like a macro and either execute it (macro imports ok) or render the macro markup as text (macro import fails, error msg is in title). This makes scan_rules independent of wiki, so we can move all re.compile time to Parser class (doing it only once on module import time).
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
206 eol_re = re.compile(r'\r?\n', re.UNICODE)
c9dd12befda7 wiki parser: match everything looking like a macro and either execute it (macro imports ok) or render the macro markup as text (macro import fails, error msg is in title). This makes scan_rules independent of wiki, so we can move all re.compile time to Parser class (doing it only once on module import time).
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
207
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
208 # this is used inside parser/pre sections (we just want to know when it's over):
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
209 parser_unique = u''
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
210 parser_scan_rule = ur"""
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
211 (?P<parser_end>
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
212 %s\}\}\} # in parser/pre, we only look for the end of the parser/pre
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
213 )
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
214 """
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
215
1402
c65bff91b9e6 use special scanning rule when in pre sections
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1401
diff changeset
216
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
217 # the big, fat, less ugly one ;)
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
218 # please be very careful: blanks and # must be escaped with \ !
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
219 scan_rules = ur"""
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
220 (?P<emph_ibb>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
221 '''''(?=[^']+''') # italic on, bold on, ..., bold off
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
222 )|(?P<emph_ibi>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
223 '''''(?=[^']+'') # italic on, bold on, ..., italic off
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
224 )|(?P<emph_ib_or_bi>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
225 '{5}(?=[^']) # italic and bold or bold and italic
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
226 )|(?P<emph>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
227 '{2,3} # italic or bold
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
228 )|(?P<u>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
229 __ # underline
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
230 )|(?P<small>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
231 (
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
232 (?P<small_on>\~-\ ?) # small on (we eat a trailing blank if it is there)
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
233 |
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
234 (?P<small_off>-\~) # small off
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
235 )
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
236 )|(?P<big>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
237 (
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
238 (?P<big_on>\~\+\ ?) # big on (eat trailing blank)
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
239 |
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
240 (?P<big_off>\+\~) # big off
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
241 )
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
242 )|(?P<strike>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
243 (
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
244 (?P<strike_on>--\() # strike-through on
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
245 |
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
246 (?P<strike_off>\)--) # strike-through off
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
247 )
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
248 )|(?P<remark>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
249 (
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
250 (^|(?<=\s)) # we require either beginning of line or some whitespace before a remark begin
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
251 (?P<remark_on>/\*\s) # inline remark on (require and eat whitespace after it)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
252 )
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
253 |
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
254 (
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
255 (?P<remark_off>\s\*/) # off (require and eat whitespace before it)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
256 (?=\s) # we require some whitespace after a remark end
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
257 )
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
258 )|(?P<sup>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
259 \^ # superscript on
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
260 (?P<sup_text>.*?) # capture the text
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
261 \^ # off
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
262 )|(?P<sub>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
263 ,, # subscript on
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
264 (?P<sub_text>[^,]{1,40}) # capture 1..40 chars of text
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
265 ,, # off
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
266 )|(?P<tt>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
267 \{\{\{ # teletype on
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
268 (?P<tt_text>.*?) # capture the text
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
269 \}\}\} # off
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
270 )|(?P<tt_bt>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
271 ` # teletype (using a backtick) on
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
272 (?P<tt_bt_text>.*?) # capture the text
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
273 ` # off
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
274 )|(?P<interwiki>
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
275 %(interwiki_rule)s # OtherWiki:PageName
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
276 )|(?P<word> # must come AFTER interwiki rule!
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
277 %(word_rule)s # CamelCase wiki words
2723
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
278 )|
2809
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
279 %(link_rule)s
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
280 |
2723
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
281 %(transclude_rule)s
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
282 |(?P<url>
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
283 %(url_rule)s
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
284 )|(?P<email>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
285 [-\w._+]+ # name
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
286 \@ # at
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
287 [\w-]+(\.[\w-]+)+ # server/domain
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
288 )|(?P<smiley>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
289 (^|(?<=\s)) # we require either beginning of line or some space before a smiley
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
290 (%(smiley)s) # one of the smileys
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
291 (?=\s) # we require some space after the smiley
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
292 )|(?P<macro>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
293 <<
2779
c9dd12befda7 wiki parser: match everything looking like a macro and either execute it (macro imports ok) or render the macro markup as text (macro import fails, error msg is in title). This makes scan_rules independent of wiki, so we can move all re.compile time to Parser class (doing it only once on module import time).
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
294 (?P<macro_name>\w+) # name of the macro
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
295 (?:\((?P<macro_args>.*?)\))? # optionally macro arguments
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
296 >>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
297 )|(?P<heading>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
298 ^(?P<hmarker>=+)\s+ # some === at beginning of line, eat trailing blanks
2811
46dba22d0fdf wiki parser: introduce link and transclusion params, strip spaces with the regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2809
diff changeset
299 (?P<heading_text>.*?) # capture heading text
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
300 \s+(?P=hmarker)\s$ # some === at end of line (matching amount as we have seen), eat blanks
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
301 )|(?P<parser>
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
302 \{\{\{ # parser on
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
303 (?P<parser_unique>(\{*|\w*)) # either some more {{{{ or some chars to solve the nesting problem
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
304 (?P<parser_line>
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
305 (
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
306 \#! # hash bang
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
307 (?P<parser_name>\w*) # we have a parser name (can be empty) directly following the {{{
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
308 (
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
309 \s+ # some space ...
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
310 (?P<parser_args>.+?) # followed by parser args
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
311 )? # parser args are optional
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
312 \s* # followed by whitespace (eat it) until EOL
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
313 )
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
314 |
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
315 (?P<parser_nothing>\s*) # no parser name, only whitespace up to EOL (eat it)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
316 )$
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
317 # "parser off" detection is done with parser_scan_rule!
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
318 )|(?P<comment>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
319 ^\#\#.*$ # src code comment, rest of line
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
320 )|(?P<ol>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
321 %(ol_rule)s # ordered list
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
322 )|(?P<dl>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
323 %(dl_rule)s # definition list
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
324 )|(?P<li>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
325 ^\s+\*\s* # unordered list
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
326 )|(?P<li_none>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
327 ^\s+\.\s* # unordered list, no bullets
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
328 )|(?P<indent>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
329 ^\s+ # indented by some spaces
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
330 )|(?P<tableZ>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
331 \|\|\ $ # the right end of a table row
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
332 )|(?P<table>
2925
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
333 (?:\|\|)+(?:<(?!<)[^>]*?>)?(?!\|?\s$) # a table
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
334 )|(?P<rule>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
335 -{4,} # hor. rule, min. 4 -
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
336 )|(?P<entity>
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
337 &(
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
338 ([a-zA-Z]+) # symbolic entity, like &uuml;
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
339 |
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
340 (\#(\d{1,5}|x[0-9a-fA-F]+)) # numeric entities, like &#42; or &#x42;
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
341 );
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
342 )|(?P<sgml_entity> # must come AFTER entity rule!
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
343 [<>&] # needs special treatment for html/xml
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
344 )""" % {
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
345 'url_scheme': url_scheme,
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
346 'url_rule': url_rule,
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
347 'punct': punct_pattern,
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
348 'ol_rule': ol_rule,
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
349 'dl_rule': dl_rule,
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
350 'interwiki_rule': interwiki_rule,
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
351 'word_rule': word_rule,
2809
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
352 'link_rule': link_rule,
2723
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
353 'transclude_rule': transclude_rule,
2757
e3b0355215a2 wiki parser: fix interwiki regex wrong matches, commented that regex part
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2755
diff changeset
354 'u': config.chars_upper,
e3b0355215a2 wiki parser: fix interwiki regex wrong matches, commented that regex part
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2755
diff changeset
355 'l': config.chars_lower,
1866
0194beaf511e reduce reduce, filter and map usage
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1812
diff changeset
356 'smiley': u'|'.join([re.escape(s) for s in config.smileys])}
2779
c9dd12befda7 wiki parser: match everything looking like a macro and either execute it (macro imports ok) or render the macro markup as text (macro import fails, error msg is in title). This makes scan_rules independent of wiki, so we can move all re.compile time to Parser class (doing it only once on module import time).
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
357 scan_re = re.compile(scan_rules, re.UNICODE|re.VERBOSE)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
358
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2263
diff changeset
359 # Don't start p before these
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
360 no_new_p_before = ("heading rule table tableZ tr td "
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
361 "ul ol dl dt dd li li_none indent "
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
362 "macro parser")
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
363 no_new_p_before = no_new_p_before.split()
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
364 no_new_p_before = dict(zip(no_new_p_before, [1] * len(no_new_p_before)))
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
365
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
366 def __init__(self, raw, request, **kw):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
367 self.raw = raw
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
368 self.request = request
1671
fa334986a93d fix missing parser.form attribute
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1667
diff changeset
369 self.form = request.form # Macro object uses this
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
370 self._ = request.getText
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
371 self.cfg = request.cfg
42
f1e33f7ad2e6 don't emit line anchors when processing i18n strings
Thomas Waldmann <tw@waldmann-edv.de>
parents: 36
diff changeset
372 self.line_anchors = kw.get('line_anchors', True)
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
373 self.start_line = kw.get('start_line', 0)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
374 self.macro = None
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
375
1752
6f8360e1a4bb wrapping div support for wiki parser, toggling display of comment divs, show_comments user prefs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1719
diff changeset
376 # currently, there is only a single, optional argument to this parser and
6f8360e1a4bb wrapping div support for wiki parser, toggling display of comment divs, show_comments user prefs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1719
diff changeset
377 # (when given), it is used as class(es) for a div wrapping the formatter output
6f8360e1a4bb wrapping div support for wiki parser, toggling display of comment divs, show_comments user prefs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1719
diff changeset
378 # either use a single class like "comment" or multiple like "comment/red/dotted"
6f8360e1a4bb wrapping div support for wiki parser, toggling display of comment divs, show_comments user prefs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1719
diff changeset
379 self.wrapping_div_class = kw.get('format_args', '').strip().replace('/', ' ')
6f8360e1a4bb wrapping div support for wiki parser, toggling display of comment divs, show_comments user prefs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1719
diff changeset
380
1667
e3c56a97e30c wiki parser: removed unused imports, cosmetic changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1572
diff changeset
381 self.is_em = 0 # must be int
e3c56a97e30c wiki parser: removed unused imports, cosmetic changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1572
diff changeset
382 self.is_b = 0 # must be int
e3c56a97e30c wiki parser: removed unused imports, cosmetic changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1572
diff changeset
383 self.is_u = False
e3c56a97e30c wiki parser: removed unused imports, cosmetic changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1572
diff changeset
384 self.is_strike = False
e3c56a97e30c wiki parser: removed unused imports, cosmetic changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1572
diff changeset
385 self.is_big = False
e3c56a97e30c wiki parser: removed unused imports, cosmetic changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1572
diff changeset
386 self.is_small = False
1786
2c9853dc11f8 new wiki markup for /* inline comments */, support toggling visibility of them
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1752
diff changeset
387 self.is_remark = False
1667
e3c56a97e30c wiki parser: removed unused imports, cosmetic changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1572
diff changeset
388
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
389 self.lineno = 0
553
42c37dcdc314 fixed: no p within lists
Thomas Waldmann <tw@waldmann-edv.de>
parents: 547
diff changeset
390 self.in_list = 0 # between <ul/ol/dl> and </ul/ol/dl>
42c37dcdc314 fixed: no p within lists
Thomas Waldmann <tw@waldmann-edv.de>
parents: 547
diff changeset
391 self.in_li = 0 # between <li> and </li>
42c37dcdc314 fixed: no p within lists
Thomas Waldmann <tw@waldmann-edv.de>
parents: 547
diff changeset
392 self.in_dd = 0 # between <dd> and </dd>
1400
a95414cd1280 wiki parser: replace numerical in_pre state values by strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1360
diff changeset
393
a95414cd1280 wiki parser: replace numerical in_pre state values by strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1360
diff changeset
394 # states of the parser concerning being inside/outside of some "pre" section:
a95414cd1280 wiki parser: replace numerical in_pre state values by strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1360
diff changeset
395 # None == we are not in any kind of pre section (was: 0)
a95414cd1280 wiki parser: replace numerical in_pre state values by strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1360
diff changeset
396 # 'search_parser' == we didn't get a parser yet, still searching for it (was: 1)
a95414cd1280 wiki parser: replace numerical in_pre state values by strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1360
diff changeset
397 # 'found_parser' == we found a valid parser (was: 2)
a95414cd1280 wiki parser: replace numerical in_pre state values by strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1360
diff changeset
398 self.in_pre = None
a95414cd1280 wiki parser: replace numerical in_pre state values by strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1360
diff changeset
399
2023
dd5240822911 text_moin_wiki: bug fix of MoinMoinBugs/IndentingAndSpaceBetweenTwoMacroCallsGivesLineBreak
Reimar Bauer <rb.proj@googlemail.com>
parents: 2016
diff changeset
400 self.no_862 = False
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
401 self.in_table = 0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
402 self.inhibit_p = 0 # if set, do not auto-create a <p>aragraph
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
403
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
404 # holds the nesting level (in chars) of open lists
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
405 self.list_indents = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
406 self.list_types = []
1356
0120ccfbaaa1 wiki parser: whitespace and comments changes only
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1355
diff changeset
407
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
408 def _close_item(self, result):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
409 #result.append("<!-- close item begin -->\n")
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
410 if self.in_table:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
411 result.append(self.formatter.table(0))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
412 self.in_table = 0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
413 if self.in_li:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
414 self.in_li = 0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
415 if self.formatter.in_p:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
416 result.append(self.formatter.paragraph(0))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
417 result.append(self.formatter.listitem(0))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
418 if self.in_dd:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
419 self.in_dd = 0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
420 if self.formatter.in_p:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
421 result.append(self.formatter.paragraph(0))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
422 result.append(self.formatter.definition_desc(0))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
423 #result.append("<!-- close item end -->\n")
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
424
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
425 def _u_repl(self, word, groups):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
426 """Handle underline."""
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
427 self.is_u = not self.is_u
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
428 return self.formatter.underline(self.is_u)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
429
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
430 def _remark_repl(self, word, groups):
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
431 """Handle remarks."""
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
432 on = groups.get('remark_on')
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
433 if on and self.is_remark:
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
434 return self.formatter.text(word)
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
435 off = groups.get('remark_off')
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
436 if off and not self.is_remark:
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
437 return self.formatter.text(word)
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
438 self.is_remark = not self.is_remark
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
439 return self.formatter.span(self.is_remark, css_class='comment')
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
440 _remark_on_repl = _remark_repl
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
441 _remark_off_repl = _remark_repl
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
442
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
443 def _strike_repl(self, word, groups):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
444 """Handle strikethrough."""
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
445 on = groups.get('strike_on')
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
446 if on and self.is_strike:
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
447 return self.formatter.text(word)
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
448 off = groups.get('strike_off')
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
449 if off and not self.is_strike:
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
450 return self.formatter.text(word)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
451 self.is_strike = not self.is_strike
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
452 return self.formatter.strike(self.is_strike)
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
453 _strike_on_repl = _strike_repl
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
454 _strike_off_repl = _strike_repl
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
455
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
456 def _small_repl(self, word, groups):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
457 """Handle small."""
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
458 on = groups.get('small_on')
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
459 if on and self.is_small:
279
54b01975e285 Fixed a few direct (non-formatter) returns in wiki.py. Broken for years ;-)
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 273
diff changeset
460 return self.formatter.text(word)
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
461 off = groups.get('small_off')
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
462 if off and not self.is_small:
279
54b01975e285 Fixed a few direct (non-formatter) returns in wiki.py. Broken for years ;-)
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 273
diff changeset
463 return self.formatter.text(word)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
464 self.is_small = not self.is_small
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
465 return self.formatter.small(self.is_small)
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
466 _small_on_repl = _small_repl
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
467 _small_off_repl = _small_repl
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
468
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
469 def _big_repl(self, word, groups):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
470 """Handle big."""
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
471 on = groups.get('big_on')
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
472 if on and self.is_big:
279
54b01975e285 Fixed a few direct (non-formatter) returns in wiki.py. Broken for years ;-)
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 273
diff changeset
473 return self.formatter.text(word)
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
474 off = groups.get('big_off')
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
475 if off and not self.is_big:
279
54b01975e285 Fixed a few direct (non-formatter) returns in wiki.py. Broken for years ;-)
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 273
diff changeset
476 return self.formatter.text(word)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
477 self.is_big = not self.is_big
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
478 return self.formatter.big(self.is_big)
2723
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
479 _big_on_repl = _big_repl
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
480 _big_off_repl = _big_repl
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
481
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
482 def _emph_repl(self, word, groups):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
483 """Handle emphasis, i.e. '' and '''."""
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
484 if len(word) == 3:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
485 self.is_b = not self.is_b
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
486 if self.is_em and self.is_b:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
487 self.is_b = 2
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
488 return self.formatter.strong(self.is_b)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
489 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
490 self.is_em = not self.is_em
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
491 if self.is_em and self.is_b:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
492 self.is_em = 2
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
493 return self.formatter.emphasis(self.is_em)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
494
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
495 def _emph_ibb_repl(self, word, groups):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
496 """Handle mixed emphasis, i.e. ''''' followed by '''."""
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
497 self.is_b = not self.is_b
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
498 self.is_em = not self.is_em
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
499 if self.is_em and self.is_b:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
500 self.is_b = 2
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
501 return self.formatter.emphasis(self.is_em) + self.formatter.strong(self.is_b)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
502
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
503 def _emph_ibi_repl(self, word, groups):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
504 """Handle mixed emphasis, i.e. ''''' followed by ''."""
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
505 self.is_b = not self.is_b
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
506 self.is_em = not self.is_em
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
507 if self.is_em and self.is_b:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
508 self.is_em = 2
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
509 return self.formatter.strong(self.is_b) + self.formatter.emphasis(self.is_em)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
510
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
511 def _emph_ib_or_bi_repl(self, word, groups):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
512 """Handle mixed emphasis, exactly five '''''."""
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
513 b_before_em = self.is_b > self.is_em > 0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
514 self.is_b = not self.is_b
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
515 self.is_em = not self.is_em
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
516 if b_before_em:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
517 return self.formatter.strong(self.is_b) + self.formatter.emphasis(self.is_em)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
518 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
519 return self.formatter.emphasis(self.is_em) + self.formatter.strong(self.is_b)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
520
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
521 def _sup_repl(self, word, groups):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
522 """Handle superscript."""
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
523 text = groups.get('sup_text', '')
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
524 return (self.formatter.sup(1) +
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
525 self.formatter.text(text) +
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
526 self.formatter.sup(0))
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
527 _sup_text_repl = _sup_repl
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
528
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
529 def _sub_repl(self, word, groups):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
530 """Handle subscript."""
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
531 text = groups.get('sub_text', '')
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
532 return (self.formatter.sub(1) +
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
533 self.formatter.text(text) +
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
534 self.formatter.sub(0))
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
535 _sub_text_repl = _sub_repl
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
536
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
537 def _tt_repl(self, word, groups):
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
538 """Handle inline code."""
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
539 tt_text = groups.get('tt_text', '')
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
540 return (self.formatter.code(1) +
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
541 self.formatter.text(tt_text) +
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
542 self.formatter.code(0))
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
543 _tt_text_repl = _tt_repl
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
544
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
545 def _tt_bt_repl(self, word, groups):
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
546 """Handle backticked inline code."""
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
547 tt_bt_text = groups.get('tt_bt_text', '')
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
548 return (self.formatter.code(1, css="backtick") +
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
549 self.formatter.text(tt_bt_text) +
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
550 self.formatter.code(0))
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
551 _tt_bt_text_repl = _tt_bt_repl
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
552
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
553 def _rule_repl(self, word, groups):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
554 """Handle sequences of dashes."""
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
555 result = self._undent() + self._closeP()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
556 if len(word) <= 4:
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
557 result += self.formatter.rule()
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
558 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
559 # Create variable rule size 1 - 6. Actual size defined in css.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
560 size = min(len(word), 10) - 4
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
561 result += self.formatter.rule(size)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
562 return result
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
563
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
564 def _interwiki_repl(self, word, groups):
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
565 """Handle InterWiki links."""
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
566 wiki = groups.get('interwiki_wiki')
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
567 page = groups.get('interwiki_page')
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
568
2728
59b3d8b8971f remove (un)quoteName, new functions split_interwiki() and resolve_interwiki(), cleanup interwiki mess, fix some link markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2725
diff changeset
569 wikitag_bad = wikiutil.resolve_interwiki(self.request, wiki, page)[3]
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
570 if wikitag_bad:
2730
a907a61c33b3 * The 1.5.8 to 1.6.0 converter now uses the 1.5.8 wiki parser, for better
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2728
diff changeset
571 text = groups.get('interwiki')
a907a61c33b3 * The 1.5.8 to 1.6.0 converter now uses the 1.5.8 wiki parser, for better
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2728
diff changeset
572 return self.formatter.text(text)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
573 else:
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
574 return (self.formatter.interwikilink(1, wiki, page) +
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
575 self.formatter.text(page) +
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
576 self.formatter.interwikilink(0, wiki, page))
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
577 _interwiki_wiki_repl = _interwiki_repl
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
578 _interwiki_page_repl = _interwiki_repl
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
579
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
580 def _word_repl(self, word, groups):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
581 """Handle WikiNames."""
2778
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
582 bang = ''
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
583 bang_present = groups.get('word_bang')
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
584 if bang_present:
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
585 if self.cfg.bang_meta:
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
586 # handle !NotWikiNames
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
587 return self.formatter.nowikiword(word)
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
588 else:
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
589 bang = self.formatter.text('!')
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
590 name = groups.get('word_name')
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
591 current_page = self.formatter.page.page_name
2778
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
592 abs_name = wikiutil.AbsPageName(current_page, name)
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
593 # if a simple, self-referencing link, emit it as plain text
2778
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
594 if abs_name == current_page:
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
595 return self.formatter.text(word)
828
902c34d95085 quoting for attachment filenames, wikiutil.load_wikimap, split_wiki can parse quoting, join_wiki does url_quote
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
596 else:
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
597 # handle anchors
2778
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
598 try:
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
599 abs_name, anchor = rsplit(abs_name, "#", 1)
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
600 except ValueError:
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
601 anchor = ""
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
602 return (bang +
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
603 self.formatter.pagelink(1, abs_name, anchor=anchor) +
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
604 self.formatter.text(word) +
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
605 self.formatter.pagelink(0, abs_name))
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
606 _word_bang_repl = _word_repl
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
607 _word_name_repl = _word_repl
2778
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
608 _word_anchor_repl = _word_repl
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
609
2721
2e5634c64e6d wiki parser: some internal renames, fix https images
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2720
diff changeset
610 def _url_repl(self, word, groups):
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
611 """Handle literal URLs."""
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
612 scheme = groups.get('url_scheme', 'http')
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
613 target = groups.get('url_target', '')
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
614 return (self.formatter.url(1, target, css=scheme) +
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
615 self.formatter.text(target) +
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
616 self.formatter.url(0))
2721
2e5634c64e6d wiki parser: some internal renames, fix https images
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2720
diff changeset
617 _url_target_repl = _url_repl
2e5634c64e6d wiki parser: some internal renames, fix https images
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2720
diff changeset
618 _url_scheme_repl = _url_repl
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
619
2809
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
620 def _transclude_description(self, desc, default_text=''):
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
621 """ parse a string <desc> valid as transclude description (text, ...)
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
622 and return "formatted" content (we do not pass it through the text
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
623 formatter, but only through wikiutil.escape as we only use it as
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
624 alt/title text).
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
625
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
626 @param desc: the transclude description to parse
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
627 @param default_text: use this text if parsing desc returns nothing.
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
628 """
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
629 m = self.transclude_desc_re.match(desc)
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
630 if m:
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
631 if m.group('simple_text'):
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
632 desc = m.group('simple_text')
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
633 else:
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
634 desc = default_text
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
635 desc = wikiutil.escape(desc)
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
636 return desc
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
637
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
638 def _get_params(self, params, tag_attrs=None, acceptable_attrs=None, query_args=None):
2812
6ac9e14a0241 wiki parser: link/transclusion parameter parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2811
diff changeset
639 """ parse the parameters of link/transclusion markup,
6ac9e14a0241 wiki parser: link/transclusion parameter parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2811
diff changeset
640 defaults can be a dict with some default key/values
6ac9e14a0241 wiki parser: link/transclusion parameter parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2811
diff changeset
641 that will be in the result as given, unless overriden
6ac9e14a0241 wiki parser: link/transclusion parameter parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2811
diff changeset
642 by the params.
6ac9e14a0241 wiki parser: link/transclusion parameter parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2811
diff changeset
643 """
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
644 if tag_attrs is None:
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
645 tag_attrs = {}
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
646 if query_args is None:
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
647 query_args = {}
2812
6ac9e14a0241 wiki parser: link/transclusion parameter parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2811
diff changeset
648 if params:
6ac9e14a0241 wiki parser: link/transclusion parameter parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2811
diff changeset
649 fixed, kw, trailing = wikiutil.parse_quoted_separated(params)
6ac9e14a0241 wiki parser: link/transclusion parameter parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2811
diff changeset
650 # we ignore fixed and trailing args and only use kw args:
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
651 if acceptable_attrs is None:
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
652 acceptable_attrs = []
2812
6ac9e14a0241 wiki parser: link/transclusion parameter parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2811
diff changeset
653 for key, val in kw.items():
6ac9e14a0241 wiki parser: link/transclusion parameter parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2811
diff changeset
654 key = str(key) # we can't use unicode as key
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
655 if key in acceptable_attrs:
2812
6ac9e14a0241 wiki parser: link/transclusion parameter parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2811
diff changeset
656 key = wikiutil.escape(key)
6ac9e14a0241 wiki parser: link/transclusion parameter parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2811
diff changeset
657 val = unicode(val) # but for the value
6ac9e14a0241 wiki parser: link/transclusion parameter parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2811
diff changeset
658 val = wikiutil.escape(val)
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
659 tag_attrs[key] = val
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
660 elif key.startswith('&'):
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
661 key = key[1:]
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
662 val = unicode(val)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
663 query_args[key] = val
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
664 return tag_attrs, query_args
2812
6ac9e14a0241 wiki parser: link/transclusion parameter parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2811
diff changeset
665
2721
2e5634c64e6d wiki parser: some internal renames, fix https images
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2720
diff changeset
666 def _transclude_repl(self, word, groups):
2e5634c64e6d wiki parser: some internal renames, fix https images
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2720
diff changeset
667 """Handles transcluding content, usually embedding images."""
2811
46dba22d0fdf wiki parser: introduce link and transclusion params, strip spaces with the regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2809
diff changeset
668 target = groups.get('transclude_target', '')
2812
6ac9e14a0241 wiki parser: link/transclusion parameter parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2811
diff changeset
669 target = wikiutil.url_unquote(target, want_unicode=True)
2811
46dba22d0fdf wiki parser: introduce link and transclusion params, strip spaces with the regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2809
diff changeset
670 desc = groups.get('transclude_desc', '') or ''
2812
6ac9e14a0241 wiki parser: link/transclusion parameter parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2811
diff changeset
671 params = groups.get('transclude_params', u'') or u''
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
672 acceptable_attrs_img = ['class', 'title', 'longdesc', 'width', 'height', 'align', ] # no style because of JS
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
673 acceptable_attrs_object = ['class', 'title', 'width', 'height', # no style because of JS
2813
82a39e6078d7 wiki_parser: refined acceptable_keys
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2812
diff changeset
674 'type', 'standby', ] # we maybe need a hack for <PARAM> here
2723
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
675 m = self.link_target_re.match(target)
2722
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
676 if m:
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
677 if m.group('extern_addr'):
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
678 scheme = m.group('extern_scheme')
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
679 target = m.group('extern_addr')
2809
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
680 desc = self._transclude_description(desc, target)
2722
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
681 if scheme.startswith('http'): # can also be https
2723
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
682 # currently only supports ext. image inclusion
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
683 tag_attrs, query_args = self._get_params(params,
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
684 tag_attrs={'class': 'external_image',
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
685 'alt': desc,
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
686 'title': desc, },
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
687 acceptable_attrs=acceptable_attrs_img)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
688 return self.formatter.image(src=target, **tag_attrs)
2755
7c8e3ce74202 wiki parser: using <object> for client side page transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2746
diff changeset
689 # FF2 has a bug with target mimetype detection, it looks at the url path
7c8e3ce74202 wiki parser: using <object> for client side page transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2746
diff changeset
690 # and expects to find some "filename extension" there (like .png) and this
7c8e3ce74202 wiki parser: using <object> for client side page transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2746
diff changeset
691 # (not the response http headers) will set the default content-type of
7c8e3ce74202 wiki parser: using <object> for client side page transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2746
diff changeset
692 # the object. This will often work for staticly served files, but
7c8e3ce74202 wiki parser: using <object> for client side page transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2746
diff changeset
693 # fails for MoinMoin attachments (they don't have the filename.ext in the
7c8e3ce74202 wiki parser: using <object> for client side page transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2746
diff changeset
694 # path, but in the query string). FF3 seems to have this bug fixed, opera 9.2
7c8e3ce74202 wiki parser: using <object> for client side page transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2746
diff changeset
695 # also works.
7c8e3ce74202 wiki parser: using <object> for client side page transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2746
diff changeset
696 #return (self.formatter.transclusion(1, data=target) +
7c8e3ce74202 wiki parser: using <object> for client side page transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2746
diff changeset
697 # desc +
7c8e3ce74202 wiki parser: using <object> for client side page transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2746
diff changeset
698 # self.formatter.transclusion(0))
1356
0120ccfbaaa1 wiki parser: whitespace and comments changes only
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1355
diff changeset
699
2722
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
700 elif m.group('attach_scheme'):
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
701 scheme = m.group('attach_scheme')
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
702 url = wikiutil.url_unquote(m.group('attach_addr'), want_unicode=True)
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
703 if scheme == 'attachment':
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
704 mt = wikiutil.MimeType(filename=url)
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
705 if mt.major == 'text':
2809
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
706 desc = self._transclude_description(desc, url)
2723
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
707 return self.formatter.attachment_inlined(url, desc)
2722
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
708 elif mt.major == 'image':
2809
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
709 desc = self._transclude_description(desc, url)
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
710 tag_attrs, query_args = self._get_params(params,
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
711 tag_attrs={'alt': desc,
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
712 'title': desc, },
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
713 acceptable_attrs=acceptable_attrs_img)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
714 return self.formatter.attachment_image(url, **tag_attrs)
2722
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
715 else:
2755
7c8e3ce74202 wiki parser: using <object> for client side page transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2746
diff changeset
716 from MoinMoin.action import AttachFile
7c8e3ce74202 wiki parser: using <object> for client side page transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2746
diff changeset
717 pagename = self.formatter.page.page_name
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
718 if AttachFile.exists(self.request, pagename, url):
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
719 href = AttachFile.getAttachUrl(pagename, url, self.request, escaped=0)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
720 tag_attrs, query_args = self._get_params(params,
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
721 tag_attrs={'title': desc, },
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
722 acceptable_attrs=acceptable_attrs_object)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
723 return (self.formatter.transclusion(1, data=href, type=mt.spoil(), **tag_attrs) +
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
724 self._transclude_description(desc, url) +
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
725 self.formatter.transclusion(0))
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
726 else:
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
727 return (self.formatter.attachment_link(1, url) +
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
728 self._transclude_description(desc, url) +
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
729 self.formatter.attachment_link(0))
2755
7c8e3ce74202 wiki parser: using <object> for client side page transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2746
diff changeset
730
7c8e3ce74202 wiki parser: using <object> for client side page transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2746
diff changeset
731 #NOT USED CURRENTLY:
7c8e3ce74202 wiki parser: using <object> for client side page transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2746
diff changeset
732
2722
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
733 # use EmbedObject for other mimetypes
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
734 from MoinMoin.macro.EmbedObject import EmbedObject
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
735 from MoinMoin.action import AttachFile
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
736 if mt is not None:
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
737 # reuse class tmp from Despam to define macro
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
738 from MoinMoin.action.Despam import tmp
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
739 macro = tmp()
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
740 macro.request = self.request
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
741 macro.formatter = self.request.html_formatter
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
742 pagename = self.formatter.page.page_name
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
743 href = AttachFile.getAttachUrl(pagename, url, self.request, escaped=1)
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
744 return self.formatter.rawHTML(EmbedObject.embed(EmbedObject(macro, wikiutil.escape(url)), mt, href))
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
745 elif scheme == 'drawing':
2809
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
746 desc = self._transclude_description(desc, url)
2723
a3056075eaaa wiki parser: parse link/transclude descriptions, fixes. html formatter: title/alt fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2722
diff changeset
747 return self.formatter.attachment_drawing(url, desc)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
748
2755
7c8e3ce74202 wiki parser: using <object> for client side page transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2746
diff changeset
749 elif m.group('page_name'):
7c8e3ce74202 wiki parser: using <object> for client side page transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2746
diff changeset
750 # experimental client side transclusion
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
751 page_name_all = m.group('page_name')
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
752 if ':' in page_name_all:
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
753 wiki_name, page_name = page_name_all.split(':', 1)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
754 wikitag, wikiurl, wikitail, err = wikiutil.resolve_interwiki(self.request, wiki_name, page_name)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
755 else:
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
756 err = True
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
757 if err: # not a interwiki link / not in interwiki map
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
758 tag_attrs, query_args = self._get_params(params,
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
759 tag_attrs={'type': 'text/html',
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
760 'width': '100%', },
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
761 acceptable_attrs=acceptable_attrs_object)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
762 if 'action' not in query_args:
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
763 query_args['action'] = 'content'
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
764 url = Page(self.request, page_name_all).url(self.request, querystr=query_args, relative=False)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
765 return (self.formatter.transclusion(1, data=url, **tag_attrs) +
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
766 self._transclude_description(desc, page_name_all) +
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
767 self.formatter.transclusion(0))
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
768 #return u"Error: <<Include(%s,%s)>> emulation missing..." % (page_name, args)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
769 else: # looks like a valid interwiki link
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
770 url = wikiutil.join_wiki(wikiurl, wikitail)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
771 tag_attrs, query_args = self._get_params(params,
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
772 tag_attrs={'type': 'text/html',
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
773 'width': '100%', },
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
774 acceptable_attrs=acceptable_attrs_object)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
775 if 'action' not in query_args:
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
776 query_args['action'] = 'content' # XXX moin specific
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
777 url += '?%s' % wikiutil.makeQueryString(query_args)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
778 return (self.formatter.transclusion(1, data=url, **tag_attrs) +
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
779 self._transclude_description(desc, page_name) +
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
780 self.formatter.transclusion(0))
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
781 #return u"Error: <<RemoteInclude(%s:%s,%s)>> still missing." % (wiki_name, page_name, args)
2722
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
782
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
783 else:
2809
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
784 desc = self._transclude_description(desc, target)
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
785 return self.formatter.text('{{%s|%s|%s}}' % (target, desc, params))
2722
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
786 return word +'???'
2721
2e5634c64e6d wiki parser: some internal renames, fix https images
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2720
diff changeset
787 _transclude_target_repl = _transclude_repl
2809
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
788 _transclude_desc_repl = _transclude_repl
2811
46dba22d0fdf wiki parser: introduce link and transclusion params, strip spaces with the regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2809
diff changeset
789 _transclude_params_repl = _transclude_repl
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
790
2735
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
791 def _link_description(self, desc, target='', default_text=''):
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
792 """ parse a string <desc> valid as link description (text, transclusion, ...)
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
793 and return formatted content.
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
794
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
795 @param desc: the link description to parse
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
796 @param default_text: use this text (formatted as text) if parsing
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
797 desc returns nothing.
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
798 @param target: target of the link (as readable markup) - used for
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
799 transcluded image's description
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
800 """
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
801 m = self.link_desc_re.match(desc)
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
802 if m:
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
803 if m.group('simple_text'):
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
804 desc = m.group('simple_text')
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
805 desc = self.formatter.text(desc)
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
806 elif m.group('transclude'):
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
807 groupdict = m.groupdict()
2809
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
808 if groupdict.get('transclude_desc') is None:
2735
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
809 # if transcluded obj (image) has no description, use target for it
2809
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
810 groupdict['transclude_desc'] = target
2735
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
811 desc = m.group('transclude')
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
812 desc = self._transclude_repl(desc, groupdict)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
813 else:
2735
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
814 desc = default_text
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
815 if desc:
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
816 desc = self.formatter.text(desc)
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
817 return desc
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
818
2721
2e5634c64e6d wiki parser: some internal renames, fix https images
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2720
diff changeset
819 def _link_repl(self, word, groups):
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
820 """Handle [[target|text]] links."""
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
821 target = groups.get('link_target', '')
2811
46dba22d0fdf wiki parser: introduce link and transclusion params, strip spaces with the regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2809
diff changeset
822 desc = groups.get('link_desc', '') or ''
2812
6ac9e14a0241 wiki parser: link/transclusion parameter parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2811
diff changeset
823 params = groups.get('link_params', u'') or u''
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
824 acceptable_attrs = ['class', 'title', 'target', 'accesskey', ] # no style because of JS
2730
a907a61c33b3 * The 1.5.8 to 1.6.0 converter now uses the 1.5.8 wiki parser, for better
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2728
diff changeset
825 mt = self.link_target_re.match(target)
a907a61c33b3 * The 1.5.8 to 1.6.0 converter now uses the 1.5.8 wiki parser, for better
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2728
diff changeset
826 if mt:
a907a61c33b3 * The 1.5.8 to 1.6.0 converter now uses the 1.5.8 wiki parser, for better
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2728
diff changeset
827 if mt.group('page_name'):
2778
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
828 page_name_and_anchor = mt.group('page_name')
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
829 if ':' in page_name_and_anchor:
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
830 wiki_name, page_name = page_name_and_anchor.split(':', 1)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
831 wikitag, wikiurl, wikitail, err = wikiutil.resolve_interwiki(self.request, wiki_name, page_name)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
832 else:
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
833 err = True
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
834 if err: # not a interwiki link / not in interwiki map
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
835 # handle anchors
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
836 try:
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
837 page_name, anchor = rsplit(page_name_and_anchor, "#", 1)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
838 except ValueError:
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
839 page_name, anchor = page_name_and_anchor, ""
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
840 current_page = self.formatter.page.page_name
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
841 if not page_name:
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
842 page_name = current_page
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
843 # handle relative links
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
844 abs_page_name = wikiutil.AbsPageName(current_page, page_name)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
845 tag_attrs, query_args = self._get_params(params,
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
846 tag_attrs={},
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
847 acceptable_attrs=acceptable_attrs)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
848 return (self.formatter.pagelink(1, abs_page_name, anchor=anchor, querystr=query_args, **tag_attrs) +
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
849 self._link_description(desc, target, page_name_and_anchor) +
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
850 self.formatter.pagelink(0, abs_page_name))
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
851 else: # interwiki link
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
852 tag_attrs, query_args = self._get_params(params,
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
853 tag_attrs={},
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
854 acceptable_attrs=acceptable_attrs)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
855 return (self.formatter.interwikilink(1, wiki_name, page_name, querystr=query_args, **tag_attrs) +
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
856 self._link_description(desc, target, page_name) +
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
857 self.formatter.interwikilink(0, wiki_name, page_name))
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
858
2730
a907a61c33b3 * The 1.5.8 to 1.6.0 converter now uses the 1.5.8 wiki parser, for better
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2728
diff changeset
859 elif mt.group('extern_addr'):
a907a61c33b3 * The 1.5.8 to 1.6.0 converter now uses the 1.5.8 wiki parser, for better
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2728
diff changeset
860 scheme = mt.group('extern_scheme')
a907a61c33b3 * The 1.5.8 to 1.6.0 converter now uses the 1.5.8 wiki parser, for better
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2728
diff changeset
861 target = mt.group('extern_addr')
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
862 tag_attrs, query_args = self._get_params(params,
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
863 tag_attrs={'class': scheme, },
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
864 acceptable_attrs=acceptable_attrs)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
865 return (self.formatter.url(1, target, **tag_attrs) +
2735
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
866 self._link_description(desc, target, target) +
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
867 self.formatter.url(0))
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
868
2730
a907a61c33b3 * The 1.5.8 to 1.6.0 converter now uses the 1.5.8 wiki parser, for better
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2728
diff changeset
869 elif mt.group('attach_scheme'):
a907a61c33b3 * The 1.5.8 to 1.6.0 converter now uses the 1.5.8 wiki parser, for better
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2728
diff changeset
870 scheme = mt.group('attach_scheme')
a907a61c33b3 * The 1.5.8 to 1.6.0 converter now uses the 1.5.8 wiki parser, for better
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2728
diff changeset
871 url = wikiutil.url_unquote(mt.group('attach_addr'), want_unicode=True)
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
872 tag_attrs, query_args = self._get_params(params,
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
873 tag_attrs={'title': desc, },
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
874 acceptable_attrs=acceptable_attrs)
2722
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
875 if scheme == 'attachment':
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
876 return (self.formatter.attachment_link(1, url, querystr=query_args, **tag_attrs) +
2735
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
877 self._link_description(desc, target, url) +
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
878 self.formatter.attachment_link(0))
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
879 elif scheme == 'drawing':
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
880 return self.formatter.attachment_drawing(url, desc, alt=desc, **tag_attrs)
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
881 else:
2735
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
882 if desc:
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
883 desc = '|' + desc
83db1c30d391 do link description parsing/formatting at the right place (between link on and link off), fixed description text_rule (do not match empty string)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2733
diff changeset
884 return self.formatter.text('[[%s%s]]' % (target, desc))
2721
2e5634c64e6d wiki parser: some internal renames, fix https images
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2720
diff changeset
885 _link_target_repl = _link_repl
2809
39a9b649d5d0 wiki parser: make stuff more consistent, implement transclusion desc parsing similar to link desc parsing, clean up
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
886 _link_desc_repl = _link_repl
2811
46dba22d0fdf wiki parser: introduce link and transclusion params, strip spaces with the regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2809
diff changeset
887 _link_params_repl = _link_repl
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
888
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
889 def _email_repl(self, word, groups):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
890 """Handle email addresses (without a leading mailto:)."""
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
891 return (self.formatter.url(1, "mailto:%s" % word, css='mailto') +
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
892 self.formatter.text(word) +
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
893 self.formatter.url(0))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
894
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
895 def _sgml_entity_repl(self, word, groups):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
896 """Handle SGML entities."""
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
897 return self.formatter.text(word)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
898
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
899 def _entity_repl(self, word, groups):
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
900 """Handle numeric (decimal and hexadecimal) and symbolic SGML entities."""
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
901 return self.formatter.rawHTML(word)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
902
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
903 def _indent_repl(self, match, groups):
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
904 """Handle pure indentation (no - * 1. markup)."""
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
905 result = []
521
d3a173c26e1c fixed dl indenting, some cosmetic issues
Thomas Waldmann <tw@waldmann-edv.de>
parents: 517
diff changeset
906 if not (self.in_li or self.in_dd):
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
907 self._close_item(result)
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
908 self.in_li = 1
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
909 css_class = None
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
910 if self.line_was_empty and not self.first_list_item:
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
911 css_class = 'gap'
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
912 result.append(self.formatter.listitem(1, css_class=css_class, style="list-style-type:none"))
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
913 return ''.join(result)
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
914
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
915 def _li_none_repl(self, match, groups):
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
916 """Handle type=none (" .") lists."""
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
917 result = []
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
918 self._close_item(result)
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
919 self.in_li = 1
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
920 css_class = None
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
921 if self.line_was_empty and not self.first_list_item:
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
922 css_class = 'gap'
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
923 result.append(self.formatter.listitem(1, css_class=css_class, style="list-style-type:none"))
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
924 return ''.join(result)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
925
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
926 def _li_repl(self, match, groups):
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
927 """Handle bullet (" *") lists."""
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
928 result = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
929 self._close_item(result)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
930 self.in_li = 1
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
931 css_class = None
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
932 if self.line_was_empty and not self.first_list_item:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
933 css_class = 'gap'
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
934 result.append(self.formatter.listitem(1, css_class=css_class))
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
935 return ''.join(result)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
936
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
937 def _ol_repl(self, match, groups):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
938 """Handle numbered lists."""
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
939 return self._li_repl(match, groups)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
940
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
941 def _dl_repl(self, match, groups):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
942 """Handle definition lists."""
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
943 result = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
944 self._close_item(result)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
945 self.in_dd = 1
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
946 result.extend([
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
947 self.formatter.definition_term(1),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
948 self.formatter.text(match[1:-3].lstrip(' ')),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
949 self.formatter.definition_term(0),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
950 self.formatter.definition_desc(1),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
951 ])
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
952 return ''.join(result)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
953
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
954 def _indent_level(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
955 """Return current char-wise indent level."""
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
956 return len(self.list_indents) and self.list_indents[-1]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
957
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
958 def _indent_to(self, new_level, list_type, numtype, numstart):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
959 """Close and open lists."""
1360
8960f31bb162 wiki parser: do not use 'open' for variable name
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1357
diff changeset
960 openlist = [] # don't make one out of these two statements!
8960f31bb162 wiki parser: do not use 'open' for variable name
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1357
diff changeset
961 closelist = []
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
962
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
963 if self._indent_level() != new_level and self.in_table:
1360
8960f31bb162 wiki parser: do not use 'open' for variable name
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1357
diff changeset
964 closelist.append(self.formatter.table(0))
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
965 self.in_table = 0
1356
0120ccfbaaa1 wiki parser: whitespace and comments changes only
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1355
diff changeset
966
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
967 while self._indent_level() > new_level:
1360
8960f31bb162 wiki parser: do not use 'open' for variable name
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1357
diff changeset
968 self._close_item(closelist)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
969 if self.list_types[-1] == 'ol':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
970 tag = self.formatter.number_list(0)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
971 elif self.list_types[-1] == 'dl':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
972 tag = self.formatter.definition_list(0)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
973 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
974 tag = self.formatter.bullet_list(0)
1360
8960f31bb162 wiki parser: do not use 'open' for variable name
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1357
diff changeset
975 closelist.append(tag)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
976
521
d3a173c26e1c fixed dl indenting, some cosmetic issues
Thomas Waldmann <tw@waldmann-edv.de>
parents: 517
diff changeset
977 del self.list_indents[-1]
d3a173c26e1c fixed dl indenting, some cosmetic issues
Thomas Waldmann <tw@waldmann-edv.de>
parents: 517
diff changeset
978 del self.list_types[-1]
1356
0120ccfbaaa1 wiki parser: whitespace and comments changes only
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1355
diff changeset
979
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
980 if self.list_types: # we are still in a list
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
981 if self.list_types[-1] == 'dl':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
982 self.in_dd = 1
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
983 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
984 self.in_li = 1
1356
0120ccfbaaa1 wiki parser: whitespace and comments changes only
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1355
diff changeset
985
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
986 # Open new list, if necessary
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
987 if self._indent_level() < new_level:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
988 self.list_indents.append(new_level)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
989 self.list_types.append(list_type)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
990
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
991 if self.formatter.in_p:
1360
8960f31bb162 wiki parser: do not use 'open' for variable name
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1357
diff changeset
992 closelist.append(self.formatter.paragraph(0))
1356
0120ccfbaaa1 wiki parser: whitespace and comments changes only
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1355
diff changeset
993
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
994 if list_type == 'ol':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
995 tag = self.formatter.number_list(1, numtype, numstart)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
996 elif list_type == 'dl':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
997 tag = self.formatter.definition_list(1)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
998 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
999 tag = self.formatter.bullet_list(1)
1360
8960f31bb162 wiki parser: do not use 'open' for variable name
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1357
diff changeset
1000 openlist.append(tag)
1356
0120ccfbaaa1 wiki parser: whitespace and comments changes only
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1355
diff changeset
1001
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1002 self.first_list_item = 1
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1003 self.in_li = 0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1004 self.in_dd = 0
1356
0120ccfbaaa1 wiki parser: whitespace and comments changes only
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1355
diff changeset
1005
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1006 # If list level changes, close an open table
1360
8960f31bb162 wiki parser: do not use 'open' for variable name
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1357
diff changeset
1007 if self.in_table and (openlist or closelist):
8960f31bb162 wiki parser: do not use 'open' for variable name
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1357
diff changeset
1008 closelist[0:0] = [self.formatter.table(0)]
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1009 self.in_table = 0
1356
0120ccfbaaa1 wiki parser: whitespace and comments changes only
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1355
diff changeset
1010
553
42c37dcdc314 fixed: no p within lists
Thomas Waldmann <tw@waldmann-edv.de>
parents: 547
diff changeset
1011 self.in_list = self.list_types != []
1360
8960f31bb162 wiki parser: do not use 'open' for variable name
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1357
diff changeset
1012 return ''.join(closelist) + ''.join(openlist)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1013
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1014 def _undent(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1015 """Close all open lists."""
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1016 result = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1017 #result.append("<!-- _undent start -->\n")
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1018 self._close_item(result)
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 404
diff changeset
1019 for type in self.list_types[::-1]:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1020 if type == 'ol':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1021 result.append(self.formatter.number_list(0))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1022 elif type == 'dl':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1023 result.append(self.formatter.definition_list(0))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1024 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1025 result.append(self.formatter.bullet_list(0))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1026 #result.append("<!-- _undent end -->\n")
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1027 self.list_indents = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1028 self.list_types = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1029 return ''.join(result)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1030
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1031 def _getTableAttrs(self, attrdef):
2925
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
1032 attr_rule = r'^(\|\|)*<(?!<)(?P<attrs>[^>]*?)>'
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
1033 m = re.match(attr_rule, attrdef, re.U)
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
1034 if not m:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1035 return {}, ''
2925
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
1036 attrdef = m.group('attrs')
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1037
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1038 # extension for special table markup
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1039 def table_extension(key, parser, attrs, wiki_parser=self):
517
39da9e68875c wikiutil.parseAttribute extension now must return a tuple (found_flag, errmsg), fixing table attr parsing
Thomas Waldmann <tw@waldmann-edv.de>
parents: 444
diff changeset
1040 """ returns: tuple (found_flag, msg)
39da9e68875c wikiutil.parseAttribute extension now must return a tuple (found_flag, errmsg), fixing table attr parsing
Thomas Waldmann <tw@waldmann-edv.de>
parents: 444
diff changeset
1041 found_flag: whether we found something and were able to process it here
39da9e68875c wikiutil.parseAttribute extension now must return a tuple (found_flag, errmsg), fixing table attr parsing
Thomas Waldmann <tw@waldmann-edv.de>
parents: 444
diff changeset
1042 true for special stuff like 100% or - or #AABBCC
39da9e68875c wikiutil.parseAttribute extension now must return a tuple (found_flag, errmsg), fixing table attr parsing
Thomas Waldmann <tw@waldmann-edv.de>
parents: 444
diff changeset
1043 false for style xxx="yyy" attributes
39da9e68875c wikiutil.parseAttribute extension now must return a tuple (found_flag, errmsg), fixing table attr parsing
Thomas Waldmann <tw@waldmann-edv.de>
parents: 444
diff changeset
1044 msg: "" or an error msg
39da9e68875c wikiutil.parseAttribute extension now must return a tuple (found_flag, errmsg), fixing table attr parsing
Thomas Waldmann <tw@waldmann-edv.de>
parents: 444
diff changeset
1045 """
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1046 _ = wiki_parser._
517
39da9e68875c wikiutil.parseAttribute extension now must return a tuple (found_flag, errmsg), fixing table attr parsing
Thomas Waldmann <tw@waldmann-edv.de>
parents: 444
diff changeset
1047 found = False
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1048 msg = ''
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1049 if key[0] in "0123456789":
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1050 token = parser.get_token()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1051 if token != '%':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1052 wanted = '%'
2925
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
1053 msg = _('Expected "%(wanted)s" after "%(key)s", got "%(token)s"', formatted=False) % {
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1054 'wanted': wanted, 'key': key, 'token': token}
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1055 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1056 try:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1057 dummy = int(key)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1058 except ValueError:
2925
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
1059 msg = _('Expected an integer "%(key)s" before "%(token)s"', formatted=False) % {
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1060 'key': key, 'token': token}
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1061 else:
517
39da9e68875c wikiutil.parseAttribute extension now must return a tuple (found_flag, errmsg), fixing table attr parsing
Thomas Waldmann <tw@waldmann-edv.de>
parents: 444
diff changeset
1062 found = True
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1063 attrs['width'] = '"%s%%"' % key
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1064 elif key == '-':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1065 arg = parser.get_token()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1066 try:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1067 dummy = int(arg)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1068 except ValueError:
2925
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
1069 msg = _('Expected an integer "%(arg)s" after "%(key)s"', formatted=False) % {
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1070 'arg': arg, 'key': key}
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1071 else:
517
39da9e68875c wikiutil.parseAttribute extension now must return a tuple (found_flag, errmsg), fixing table attr parsing
Thomas Waldmann <tw@waldmann-edv.de>
parents: 444
diff changeset
1072 found = True
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1073 attrs['colspan'] = '"%s"' % arg
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1074 elif key == '|':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1075 arg = parser.get_token()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1076 try:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1077 dummy = int(arg)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1078 except ValueError:
2925
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
1079 msg = _('Expected an integer "%(arg)s" after "%(key)s"', formatted=False) % {
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1080 'arg': arg, 'key': key}
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1081 else:
517
39da9e68875c wikiutil.parseAttribute extension now must return a tuple (found_flag, errmsg), fixing table attr parsing
Thomas Waldmann <tw@waldmann-edv.de>
parents: 444
diff changeset
1082 found = True
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1083 attrs['rowspan'] = '"%s"' % arg
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1084 elif key == '(':
517
39da9e68875c wikiutil.parseAttribute extension now must return a tuple (found_flag, errmsg), fixing table attr parsing
Thomas Waldmann <tw@waldmann-edv.de>
parents: 444
diff changeset
1085 found = True
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1086 attrs['align'] = '"left"'
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1087 elif key == ':':
517
39da9e68875c wikiutil.parseAttribute extension now must return a tuple (found_flag, errmsg), fixing table attr parsing
Thomas Waldmann <tw@waldmann-edv.de>
parents: 444
diff changeset
1088 found = True
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1089 attrs['align'] = '"center"'
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1090 elif key == ')':
517
39da9e68875c wikiutil.parseAttribute extension now must return a tuple (found_flag, errmsg), fixing table attr parsing
Thomas Waldmann <tw@waldmann-edv.de>
parents: 444
diff changeset
1091 found = True
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1092 attrs['align'] = '"right"'
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1093 elif key == '^':
517
39da9e68875c wikiutil.parseAttribute extension now must return a tuple (found_flag, errmsg), fixing table attr parsing
Thomas Waldmann <tw@waldmann-edv.de>
parents: 444
diff changeset
1094 found = True
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1095 attrs['valign'] = '"top"'
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1096 elif key == 'v':
517
39da9e68875c wikiutil.parseAttribute extension now must return a tuple (found_flag, errmsg), fixing table attr parsing
Thomas Waldmann <tw@waldmann-edv.de>
parents: 444
diff changeset
1097 found = True
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1098 attrs['valign'] = '"bottom"'
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1099 elif key == '#':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1100 arg = parser.get_token()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1101 try:
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
1102 if len(arg) != 6:
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
1103 raise ValueError
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1104 dummy = int(arg, 16)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1105 except ValueError:
2925
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
1106 msg = _('Expected a color value "%(arg)s" after "%(key)s"', formatted=False) % {
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1107 'arg': arg, 'key': key}
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1108 else:
517
39da9e68875c wikiutil.parseAttribute extension now must return a tuple (found_flag, errmsg), fixing table attr parsing
Thomas Waldmann <tw@waldmann-edv.de>
parents: 444
diff changeset
1109 found = True
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1110 attrs['bgcolor'] = '"#%s"' % arg
517
39da9e68875c wikiutil.parseAttribute extension now must return a tuple (found_flag, errmsg), fixing table attr parsing
Thomas Waldmann <tw@waldmann-edv.de>
parents: 444
diff changeset
1111 return found, self.formatter.rawHTML(msg)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1112
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1113 # scan attributes
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1114 attr, msg = wikiutil.parseAttributes(self.request, attrdef, '>', table_extension)
529
20f8bda12a7b fix table *bgcolor trouble, cleanup style synth, fix html_gedit api
Thomas Waldmann <tw@waldmann-edv.de>
parents: 525
diff changeset
1115 if msg:
20f8bda12a7b fix table *bgcolor trouble, cleanup style synth, fix html_gedit api
Thomas Waldmann <tw@waldmann-edv.de>
parents: 525
diff changeset
1116 msg = '<strong class="highlight">%s</strong>' % msg
517
39da9e68875c wikiutil.parseAttribute extension now must return a tuple (found_flag, errmsg), fixing table attr parsing
Thomas Waldmann <tw@waldmann-edv.de>
parents: 444
diff changeset
1117 #self.request.log("parseAttributes returned %r" % attr)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1118 return attr, msg
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1119
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
1120 def _tableZ_repl(self, word, groups):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1121 """Handle table row end."""
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1122 if self.in_table:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1123 result = ''
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1124 # REMOVED: check for self.in_li, p should always close
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1125 if self.formatter.in_p:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1126 result = self.formatter.paragraph(0)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1127 result += self.formatter.table_cell(0) + self.formatter.table_row(0)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1128 return result
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1129 else:
279
54b01975e285 Fixed a few direct (non-formatter) returns in wiki.py. Broken for years ;-)
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 273
diff changeset
1130 return self.formatter.text(word)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1131
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
1132 def _table_repl(self, word, groups):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1133 """Handle table cell separator."""
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1134 if self.in_table:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1135 result = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1136 # check for attributes
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1137 attrs, attrerr = self._getTableAttrs(word)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1138
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1139 # start the table row?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1140 if self.table_rowstart:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1141 self.table_rowstart = 0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1142 result.append(self.formatter.table_row(1, attrs))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1143 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1144 # Close table cell, first closing open p
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1145 # REMOVED check for self.in_li, paragraph should close always!
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1146 if self.formatter.in_p:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1147 result.append(self.formatter.paragraph(0))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1148 result.append(self.formatter.table_cell(0))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1149
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1150 # check for adjacent cell markers
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1151 if word.count("|") > 2:
1868
64507f46beb2 reduce usage of has_key()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1867
diff changeset
1152 if 'align' not in attrs and \
64507f46beb2 reduce usage of has_key()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1867
diff changeset
1153 not ('style' in attrs and 'text-align' in attrs['style'].lower()):
1572
f6136eb3b021 Fixed MoinMoinBugs/TableAlignmentProbsWithGUI
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1520
diff changeset
1154 # add center alignment if we don't have some alignment already
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1155 attrs['align'] = '"center"'
1868
64507f46beb2 reduce usage of has_key()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1867
diff changeset
1156 if 'colspan' not in attrs:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1157 attrs['colspan'] = '"%d"' % (word.count("|")/2)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1158
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1159 # return the complete cell markup
1356
0120ccfbaaa1 wiki parser: whitespace and comments changes only
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1355
diff changeset
1160 result.append(self.formatter.table_cell(1, attrs) + attrerr)
525
66c0297e3fd0 make <p> self-closing, line-anchors more well-behaved
Thomas Waldmann <tw@waldmann-edv.de>
parents: 521
diff changeset
1161 result.append(self._line_anchordef())
1356
0120ccfbaaa1 wiki parser: whitespace and comments changes only
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1355
diff changeset
1162 return ''.join(result)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1163 else:
279
54b01975e285 Fixed a few direct (non-formatter) returns in wiki.py. Broken for years ;-)
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 273
diff changeset
1164 return self.formatter.text(word)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1165
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
1166 def _heading_repl(self, word, groups):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1167 """Handle section headings."""
2811
46dba22d0fdf wiki parser: introduce link and transclusion params, strip spaces with the regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2809
diff changeset
1168 heading_text = groups.get('heading_text', '')
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
1169 depth = min(len(groups.get('hmarker')), 5)
2566
d5ef57193ccb (johill, xorAxAx) make formatter responsible for making heading IDs unique
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2516
diff changeset
1170 return ''.join([
d5ef57193ccb (johill, xorAxAx) make formatter responsible for making heading IDs unique
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2516
diff changeset
1171 self._closeP(),
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
1172 self.formatter.heading(1, depth, id=heading_text),
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
1173 self.formatter.text(heading_text),
2566
d5ef57193ccb (johill, xorAxAx) make formatter responsible for making heading IDs unique
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2516
diff changeset
1174 self.formatter.heading(0, depth),
d5ef57193ccb (johill, xorAxAx) make formatter responsible for making heading IDs unique
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2516
diff changeset
1175 ])
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
1176 _heading_text_repl = _heading_repl
1356
0120ccfbaaa1 wiki parser: whitespace and comments changes only
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1355
diff changeset
1177
2719
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
1178 def _parser_repl(self, word, groups):
639
a80a6c629bc3 remove processor support, use a parser now
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 635
diff changeset
1179 """Handle parsed code displays."""
a80a6c629bc3 remove processor support, use a parser now
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 635
diff changeset
1180 self.parser = None
a80a6c629bc3 remove processor support, use a parser now
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 635
diff changeset
1181 self.parser_name = None
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
1182 self.parser_lines = []
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
1183 parser_line = word = groups.get('parser_line', u'')
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
1184 parser_name = groups.get('parser_name', None)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
1185 parser_args = groups.get('parser_args', None)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
1186 parser_nothing = groups.get('parser_nothing', None)
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
1187 parser_unique = groups.get('parser_unique', u'') or u''
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
1188 #logging.debug("_parser_repl: parser_name %r parser_args %r parser_unique %r" % (parser_name, parser_args, parser_unique))
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
1189 if set(parser_unique) == set('{'): # just some more {{{{{{
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3027
diff changeset
1190 parser_unique = u'}' * len(parser_unique) # for symmetry cosmetic reasons
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT wal&