Modify

Opened 3 years ago

Closed 3 years ago

Last modified 3 months ago

#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)

wikiextrasplugin_py3_trac154.patch (9.3 KB) - added by Dan 3 years ago.
Patch to work with Python 3.

Download all attachments as: .zip

Change History (11)

Changed 3 years ago by Dan

Patch to work with Python 3.

comment:1 Changed 3 years ago by Ryan J Ollos

Owner: changed from Mikael Relbe to Ryan J Ollos
Status: newaccepted

comment:2 Changed 3 years ago by Ryan J Ollos

In 18475:

TracWikiExtras 1.3.2dev: Make compatible with Python 3

Refs #14133.

comment:3 Changed 3 years ago by Ryan J Ollos

Resolution: fixed
Status: acceptedclosed

comment:4 Changed 3 years ago by Ryan J Ollos

Owner: changed from Ryan J Ollos to Dan

comment:5 Changed 11 months ago by clemens

Trac Release: 1.6

comment:6 Changed 3 months ago by clemens

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 write FIXME:, 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 clemens

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 clemens

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 clemens

Cc: clemens added

comment:10 Changed 3 months ago by Jun Omae

In 18651:

TracWikiExtras 1.3.2dev: follow-up to r18475, sort longer phrases before shorter ones in regular expression for wiki syntax (refs #14133)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Dan.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.