#14133 closed enhancement (fixed)
Patch to allow WikiExtrasPlugin to work with Trac 1.6
Reported by: | Dan | Owned by: | Dan |
---|---|---|---|
Priority: | normal | Component: | WikiExtrasPlugin |
Severity: | normal | Keywords: | patch |
Cc: | clemens | Trac Release: | 1.6 |
Description
I am attaching a patch to allow the plugin to work with 1.5.4.
I think this is a fun plugin, though I don't consider myself a power user.
Attachments (1)
Change History (11)
Changed 3 years ago by
Attachment: | wikiextrasplugin_py3_trac154.patch added |
---|
comment:1 Changed 3 years ago by
Owner: | changed from Mikael Relbe to Ryan J Ollos |
---|---|
Status: | new → accepted |
comment:3 Changed 3 years ago by
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
comment:4 Changed 3 years ago by
Owner: | changed from Ryan J Ollos to Dan |
---|
comment:5 Changed 11 months ago by
Trac Release: | → 1.6 |
---|
comment:6 Changed 3 months ago by
I suspect there is a TRAC 1.6 (Python 3) regression with the popular WikiExtrasPlugin. After upgrading from TRAC 1.4 to 1.6 the handling of delimiters adjacent to a phrase seems affected.
Here is a quote of what WikiExtrasPlugin advertises, and what is
accomplished in code with method add_style
in file phrases.py:
Any delimiter
():<>
adjacent to a phrase will not be presented. This makes it possible to naturally writeFIXME:
, for example, but view the phrase highlighted without the colon (:) which would not look natural.
However, in TRAC 1.6 for a phrase like FIXME:
the colon is not removed, but it should be. For dual colons e.g. :FIXME:
both colons are removed, which is correct.
In TRAC 1.4, all colons in FIXME:
as well as in :FIXME:
are removed.
comment:7 Changed 3 months ago by
On the mailing list Jun Omae wrote on 08.08.2024 at 01:49:
That is caused by the generated regular expression from the plugin. The longer symbols in (...|...|...) of the regular expression should come first.
Please try the following patch:
[[[ Index: tracwikiextras/util.py =================================================================== --- tracwikiextras/util.py (revision 18650) +++ tracwikiextras/util.py (working copy) @@ -35,7 +35,7 @@ unicode = str def prepare_regexp(d): - syms = sorted(d.keys(), key=lambda a: len(a)) + syms = sorted(d.keys(), key=lambda a: len(a), reverse=True) return "|".join([r'%s%s%s' % (r'\b' if re.match(r'\w', s[0]) else '', re.escape(s), ]]]
comment:8 Changed 3 months ago by
The above patch works well. Great! Thanks, Jun.
Using reverse=True
inside prepare_regexp
seems to cure the issue. I just tested this with TRAC 1.6.
SVN-blame tells us:
The affected line 38 in util.py has been recently edited in 2022 (revision r18475) with the objective to make this plug-in compatible with Python 3.
comment:9 Changed 3 months ago by
Cc: | clemens added |
---|
Patch to work with Python 3.