annotate MoinMoin/parser/text_moin_wiki.py @ 6103:500f68d3e2fd

remove our own usage of python_compatibility module
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 06 Sep 2016 01:00:25 +0200
parents ff39884957af
children
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>,
3127
ea5383222f2f refactored misc. modules to use own logger instead of request.log
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3122
diff changeset
6 2006-2008 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
3107
c6e39279f83b refactor logging usage
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
12
3110
a48929a5036c logging: make it work correctly by doing logging configuration very early
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3107
diff changeset
13 from MoinMoin import log
a48929a5036c logging: make it work correctly by doing logging configuration very early
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3107
diff changeset
14 logging = log.getLogger(__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
15
635
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 569
diff changeset
16 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
17 from MoinMoin.Page import Page
2567
b403a24f7c8f (xorAxAx, johill) make saner looking anchors, no more sha hash
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2566
diff changeset
18
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2263
diff changeset
19 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
20
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
21
3784
951ed1df8ec3 move editor quickhelp out of config into parser modules
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3694
diff changeset
22 _ = lambda x: x
951ed1df8ec3 move editor quickhelp out of config into parser modules
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3694
diff changeset
23
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
24 class Parser:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
25 """
2777
8e87182648f4 cleaned up wiki parser comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2771
diff changeset
26 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
27
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
28 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
29 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
30
2777
8e87182648f4 cleaned up wiki parser comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2771
diff changeset
31 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
32 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
33
5421
eaef92e05011 extension for parser text_creole and text_moin_wiki added.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5102
diff changeset
34 extensions = ['.moin']
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
35 # allow caching
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
36 caching = 1
2196
45cf51902c61 wiki comment divs: fix caching behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2195
diff changeset
37 Dependencies = Dependencies
3784
951ed1df8ec3 move editor quickhelp out of config into parser modules
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3694
diff changeset
38 quickhelp = _(u"""\
951ed1df8ec3 move editor quickhelp out of config into parser modules
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3694
diff changeset
39 Emphasis:: <<Verbatim('')>>''italics''<<Verbatim('')>>; <<Verbatim(''')>>'''bold'''<<Verbatim(''')>>; <<Verbatim(''''')>>'''''bold italics'''''<<Verbatim(''''')>>; <<Verbatim('')>>''mixed ''<<Verbatim(''')>>'''''bold'''<<Verbatim(''')>> and italics''<<Verbatim('')>>; <<Verbatim(----)>> horizontal rule.
951ed1df8ec3 move editor quickhelp out of config into parser modules
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3694
diff changeset
40 Headings:: = Title 1 =; == Title 2 ==; === Title 3 ===; ==== Title 4 ====; ===== Title 5 =====.
951ed1df8ec3 move editor quickhelp out of config into parser modules
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3694
diff changeset
41 Lists:: space and one of: * bullets; 1., a., A., i., I. numbered items; 1.#n start numbering at n; space alone indents.
951ed1df8ec3 move editor quickhelp out of config into parser modules
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3694
diff changeset
42 Links:: <<Verbatim(JoinCapitalizedWords)>>; <<Verbatim([[target|linktext]])>>.
951ed1df8ec3 move editor quickhelp out of config into parser modules
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3694
diff changeset
43 Tables:: || cell text |||| cell text spanning 2 columns ||; no trailing white space allowed after tables or titles.
951ed1df8ec3 move editor quickhelp out of config into parser modules
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3694
diff changeset
44
4473
0e3c82dd2109 replace SyntaxReference page by HelpOnMoinWikiSyntax
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3996
diff changeset
45 (!) For more help, see HelpOnEditing or HelpOnMoinWikiSyntax.
3784
951ed1df8ec3 move editor quickhelp out of config into parser modules
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3694
diff changeset
46 """)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
47
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
48 # 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
49 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
50 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
51 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
52 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
53
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
54 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
55 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
56
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
57 # 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
58 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
59 (?:^|(?<=\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
60 (?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
61 (?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
62 \:
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
63 \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
64 )
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
65 (?:$|(?=\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
66 ''' % {
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
67 '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
68 '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
69 }
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
70
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
71 # 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
72 # 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
73 # 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
74 # 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
75 # 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
76 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
77 (?:^|(?<=\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
78 (?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
79 \:
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
80 (?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
81 (?=[^ ]*[%(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
82 [^\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
83 )
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
84 ''' % {
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
85 '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
86 '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
87 '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
88 }
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
89
3390
f1ba94b7913d GUI editor: fixed javascript error by using a simpler word_rule_js regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3338
diff changeset
90 # BE CAREFUL: if you do changes to word_rule, consider doing them also to word_rule_js (see below)
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
91 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
92 (?:
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
93 (?<![%(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
94 |
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
95 ^ # ... 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
96 )
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
97 (?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
98 (?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
99 (?:
2778
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
100 (%(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
101 |
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
102 ((?<!%(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
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 (
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
105 ((?<!%(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
106 (?:[%(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
107 )+ # 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
108 (?:
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
109 \# # 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
110 (?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
111 )?
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 )
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
113 (?:
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
114 (?![%(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
115 |
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
116 $ # ... 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
117 )
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
118 ''' % {
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
119 '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
120 '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
121 '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
122 '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
123 }
3390
f1ba94b7913d GUI editor: fixed javascript error by using a simpler word_rule_js regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3338
diff changeset
124 # simplified word_rule for FCKeditor's "unlink" plugin (puts a ! in front of a WikiName if WikiName matches word_rule_js),
f1ba94b7913d GUI editor: fixed javascript error by using a simpler word_rule_js regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3338
diff changeset
125 # because JavaScript can not use group names and verbose regular expressions!
f1ba94b7913d GUI editor: fixed javascript error by using a simpler word_rule_js regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3338
diff changeset
126 word_rule_js = (
f1ba94b7913d GUI editor: fixed javascript error by using a simpler word_rule_js regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3338
diff changeset
127 ur'''(?:(?<![%(u)s%(l)s/])|^)'''
f1ba94b7913d GUI editor: fixed javascript error by using a simpler word_rule_js regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3338
diff changeset
128 ur'''(?:'''
f1ba94b7913d GUI editor: fixed javascript error by using a simpler word_rule_js regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3338
diff changeset
129 ur'''(?:(%(parent)s)*|((?<!%(child)s)%(child)s)?)'''
f1ba94b7913d GUI editor: fixed javascript error by using a simpler word_rule_js regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3338
diff changeset
130 ur'''(((?<!%(child)s)%(child)s)?(?:[%(u)s][%(l)s]+){2,})+'''
f1ba94b7913d GUI editor: fixed javascript error by using a simpler word_rule_js regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3338
diff changeset
131 ur'''(?:\#(?:\S+))?'''
f1ba94b7913d GUI editor: fixed javascript error by using a simpler word_rule_js regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3338
diff changeset
132 ur''')'''
f1ba94b7913d GUI editor: fixed javascript error by using a simpler word_rule_js regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3338
diff changeset
133 ur'''(?:(?![%(u)s%(l)s/])|$)'''
f1ba94b7913d GUI editor: fixed javascript error by using a simpler word_rule_js regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3338
diff changeset
134 ) % {
f1ba94b7913d GUI editor: fixed javascript error by using a simpler word_rule_js regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3338
diff changeset
135 'u': config.chars_upper,
f1ba94b7913d GUI editor: fixed javascript error by using a simpler word_rule_js regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3338
diff changeset
136 'l': config.chars_lower,
f1ba94b7913d GUI editor: fixed javascript error by using a simpler word_rule_js regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3338
diff changeset
137 'child': re.escape(CHILD_PREFIX),
f1ba94b7913d GUI editor: fixed javascript error by using a simpler word_rule_js regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3338
diff changeset
138 'parent': re.escape(PARENT_PREFIX),
f1ba94b7913d GUI editor: fixed javascript error by using a simpler word_rule_js regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3338
diff changeset
139 }
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
140
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
141 # 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
142 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
143 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
144 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
145
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
146 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
147 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
148 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
149 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
150 ])
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
151 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
152
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
153 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
154 (?P<link>
2925
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
155 \[\[ # link target
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
156 \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
157 (?P<link_target>[^|]+?)
2925
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
158 \s* # strip space
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
159 (
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
160 \| # link description
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
161 \s* # strip space
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
162 (?P<link_desc>
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
163 (?: # 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
164 \{\{
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
165 \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
166 (\|\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
167 (\|\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
168 )?
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
169 )?
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
170 \}\}
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
171 )
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
172 |
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
173 (?: # 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
174 [^|]+?
2925
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
175 )
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
176 )?
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
177 \s* # strip space
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
178 (
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
179 \| # link parameters
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
180 \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
181 (?P<link_params>[^|]+?)?
2925
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
182 \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
183 )?
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
184 )?
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
185 \]\]
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
186 )
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
187 """
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
188
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
189 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
190 (?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
191 \{\{
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
192 \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
193 (\|\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
194 (\|\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
195 )?
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
196 )?
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
197 \}\}
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
198 )
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
199 """
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
200 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
201 (?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
202 [^|]+ # 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
203 )
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
204 """
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
205 # 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
206 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
207 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
208 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
209 ])
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
210 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
211
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
212 # 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
213 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
214 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
215 ])
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
216 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
217
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
218 # 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
219 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
220 ^\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
221 (?:[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
222 (?:\#\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
223 \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
224 """
61efafeafed5 wiki parser: rewrote half of it, 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 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
226
61efafeafed5 wiki parser: rewrote half of it, 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 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
228 ^\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
229 .*?:: # 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
230 \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
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 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
233
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
234 # 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
235 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
236 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
237
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
238 # 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
239 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
240 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
241 (?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
242 %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
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 """
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
245
1402
c65bff91b9e6 use special scanning rule when in pre sections
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1401
diff changeset
246
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
247 # 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
248 # 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
249 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
250 (?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
251 '''''(?=[^']+''') # 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
252 )|(?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
253 '''''(?=[^']+'') # 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
254 )|(?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
255 '{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
256 )|(?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
257 '{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
258 )|(?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
259 __ # 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
260 )|(?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
261 (
61efafeafed5 wiki parser: rewrote half of it, 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<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
263 |
61efafeafed5 wiki parser: rewrote half of it, 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<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
265 )
61efafeafed5 wiki parser: rewrote half of it, 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<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
267 (
61efafeafed5 wiki parser: rewrote half of it, 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<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
269 |
61efafeafed5 wiki parser: rewrote half of it, 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<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
271 )
61efafeafed5 wiki parser: rewrote half of it, 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<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
273 (
61efafeafed5 wiki parser: rewrote half of it, 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<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
275 |
61efafeafed5 wiki parser: rewrote half of it, 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<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
277 )
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
278 )|(?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
279 (
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
280 (^|(?<=\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
281 (?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
282 )
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 |
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
284 (
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
285 (?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
286 (?=\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
287 )
61efafeafed5 wiki parser: rewrote half of it, 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<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
289 \^ # 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
290 (?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
291 \^ # 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
292 )|(?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
293 ,, # subscript on
3694
56e6073b2e23 Fix subscript parsing (was broken for cases like 'a,,1,2,,')
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3458
diff changeset
294 (?P<sub_text>.*?) # capture the 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
295 ,, # 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
296 )|(?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
297 \{\{\{ # 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
298 (?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
299 \}\}\} # 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
300 )|(?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
301 ` # 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
302 (?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
303 ` # 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
304 )|(?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
305 %(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
306 )|(?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
307 %(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
308 )|
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
309 %(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
310 |
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
311 %(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
312 |(?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
313 %(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
314 )|(?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
315 [-\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
316 \@ # 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
317 [\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
318 )|(?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
319 (^|(?<=\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
320 (%(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
321 (?=\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
322 )|(?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
323 <<
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
324 (?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
325 (?:\((?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
326 >>
61efafeafed5 wiki parser: rewrote half of it, 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 )|(?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
328 ^(?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
329 (?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
330 \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
331 )|(?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
332 \{\{\{ # 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
333 (?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
334 (?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
335 (
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
336 \#! # 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
337 (?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
338 (
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
339 \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
340 (?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
341 )? # 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
342 \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
343 )
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
344 |
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
345 (?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
346 )$
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
347 # "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
348 )|(?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
349 ^\#\#.*$ # 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
350 )|(?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
351 %(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
352 )|(?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
353 %(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
354 )|(?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
355 ^\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
356 )|(?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
357 ^\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
358 )|(?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
359 ^\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
360 )|(?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
361 \|\|\ $ # 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
362 )|(?P<table>
2925
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
363 (?:\|\|)+(?:<(?!<)[^>]*?>)?(?!\|?\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
364 )|(?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
365 -{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
366 )|(?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
367 &(
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
368 ([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
369 |
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
370 (\#(\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
371 );
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
372 )|(?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
373 [<>&] # 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
374 )""" % {
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
375 '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
376 '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
377 'punct': punct_pattern,
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
378 '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
379 '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
380 '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
381 '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
382 '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
383 '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
384 '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
385 'l': config.chars_lower,
1866
0194beaf511e reduce reduce, filter and map usage
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1812
diff changeset
386 '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
387 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
388
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2263
diff changeset
389 # 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
390 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
391 "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
392 "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
393 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
394 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
395
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
396 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
397 self.raw = raw
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
398 self.request = request
1671
fa334986a93d fix missing parser.form attribute
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1667
diff changeset
399 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
400 self._ = request.getText
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
401 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
402 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
403 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
404 self.macro = None
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
405
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
406 # 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
407 # (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
408 # 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
409 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
410
1667
e3c56a97e30c wiki parser: removed unused imports, cosmetic changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1572
diff changeset
411 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
412 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
413 self.is_u = False
e3c56a97e30c wiki parser: removed unused imports, cosmetic changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1572
diff changeset
414 self.is_strike = False
e3c56a97e30c wiki parser: removed unused imports, cosmetic changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1572
diff changeset
415 self.is_big = False
e3c56a97e30c wiki parser: removed unused imports, cosmetic changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1572
diff changeset
416 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
417 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
418
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
419 self.lineno = 0
553
42c37dcdc314 fixed: no p within lists
Thomas Waldmann <tw@waldmann-edv.de>
parents: 547
diff changeset
420 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
421 self.in_li = 0 # between <li> and </li>
42c37dcdc314 fixed: no p within lists
Thomas Waldmann <tw@waldmann-edv.de>
parents: 547
diff changeset
422 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
423
a95414cd1280 wiki parser: replace numerical in_pre state values by strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1360
diff changeset
424 # 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
425 # 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
426 # '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
427 # '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
428 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
429
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
430 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
431 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
432
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
433 # 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
434 self.list_indents = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
435 self.list_types = []
1356
0120ccfbaaa1 wiki parser: whitespace and comments changes only
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1355
diff changeset
436
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
437 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
438 #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
439 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
440 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
441 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
442 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
443 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
444 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
445 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
446 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
447 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
448 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
449 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
450 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
451 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
452 #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
453
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
454 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
455 """Handle underline."""
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
456 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
457 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
458
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
459 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
460 """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
461 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
462 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
463 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
464 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
465 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
466 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
467 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
468 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
469 _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
470 _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
471
61efafeafed5 wiki parser: rewrote half of it, 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 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
473 """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
474 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
475 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
476 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
477 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
478 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
479 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
480 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
481 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
482 _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
483 _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
484
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
485 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
486 """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
487 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
488 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
489 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
490 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
491 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
492 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
493 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
494 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
495 _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
496 _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
497
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
498 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
499 """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
500 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
501 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
502 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
503 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
504 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
505 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
506 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
507 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
508 _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
509 _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
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_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 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
513 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
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 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
516 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
517 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
518 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
519 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
520 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
521 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
522 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
523
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
524 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
525 """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
526 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
527 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
528 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
529 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
530 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
531
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
532 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
533 """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
534 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
535 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
536 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
537 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
538 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
539
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
540 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
541 """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
542 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
543 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
544 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
545 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
546 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
547 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
548 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
549
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
550 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
551 """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
552 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
553 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
554 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
555 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
556 _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
557
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
558 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
559 """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
560 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
561 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
562 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
563 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
564 _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
565
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
566 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
567 """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
568 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
569 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
570 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
571 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
572 _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
573
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 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
575 """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
576 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
577 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
578 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
579 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
580 _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
581
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
582 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
583 """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
584 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
585 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
586 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
587 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
588 # 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
589 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
590 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
591 return result
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
592
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 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
594 """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
595 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
596 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
597
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
598 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
599 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
600 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
601 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
602 else:
4493
af211e2f132c moved anchor parsing from formatter to parsers, fixed anchor parsing for interwiki links, reduce code duplication by new wikiutil.split_anchor()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4476
diff changeset
603 page, anchor = wikiutil.split_anchor(page)
af211e2f132c moved anchor parsing from formatter to parsers, fixed anchor parsing for interwiki links, reduce code duplication by new wikiutil.split_anchor()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4476
diff changeset
604 return (self.formatter.interwikilink(1, wiki, page, anchor=anchor) +
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
605 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
606 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
607 _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
608 _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
609
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
610 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
611 """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
612 bang = ''
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
613 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
614 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
615 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
616 # handle !NotWikiNames
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
617 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
618 else:
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
619 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
620 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
621 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
622 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
623 # 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
624 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
625 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
626 else:
4493
af211e2f132c moved anchor parsing from formatter to parsers, fixed anchor parsing for interwiki links, reduce code duplication by new wikiutil.split_anchor()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4476
diff changeset
627 abs_name, anchor = wikiutil.split_anchor(abs_name)
2778
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
628 return (bang +
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2777
diff changeset
629 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
630 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
631 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
632 _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
633 _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
634 _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
635
2721
2e5634c64e6d wiki parser: some internal renames, fix https images
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2720
diff changeset
636 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
637 """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
638 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
639 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
640 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
641 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
642 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
643 _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
644 _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
645
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
646 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
647 """ parse a string <desc> valid as transclude description (text, ...)
3255
bf0e5f19be97 moin wiki parser: fix escaping of transclusion description (the formatter does it!), use formatter.text to output a description as text
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3250
diff changeset
648 and return the description.
bf0e5f19be97 moin wiki parser: fix escaping of transclusion description (the formatter does it!), use formatter.text to output a description as text
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3250
diff changeset
649
bf0e5f19be97 moin wiki parser: fix escaping of transclusion description (the formatter does it!), use formatter.text to output a description as text
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3250
diff changeset
650 We do NOT use wikiutil.escape here because it is html specific (the
bf0e5f19be97 moin wiki parser: fix escaping of transclusion description (the formatter does it!), use formatter.text to output a description as text
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3250
diff changeset
651 html formatter, if used, does this for all html attributes).
bf0e5f19be97 moin wiki parser: fix escaping of transclusion description (the formatter does it!), use formatter.text to output a description as text
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3250
diff changeset
652
bf0e5f19be97 moin wiki parser: fix escaping of transclusion description (the formatter does it!), use formatter.text to output a description as text
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3250
diff changeset
653 We do NOT call formatter.text here because it sometimes is just used
bf0e5f19be97 moin wiki parser: fix escaping of transclusion description (the formatter does it!), use formatter.text to output a description as text
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3250
diff changeset
654 for some alt and/or title attribute, but not emitted as 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
655
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
656 @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
657 @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
658 """
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
659 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
660 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
661 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
662 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
663 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
664 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
665 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
666
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
667 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
668 """ 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
669 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
670 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
671 by the params.
6ac9e14a0241 wiki parser: link/transclusion parameter parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2811
diff changeset
672 """
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
673 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
674 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
675 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
676 query_args = {}
2812
6ac9e14a0241 wiki parser: link/transclusion parameter parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2811
diff changeset
677 if params:
6ac9e14a0241 wiki parser: link/transclusion parameter parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2811
diff changeset
678 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
679 # 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
680 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
681 acceptable_attrs = []
2812
6ac9e14a0241 wiki parser: link/transclusion parameter parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2811
diff changeset
682 for key, val in kw.items():
3257
7beffeb2e41f moin wiki parser: fix escaping of attributes (the formatter does it!)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3255
diff changeset
683 # wikiutil.escape for key/val must be done by (html) formatter!
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
684 if key in acceptable_attrs:
3336
fb0f0f3ef115 wiki parser: allow arbitrary unicode link parameters
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3307
diff changeset
685 # tag attributes must be string type
fb0f0f3ef115 wiki parser: allow arbitrary unicode link parameters
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3307
diff changeset
686 tag_attrs[str(key)] = 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
687 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
688 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
689 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
690 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
691
2721
2e5634c64e6d wiki parser: some internal renames, fix https images
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2720
diff changeset
692 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
693 """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
694 target = groups.get('transclude_target', '')
4569
3caaa8c74c41 wikiutil: replace moin's cgi/urllib wrappers by calls to werkzeug.utils code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4498
diff changeset
695 target = wikiutil.url_unquote(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
696 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
697 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
698 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
699 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
700 '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
701 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
702 if m:
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
703 if m.group('extern_addr'):
3441
8230be5f24d7 wiki parser: removed protocol check for (image) transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3390
diff changeset
704 # currently only supports ext. image inclusion
2722
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
705 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
706 desc = self._transclude_description(desc, target)
3441
8230be5f24d7 wiki parser: removed protocol check for (image) transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3390
diff changeset
707 tag_attrs, query_args = self._get_params(params,
8230be5f24d7 wiki parser: removed protocol check for (image) transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3390
diff changeset
708 tag_attrs={'class': 'external_image',
8230be5f24d7 wiki parser: removed protocol check for (image) transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3390
diff changeset
709 'alt': desc,
8230be5f24d7 wiki parser: removed protocol check for (image) transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3390
diff changeset
710 'title': desc, },
8230be5f24d7 wiki parser: removed protocol check for (image) transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3390
diff changeset
711 acceptable_attrs=acceptable_attrs_img)
8230be5f24d7 wiki parser: removed protocol check for (image) transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3390
diff changeset
712 return self.formatter.image(src=target, **tag_attrs)
8230be5f24d7 wiki parser: removed protocol check for (image) transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3390
diff changeset
713 # FF2 has a bug with target mimetype detection, it looks at the url path
8230be5f24d7 wiki parser: removed protocol check for (image) transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3390
diff changeset
714 # and expects to find some "filename extension" there (like .png) and this
8230be5f24d7 wiki parser: removed protocol check for (image) transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3390
diff changeset
715 # (not the response http headers) will set the default content-type of
8230be5f24d7 wiki parser: removed protocol check for (image) transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3390
diff changeset
716 # the object. This will often work for staticly served files, but
8230be5f24d7 wiki parser: removed protocol check for (image) transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3390
diff changeset
717 # fails for MoinMoin attachments (they don't have the filename.ext in the
8230be5f24d7 wiki parser: removed protocol check for (image) transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3390
diff changeset
718 # path, but in the query string). FF3 seems to have this bug fixed, opera 9.2
8230be5f24d7 wiki parser: removed protocol check for (image) transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3390
diff changeset
719 # also works.
8230be5f24d7 wiki parser: removed protocol check for (image) transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3390
diff changeset
720 #return (self.formatter.transclusion(1, data=target) +
8230be5f24d7 wiki parser: removed protocol check for (image) transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3390
diff changeset
721 # desc +
8230be5f24d7 wiki parser: removed protocol check for (image) transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3390
diff changeset
722 # 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
723
2722
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
724 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
725 scheme = m.group('attach_scheme')
4569
3caaa8c74c41 wikiutil: replace moin's cgi/urllib wrappers by calls to werkzeug.utils code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4498
diff changeset
726 url = wikiutil.url_unquote(m.group('attach_addr'))
2722
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
727 if scheme == 'attachment':
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
728 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
729 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
730 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
731 return self.formatter.attachment_inlined(url, desc)
3338
5f660b3c1cd7 moved browser_supported_images to config and exchanged it
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3336
diff changeset
732 # destinguishs if browser need a plugin in place
5f660b3c1cd7 moved browser_supported_images to config and exchanged it
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3336
diff changeset
733 elif mt.major == 'image' and mt.minor in config.browser_supported_images:
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
734 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
735 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
736 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
737 '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
738 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
739 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
740 else:
2755
7c8e3ce74202 wiki parser: using <object> for client side page transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2746
diff changeset
741 from MoinMoin.action import AttachFile
5506
a4b4cd17410c wiki parser: fix transclusion of attachments on other pages (backport from 1.9)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4493
diff changeset
742 current_pagename = self.formatter.page.page_name
a4b4cd17410c wiki parser: fix transclusion of attachments on other pages (backport from 1.9)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4493
diff changeset
743 pagename, filename = AttachFile.absoluteName(url, current_pagename)
a4b4cd17410c wiki parser: fix transclusion of attachments on other pages (backport from 1.9)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4493
diff changeset
744 if AttachFile.exists(self.request, pagename, filename):
5493
07833d54f43d wiki parser: fix transclusion of attachments on other pages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5444
diff changeset
745 href = AttachFile.getAttachUrl(pagename, filename, self.request)
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
746 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
747 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
748 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
749 return (self.formatter.transclusion(1, data=href, type=mt.spoil(), **tag_attrs) +
3255
bf0e5f19be97 moin wiki parser: fix escaping of transclusion description (the formatter does it!), use formatter.text to output a description as text
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3250
diff changeset
750 self.formatter.text(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
751 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
752 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
753 return (self.formatter.attachment_link(1, url) +
3255
bf0e5f19be97 moin wiki parser: fix escaping of transclusion description (the formatter does it!), use formatter.text to output a description as text
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3250
diff changeset
754 self.formatter.text(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
755 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
756
7c8e3ce74202 wiki parser: using <object> for client side page transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2746
diff changeset
757 #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
758
2722
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
759 # 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
760 if mt is not None:
3266
f62792cb2d24 macro.EmbedObject: adjusted to changes of argument parser, escaped output.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3257
diff changeset
761 from MoinMoin import macro
2722
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
762 macro.request = self.request
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
763 macro.formatter = self.request.html_formatter
3266
f62792cb2d24 macro.EmbedObject: adjusted to changes of argument parser, escaped output.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3257
diff changeset
764 p = Parser("##\n", request)
f62792cb2d24 macro.EmbedObject: adjusted to changes of argument parser, escaped output.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3257
diff changeset
765 m = macro.Macro(p)
2722
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
766 pagename = self.formatter.page.page_name
3266
f62792cb2d24 macro.EmbedObject: adjusted to changes of argument parser, escaped output.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3257
diff changeset
767 return m.execute('EmbedObject', u'target=%s' % url)
2722
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
768 elif scheme == 'drawing':
5102
9ae242080889 drawings/attachments: made editing support more generic (details see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5101
diff changeset
769 url = wikiutil.drawing2fname(url)
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
770 desc = self._transclude_description(desc, url)
4476
f8e4e84525e8 streamline attachment_drawing formatter behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3996
diff changeset
771 if desc:
f8e4e84525e8 streamline attachment_drawing formatter behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3996
diff changeset
772 tag_attrs= {'alt': desc, 'title': desc, }
f8e4e84525e8 streamline attachment_drawing formatter behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3996
diff changeset
773 else:
f8e4e84525e8 streamline attachment_drawing formatter behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3996
diff changeset
774 tag_attrs = {}
f8e4e84525e8 streamline attachment_drawing formatter behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3996
diff changeset
775 tag_attrs, query_args = self._get_params(params,
f8e4e84525e8 streamline attachment_drawing formatter behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3996
diff changeset
776 tag_attrs=tag_attrs,
f8e4e84525e8 streamline attachment_drawing formatter behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3996
diff changeset
777 acceptable_attrs=acceptable_attrs_img)
f8e4e84525e8 streamline attachment_drawing formatter behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3996
diff changeset
778 return self.formatter.attachment_drawing(url, desc, **tag_attrs)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
779
2755
7c8e3ce74202 wiki parser: using <object> for client side page transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2746
diff changeset
780 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
781 # 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
782 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
783 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
784 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
785 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
786 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
787 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
788 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
789 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
790 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
791 '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
792 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
793 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
794 query_args['action'] = 'content'
3234
a739558ca3dc Page.url() default changed to relative=False
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3222
diff changeset
795 url = Page(self.request, page_name_all).url(self.request, querystr=query_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
796 return (self.formatter.transclusion(1, data=url, **tag_attrs) +
3255
bf0e5f19be97 moin wiki parser: fix escaping of transclusion description (the formatter does it!), use formatter.text to output a description as text
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3250
diff changeset
797 self.formatter.text(self._transclude_description(desc, page_name_all)) +
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
798 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
799 #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
800 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
801 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
802 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
803 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
804 '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
805 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
806 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
807 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
808 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
809 return (self.formatter.transclusion(1, data=url, **tag_attrs) +
3255
bf0e5f19be97 moin wiki parser: fix escaping of transclusion description (the formatter does it!), use formatter.text to output a description as text
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3250
diff changeset
810 self.formatter.text(self._transclude_description(desc, 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
811 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
812 #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
813
27822696115f wiki parser: clean up link vs. transclusion
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2721
diff changeset
814 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
815 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
816 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
817 return word +'???'
2721
2e5634c64e6d wiki parser: some internal renames, fix https images
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2720
diff changeset
818 _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
819 _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
820 _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
821
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
822 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
823 """ 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
824 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
825
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
826 @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
827 @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
828 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
829 @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
830 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
831 """
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
832 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
833 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
834 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
835 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
836 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
837 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
838 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
839 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
840 # 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
841 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
842 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
843 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
844 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
845 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
846 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
847 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
848 return desc
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
849
2721
2e5634c64e6d wiki parser: some internal renames, fix https images
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2720
diff changeset
850 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
851 """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
852 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
853 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
854 params = groups.get('link_params', u'') or u''
5444
48874d70abff accept rel attr for links
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5427
diff changeset
855 acceptable_attrs = ['class', 'title', 'target', 'accesskey', 'rel', ] # 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
856 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
857 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
858 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
859 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
860 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
861 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
862 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
863 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
864 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
865 if err: # not a interwiki link / not in interwiki map
4493
af211e2f132c moved anchor parsing from formatter to parsers, fixed anchor parsing for interwiki links, reduce code duplication by new wikiutil.split_anchor()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4476
diff changeset
866 page_name, anchor = wikiutil.split_anchor(page_name_and_anchor)
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
867 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
868 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
869 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
870 # 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
871 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
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={},
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)
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
875 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
876 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
877 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
878 else: # interwiki link
4493
af211e2f132c moved anchor parsing from formatter to parsers, fixed anchor parsing for interwiki links, reduce code duplication by new wikiutil.split_anchor()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4476
diff changeset
879 page_name, anchor = wikiutil.split_anchor(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
880 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
881 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
882 acceptable_attrs=acceptable_attrs)
4493
af211e2f132c moved anchor parsing from formatter to parsers, fixed anchor parsing for interwiki links, reduce code duplication by new wikiutil.split_anchor()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4476
diff changeset
883 return (self.formatter.interwikilink(1, wiki_name, page_name, anchor=anchor, querystr=query_args, **tag_attrs) +
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
884 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
885 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
886
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
887 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
888 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
889 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
890 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
891 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
892 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
893 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
894 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
895 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
896
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
897 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
898 scheme = mt.group('attach_scheme')
4569
3caaa8c74c41 wikiutil: replace moin's cgi/urllib wrappers by calls to werkzeug.utils code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4498
diff changeset
899 url = wikiutil.url_unquote(mt.group('attach_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
900 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
901 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
902 acceptable_attrs=acceptable_attrs)
5561
16db661e85b7 MoinMoin.support: move the flup version notes to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5508
diff changeset
903 if scheme == 'attachment': # ZZZ
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
904 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
905 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
906 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
907 elif scheme == 'drawing':
5102
9ae242080889 drawings/attachments: made editing support more generic (details see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5101
diff changeset
908 url = wikiutil.drawing2fname(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
909 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
910 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
911 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
912 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
913 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
914 _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
915 _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
916 _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
917
61efafeafed5 wiki parser: rewrote half of it, using link markup inspired by creole, removing magic, removing old weird code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2576
diff changeset
918 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
919 """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
920 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
921 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
922 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
923
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
924 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
925 """Handle SGML entities."""
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
926 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
927
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
928 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
929 """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
930 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
931
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
932 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
933 """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
934 result = []
521
d3a173c26e1c fixed dl indenting, some cosmetic issues
Thomas Waldmann <tw@waldmann-edv.de>
parents: 517
diff changeset
935 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
936 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
937 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
938 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
939 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
940 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
941 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
942 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
943
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
944 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
945 """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
946 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
947 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
948 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
949 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
950 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
951 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
952 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
953 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
954
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
955 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
956 """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
957 result = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
958 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
959 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
960 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
961 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
962 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
963 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
964 return ''.join(result)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
965
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
966 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
967 """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
968 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
969
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
970 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
971 """Handle definition lists."""
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
972 result = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
973 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
974 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
975 result.extend([
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
976 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
977 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
978 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
979 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
980 ])
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
981 return ''.join(result)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
982
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
983 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
984 """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
985 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
986
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
987 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
988 """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
989 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
990 closelist = []
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
991
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
992 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
993 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
994 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
995
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
996 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
997 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
998 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
999 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
1000 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
1001 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
1002 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1003 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
1004 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
1005
521
d3a173c26e1c fixed dl indenting, some cosmetic issues
Thomas Waldmann <tw@waldmann-edv.de>
parents: 517
diff changeset
1006 del self.list_indents[-1]
d3a173c26e1c fixed dl indenting, some cosmetic issues
Thomas Waldmann <tw@waldmann-edv.de>
parents: 517
diff changeset
1007 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
1008
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1009 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
1010 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
1011 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
1012 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1013 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
1014
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1015 # 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
1016 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
1017 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
1018 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
1019
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1020 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
1021 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
1022
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1023 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
1024 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
1025 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
1026 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
1027 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1028 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
1029 openlist.append(tag)
1356
0120ccfbaaa1 wiki parser: whitespace and comments changes only
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1355
diff changeset
1030
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1031 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
1032 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
1033 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
1034
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1035 # 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
1036 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
1037 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
1038 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
1039
553
42c37dcdc314 fixed: no p within lists
Thomas Waldmann <tw@waldmann-edv.de>
parents: 547
diff changeset
1040 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
1041 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
1042
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1043 def _undent(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1044 """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
1045 result = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1046 #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
1047 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
1048 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
1049 if type == 'ol':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1050 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
1051 elif type == 'dl':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1052 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
1053 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1054 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
1055 #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
1056 self.list_indents = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1057 self.list_types = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1058 return ''.join(result)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1059
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1060 def _getTableAttrs(self, attrdef):
2925
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
1061 attr_rule = r'^(\|\|)*<(?!<)(?P<attrs>[^>]*?)>'
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
1062 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
1063 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
1064 return {}, ''
2925
c2d362149f71 port wiki parser changes from 1.6
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2920
diff changeset
1065 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
1066
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1067 # 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
1068 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
1069 """ 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
1070 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
1071 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
1072 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
1073 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
1074 """
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1075 _ = 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
1076 found = False
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1077 msg = ''
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1078 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
1079 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
1080 if token != '%':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1081 wanted = '%'
3122
a1322262398a refactored _() getText calls to match new api
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3110
diff changeset
1082 msg = _('Expected "%(wanted)s" after "%(key)s", got "%(token)s"') % {
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1083 '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
1084 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1085 try:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1086 dummy = int(key)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1087 except ValueError:
3122
a1322262398a refactored _() getText calls to match new api
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3110
diff changeset
1088 msg = _('Expected an integer "%(key)s" before "%(token)s"') % {
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1089 '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
1090 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
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['width'] = '"%s%%"' % key
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1093 elif key == '-':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1094 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
1095 try:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1096 dummy = int(arg)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1097 except ValueError:
3122
a1322262398a refactored _() getText calls to match new api
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3110
diff changeset
1098 msg = _('Expected an integer "%(arg)s" after "%(key)s"') % {
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1099 '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
1100 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
1101 found = True
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1102 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
1103 elif key == '|':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1104 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
1105 try:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1106 dummy = int(arg)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1107 except ValueError:
3122
a1322262398a refactored _() getText calls to match new api
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3110
diff changeset
1108 msg = _('Expected an integer "%(arg)s" after "%(key)s"') % {
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1109 '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
1110 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
1111 found = True
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1112 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
1113 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
1114 found = True
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1115 attrs['align'] = '"left"'
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1116 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
1117 found = True
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1118 attrs['align'] = '"center"'
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1119 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
1120 found = True
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1121 attrs['align'] = '"right"'
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1122 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
1123 found = True
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1124 attrs['valign'] = '"top"'
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1125 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
1126 found = True
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1127 attrs['valign'] = '"bottom"'
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1128 elif key == '#':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1129 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
1130 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
1131 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
1132 raise ValueError
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1133 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
1134 except ValueError:
3122
a1322262398a refactored _() getText calls to match new api
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3110
diff changeset
1135 msg = _('Expected a color value "%(arg)s" after "%(key)s"') % {
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1136 '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
1137 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
1138 found = True
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1139 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
1140 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
1141
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1142 # scan attributes
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1143 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
1144 if msg:
20f8bda12a7b fix table *bgcolor trouble, cleanup style synth, fix html_gedit api
Thomas Waldmann <tw@waldmann-edv.de>
parents: 525
diff changeset
1145 msg = '<strong class="highlight">%s</strong>' % msg
3127
ea5383222f2f refactored misc. modules to use own logger instead of request.log
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3122
diff changeset
1146 #logging.debug("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
1147 return attr, msg
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1148
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
1149 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
1150 """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
1151 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
1152 result = ''
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1153 # 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
1154 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
1155 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
1156 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
1157 return result
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1158 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
1159 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
1160
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
1161 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
1162 """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
1163 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
1164 result = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1165 # check for attributes
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1166 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
1167
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1168 # 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
1169 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
1170 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
1171 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
1172 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1173 # 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
1174 # 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
1175 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
1176 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
1177 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
1178
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1179 # 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
1180 if word.count("|") > 2:
1868
64507f46beb2 reduce usage of has_key()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1867
diff changeset
1181 if 'align' not in attrs and \
64507f46beb2 reduce usage of has_key()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1867
diff changeset
1182 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
1183 # 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
1184 attrs['align'] = '"center"'
1868
64507f46beb2 reduce usage of has_key()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1867
diff changeset
1185 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
1186 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
1187
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1188 # return the complete cell markup
1356
0120ccfbaaa1 wiki parser: whitespace and comments changes only
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: