Page MenuHomePhabricator

New parser function for reversing order of characters
Closed, DeclinedPublic

Description

Author: abxabx

Description:
Hi! I would like to have available (mainly for wiktionaries) function {{#reverse:SOME_TEXT}} which returns given text in reversed order of characters:

Examples:
{{#reverse:SOME_TEXT}} -> TXET_EMOS
{{#reverse:bugfix}} -> xifgub
{{#reverse:black dog}} -> god kcalb

Purpose:
I want to have indexes (categories) sorted according to characters placed at the end of page name (or at the end of any given text). I want to write [[Category:English words|{{PAGENAME}}]] for normal category as usually and [[Category:English words (a tergo)|{{#reverse:{{PAGENAME}}}}]].

Rationale:
Classic dictionaries have extra bonus called "index a tergo". That's index where terms are places according to the end of term. Words like "comeback", "hatchback", "playback" are next to each other. In such index North America, South America and Central America and all cities of the world named America are together. This is handy for ethymologists when they look for words with same postfix but also for users who do not remember begining of the term.

ABX


Version: unspecified
Severity: enhancement

Details

Reference
bz17999

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 21 2014, 10:33 PM
bzimport added a project: ParserFunctions.
bzimport set Reference to bz17999.
bzimport added a subscriber: Unknown Object (MLST).

Would it be really useful? I would rather think of writing something like [[Special:SuffixIndex]], working like [[Special:PrefixIndex]].

abxabx wrote:

[[Special:PrefixIndex]] AFAIK doesn't allow browsing categories and browsing categories (ie. only one language) according to postfix is what makes value of such index for single language specialists. There is already field for postfix in [[Special:AllPages]] hovewer this also doesn't allow selection of single category.

(In reply to comment #1)

Would it be really useful? I would rather think of writing something like
[[Special:SuffixIndex]], working like [[Special:PrefixIndex]].

That couldn't be done for performance reasons.

wclark wrote:

Parser function to implement string reversal

attachment reverse ignored as obsolete

wclark wrote:

Comment on attachment 5998
Parser function to implement string reversal

stupid eclipse... wtf is with the character encoding nonsense and .buildpath

wclark wrote:

Cleaner patch to implement string reversal parser function

This one will probably still contain character encoding nonsense but is missing the stupid eclipse .buildpath file

attachment patch.txt ignored as obsolete

overlordq wrote:

Clean patch

Another thing to note is that strrev clobbers multibyte characters.

Hopefully this fixes both issues.

Attached:

It should be noted that due to the potential for abuse, we're at least wary of (possibly flat-out opposed to) new parser functions with the intention of providing string manipulation abilities in wikitext.

I should warn you that it is possible (even likely) that this patch will sit waiting for review for another few years, until we figure out which direction we are going with respect to string manipulation in wikitext.

joystick.pl wrote:

It's very easy to implementation. <bdo dir="rtl">SOME_TEXT</bdo> view: TXET_EMOS. Unfortunately, now tag <bdo> is blocked.

Between adding a suffix index (which may or may not ever be feasible, but is certainly covered by other bugs), adding <bdo> (which might be covered under the expand allowed HTML list bug), I can't see a huge use case here. Partially because of the reasons I mentioned, and partially because of comment #8, I'm going ahead and being bold with a WONTFIX.