Attachment '30430_new_heading_parser.patch'
Download 1 New header parser allow links and other wiki format in header.
2
3 diff -r 873d2942ba36 MoinMoin/parser/text_moin_wiki.py
4 --- a/MoinMoin/parser/text_moin_wiki.py Wed Nov 19 10:25:21 2008 +0800
5 +++ b/MoinMoin/parser/text_moin_wiki.py Wed Nov 19 10:25:23 2008 +0800
6 @@ -325,9 +325,11 @@
7 (?:\((?P<macro_args>.*?)\))? # optionally macro arguments
8 >>
9 )|(?P<heading>
10 - ^(?P<hmarker>=+)\s+ # some === at beginning of line, eat trailing blanks
11 - (?P<heading_text>.*?) # capture heading text
12 - \s+(?P=hmarker)\s$ # some === at end of line (matching amount as we have seen), eat blanks
13 + (
14 + (^(?P<heading_on>=+)\s*) # some === at beginning of line, eat trailing blanks
15 + |
16 + (?P<heading_off>\s*=*\s$) # some === at end of line (matching amount as we have seen), eat blanks
17 + )
18 )|(?P<parser>
19 \{\{\{ # parser on
20 (?P<parser_unique>(\{*|\w*)) # either some more {{{{ or some chars to solve the nesting problem
21 @@ -415,6 +417,8 @@
22 self.is_big = False
23 self.is_small = False
24 self.is_remark = False
25 + # OSSXP: new header parser
26 + self.heading_depth = 0
27
28 self.lineno = 0
29 self.in_list = 0 # between <ul/ol/dl> and </ul/ol/dl>
30 @@ -1198,15 +1202,27 @@
31
32 def _heading_repl(self, word, groups):
33 """Handle section headings."""
34 - heading_text = groups.get('heading_text', '')
35 - depth = min(len(groups.get('hmarker')), 5)
36 - return ''.join([
37 - self._closeP(),
38 - self.formatter.heading(1, depth, id=heading_text),
39 - self.formatter.text(heading_text),
40 - self.formatter.heading(0, depth),
41 - ])
42 - _heading_text_repl = _heading_repl
43 + on = groups.get('heading_on', '')
44 + if on:
45 + depth = min(len(on), 5)
46 + self.heading_depth = depth
47 + return ''.join([
48 + # self._closeP(),
49 + self.formatter.heading(1, depth, id=self.formatter.page.page_name),
50 + ])
51 + else: # end of heading
52 + depth = self.heading_depth
53 + self.heading_depth = 0
54 + if depth:
55 + return ''.join([
56 + self._closeP(),
57 + self.formatter.heading(0, depth)
58 + ])
59 + else:
60 + return self.formatter.text(word)
61 +
62 + _heading_on_repl = _heading_repl
63 + _heading_off_repl = _heading_repl
64
65 def _parser_repl(self, word, groups):
66 """Handle parsed code displays."""
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.