comparison MoinMoin/parser/text_rst.py @ 4493:af211e2f132c

moved anchor parsing from formatter to parsers, fixed anchor parsing for interwiki links, reduce code duplication by new wikiutil.split_anchor()
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 18 Jan 2009 12:54:18 +0100
parents 951ed1df8ec3
children b631aca46a48
comparison
equal deleted inserted replaced
4492:b74c7ec6addb 4493:af211e2f132c
18 # docutils imports are below 18 # docutils imports are below
19 from MoinMoin.parser.text_moin_wiki import Parser as WikiParser 19 from MoinMoin.parser.text_moin_wiki import Parser as WikiParser
20 from MoinMoin.Page import Page 20 from MoinMoin.Page import Page
21 from MoinMoin.action import AttachFile 21 from MoinMoin.action import AttachFile
22 from MoinMoin import wikiutil 22 from MoinMoin import wikiutil
23 from MoinMoin.support.python_compatibility import rsplit
24 23
25 Dependencies = [] # this parser just depends on the raw text 24 Dependencies = [] # this parser just depends on the raw text
26 25
27 # --- make docutils safe by overriding all module-scoped names related to IO --- 26 # --- make docutils safe by overriding all module-scoped names related to IO ---
28 27
398 # Don't touch the refuri. 397 # Don't touch the refuri.
399 if not [i for i in node.children if i.__class__ == docutils.nodes.image]: 398 if not [i for i in node.children if i.__class__ == docutils.nodes.image]:
400 node['classes'].append(prefix) 399 node['classes'].append(prefix)
401 else: 400 else:
402 # Default case - make a link to a wiki page. 401 # Default case - make a link to a wiki page.
403 pagename = refuri 402 pagename, anchor = wikiutil.split_anchor(refuri)
404 anchor = ''
405 if '#' in refuri:
406 pagename, anchor = rsplit(refuri, '#', 1)
407 page = Page(self.request, wikiutil.AbsPageName(self.formatter.page.page_name, pagename)) 403 page = Page(self.request, wikiutil.AbsPageName(self.formatter.page.page_name, pagename))
408 node['refuri'] = page.url(self.request, anchor=anchor) 404 node['refuri'] = page.url(self.request, anchor=anchor)
409 if not page.exists(): 405 if not page.exists():
410 node['classes'].append('nonexistent') 406 node['classes'].append('nonexistent')
411 html4css1.HTMLTranslator.visit_reference(self, node) 407 html4css1.HTMLTranslator.visit_reference(self, node)