comparison MoinMoin/wikiutil.py @ 2704:c6b5c2d813b6

fix AbsPageName(), add tests for it
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 21 Aug 2007 15:45:24 +0200
parents 2e6227a50d27
children 4a4d84273ae1 7bfe80df6772
comparison
equal deleted inserted replaced
2703:558a527c0ec7 2704:c6b5c2d813b6
838 @param pagename: the (possibly relative) page name 838 @param pagename: the (possibly relative) page name
839 @rtype: string 839 @rtype: string
840 @return: the absolute page name 840 @return: the absolute page name
841 """ 841 """
842 if pagename.startswith(PARENT_PREFIX): 842 if pagename.startswith(PARENT_PREFIX):
843 pagename = '/'.join([x for x in context.split('/')[:-1] + [pagename[PARENT_PREFIX_LEN:]] if x]) 843 while context and pagename.startswith(PARENT_PREFIX):
844 context = '/'.join(context.split('/')[:-1])
845 pagename = pagename[PARENT_PREFIX_LEN:]
846 pagename = '/'.join(filter(None, [ context, pagename, ]))
844 elif pagename.startswith(CHILD_PREFIX): 847 elif pagename.startswith(CHILD_PREFIX):
845 pagename = context + '/' + pagename[CHILD_PREFIX_LEN:] 848 if context:
849 pagename = context + '/' + pagename[CHILD_PREFIX_LEN:]
850 else:
851 pagename = pagename[CHILD_PREFIX_LEN:]
846 return pagename 852 return pagename
847 853
848 def pagelinkmarkup(pagename): 854 def pagelinkmarkup(pagename):
849 """ return markup that can be used as link to page <pagename> """ 855 """ return markup that can be used as link to page <pagename> """
850 from MoinMoin.parser.text_moin_wiki import Parser 856 from MoinMoin.parser.text_moin_wiki import Parser