Short description
It would be fine to have the posibility to write titles with subscripts and superscripts.
-- ReimarBauer 2005-07-04 08:21:34
patch to enable typefaces for 1.6dev. So you can write a title with subscripts H2O
all typefaces do work -- ReimarBauer 2007-03-18 17:22:13
1 --- text_moin_wiki_orig.py 2007-03-18 18:16:55.000000000 +0100
2 +++ text_moin_wiki.py 2007-03-18 18:21:16.000000000 +0100
3 @@ -919,7 +919,18 @@
4
5 # Get replace method and replace hit
6 replace = getattr(self, '_' + type + '_repl')
7 - result.append(replace(hit))
8 + # enables wiki markup in headings (Typefaces)
9 + if type == u"heading":
10 + hit = replace(hit)
11 + Parser = wikiutil.searchAndImportPlugin(self.request.cfg, "parser", 'wiki')
12 + hit = wikiutil.renderText(self.request, Parser, hit)
13 + hit = hit.replace('<', '<')
14 + hit = hit.replace('>', '>')
15 + result.append(hit)
16 + else:
17 + hit = replace(hit)
18 + result.append(hit)
19 +
20 return ''.join(result)
21 else:
22 # We should never get here
Discussion
TableOfContents needs to render headings too
- is attachment in heading wanted ?
- fails with gui editor because converter needs a patch too
Another patch for this
The reason wiki parser can not format the title is that the title it self is matched by the <heading> regex and there is no chance for other regex patterns to match against the title.
Now links, subscript, or others works in title. For example:
=== [[FeatureRequests/TitleFormatting|Link also works in title ===
=== H,,2,,O =
As a side effect of my patch, unblanced left right marker also works.
=== Title = is also a valid title.
Below is my patch. It may have the same result with the previous one.
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."""
30430_new_heading_parser.patch
-- JiangXin 2008-10-16 15:01:22