Mercurial > moin > 1.9
changeset 517:39da9e68875c
wikiutil.parseAttribute extension now must return a tuple (found_flag, errmsg), fixing table attr parsing
imported from: moin--main--1.5--patch-521
author | Thomas Waldmann <tw@waldmann-edv.de> |
---|---|
date | Wed, 29 Mar 2006 07:12:28 +0000 |
parents | ec330d9ec20b |
children | e779addaf39a |
files | ChangeLog MoinMoin/formatter/text_html.py MoinMoin/parser/wiki.py MoinMoin/wikiutil.py docs/CHANGES |
diffstat | 5 files changed, 44 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Mar 28 22:07:11 2006 +0000 +++ b/ChangeLog Wed Mar 29 07:12:28 2006 +0000 @@ -2,6 +2,21 @@ # arch-tag: automatic-ChangeLog--arch@arch.thinkmo.de--2003-archives/moin--main--1.5 # +2006-03-29 08:12:28 GMT Thomas Waldmann <tw@waldmann-edv.de> patch-521 + + Summary: + wikiutil.parseAttribute extension now must return a tuple (found_flag, errmsg), fixing table attr parsing + Revision: + moin--main--1.5--patch-521 + + wikiutil.parseAttribute extension now must return a tuple (found_flag, errmsg), fixing table attr parsing + + + modified files: + ChangeLog MoinMoin/formatter/text_html.py + MoinMoin/parser/wiki.py MoinMoin/wikiutil.py docs/CHANGES + + 2006-03-28 23:07:11 GMT Thomas Waldmann <tw@waldmann-edv.de> patch-520 Summary:
--- a/MoinMoin/formatter/text_html.py Tue Mar 28 22:07:11 2006 +0000 +++ b/MoinMoin/formatter/text_html.py Wed Mar 29 07:12:28 2006 +0000 @@ -1267,6 +1267,7 @@ result['style'] += s else: result['style'] = s + #self.request.log("_checkTableAttr returns %r" % result) return result
--- a/MoinMoin/parser/wiki.py Tue Mar 28 22:07:11 2006 +0000 +++ b/MoinMoin/parser/wiki.py Wed Mar 29 07:12:28 2006 +0000 @@ -638,7 +638,14 @@ # extension for special table markup def table_extension(key, parser, attrs, wiki_parser=self): + """ returns: tuple (found_flag, msg) + found_flag: whether we found something and were able to process it here + true for special stuff like 100% or - or #AABBCC + false for style xxx="yyy" attributes + msg: "" or an error msg + """ _ = wiki_parser._ + found = False msg = '' if key[0] in "0123456789": token = parser.get_token() @@ -653,6 +660,7 @@ msg = _('Expected an integer "%(key)s" before "%(token)s"') % { 'key': key, 'token': token} else: + found = True attrs['width'] = '"%s%%"' % key elif key == '-': arg = parser.get_token() @@ -662,6 +670,7 @@ msg = _('Expected an integer "%(arg)s" after "%(key)s"') % { 'arg': arg, 'key': key} else: + found = True attrs['colspan'] = '"%s"' % arg elif key == '|': arg = parser.get_token() @@ -671,16 +680,22 @@ msg = _('Expected an integer "%(arg)s" after "%(key)s"') % { 'arg': arg, 'key': key} else: + found = True attrs['rowspan'] = '"%s"' % arg elif key == '(': + found = True attrs['align'] = '"left"' elif key == ':': + found = True attrs['align'] = '"center"' elif key == ')': + found = True attrs['align'] = '"right"' elif key == '^': + found = True attrs['valign'] = '"top"' elif key == 'v': + found = True attrs['valign'] = '"bottom"' elif key == '#': arg = parser.get_token() @@ -691,16 +706,14 @@ msg = _('Expected a color value "%(arg)s" after "%(key)s"') % { 'arg': arg, 'key': key} else: + found = True attrs['bgcolor'] = '"#%s"' % arg - else: - msg = "" - #print "key: %s\nattrs: %s" % (key, str(attrs)) - return self.formatter.rawHTML(msg) + return found, self.formatter.rawHTML(msg) # scan attributes attr, msg = wikiutil.parseAttributes(self.request, attrdef, '>', table_extension) if msg: msg = '<strong class="highlight">%s</strong>' % msg - #print attr + #self.request.log("parseAttributes returned %r" % attr) return attr, msg def _tableZ_repl(self, word):
--- a/MoinMoin/wikiutil.py Tue Mar 28 22:07:11 2006 +0000 +++ b/MoinMoin/wikiutil.py Wed Mar 29 07:12:28 2006 +0000 @@ -928,8 +928,8 @@ Parse a list of attributes and return a dict plus a possible error message. If extension is passed, it has to be a callable that returns - None when it was not interested into the token, '' when all was OK - and it did eat the token, and any other string to return an error + a tuple (found_flag, msg). found_flag is whether it did find and process + something, msg is '' when all was OK or any other string to return an error message. @param request: the request object @@ -960,9 +960,13 @@ # call extension function with the current token, the parser, and the dict if extension: - msg = extension(key, parser, attrs) - if msg == '': continue - if msg: break + found_flag, msg = extension(key, parser, attrs) + #request.log("%r = extension(%r, parser, %r)" % (msg, key, attrs)) + if found_flag: + continue + elif msg: + break + #else (we found nothing, but also didn't have an error msg) we just continue below: try: eq = parser.get_token()
--- a/docs/CHANGES Tue Mar 28 22:07:11 2006 +0000 +++ b/docs/CHANGES Wed Mar 29 07:12:28 2006 +0000 @@ -40,6 +40,7 @@ Bugfixes: * fixed double class attribute for nonexistent links * fixed double </a> with qm_noexist option + * fixed table xxx="yyy" style attribute parsing Other changes: * moved back UserPreferences action link from menu to top of page (renaming