Mercurial > moin > 1.9
changeset 2744:e931f45fec3a
wiki parser: support multiple parent prefixes, require no / directly before or after matched wikiwords
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Tue, 21 Aug 2007 16:35:54 +0200 |
parents | 7bfe80df6772 |
children | 4c95862bf9ef |
files | MoinMoin/parser/text_moin_wiki.py MoinMoin/wikiutil.py |
diffstat | 2 files changed, 9 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/parser/text_moin_wiki.py Tue Aug 21 15:47:56 2007 +0200 +++ b/MoinMoin/parser/text_moin_wiki.py Tue Aug 21 16:35:54 2007 +0200 @@ -71,19 +71,23 @@ word_rule = ur''' (?: - (?<![%(u)s%(l)s]) # require anything not upper/lower before + (?<![%(u)s%(l)s/]) # require anything not upper/lower/slash before | ^ # ... or beginning of line ) (?P<word_bang>\!)? # configurable: avoid getting CamelCase rendered as link - (?P<word_parent_prefix>%(parent)s)? # there might be ../ parent prefix XXX TODO: there might be even multiple!! (?P<word_name> + (?: + (?P<word_parent_prefix>%(parent)s)* # there might be either ../ parent prefix(es) + | + ((?<!%(child)s)%(child)s)? # or maybe a single / child prefix (but not if we already had it before) + ) ( - (%(child)s)? # there might be / child prefix + ((?<!%(child)s)%(child)s)? # there might be / child prefix (but not if we already had it before) (?:[%(u)s][%(l)s]+){2,} # at least 2 upper>lower transitions make CamelCase )+ # we can have MainPage/SubPage/SubSubPage ... ) - (?![%(u)s%(l)s]+) # require anything NOT upper/lower following + (?![%(u)s%(l)s/]) # require anything not upper/lower/slash following ''' % { 'u': config.chars_upper, 'l': config.chars_lower, @@ -542,13 +546,6 @@ name = groups.get('word_name') parent_prefix = groups.get('word_parent_prefix') current_page = self.formatter.page.page_name - # check for parent links - # !!! should use wikiutil.AbsPageName here, but setting `text` - # correctly prevents us from doing this for now - #if parent_prefix: - # name = '/'.join([x for x in current_page.split('/')[:-1] + [name] if x]) - #elif name.startswith(self.CHILD_PREFIX): - # name = current_page + '/' + name[self.CHILD_PREFIX_LEN:] name = wikiutil.AbsPageName(self.request, current_page, name) # if a simple, self-referencing link, emit it as plain text if name == current_page:
--- a/MoinMoin/wikiutil.py Tue Aug 21 15:47:56 2007 +0200 +++ b/MoinMoin/wikiutil.py Tue Aug 21 16:35:54 2007 +0200 @@ -847,7 +847,7 @@ while context and pagename.startswith(PARENT_PREFIX): context = '/'.join(context.split('/')[:-1]) pagename = pagename[PARENT_PREFIX_LEN:] - pagename = '/'.join(filter(None, [ context, pagename, ])) + pagename = '/'.join(filter(None, [context, pagename, ])) elif pagename.startswith(CHILD_PREFIX): if context: pagename = context + '/' + pagename[CHILD_PREFIX_LEN:]