Tags:
usability1Add my vote for this tag create new tag
view all tags

Feature Proposal: Underscore WikiWords without Syntax Change

Follow-up on UnderscoreWikiWords.

Motivation

TWiki's link syntax has been established early on and any change will cause major problems for existings installations. Still we want readable, humanized links - no geeky syntax such as WikiWord when in fact wiki word is meant. But what would be possible if underscores are used only under the hood?

Let's take Mediawiki's link syntax as an example:

London has [[public transport]].
will link to the page Public_transport. Writing [[Public_transport]] will create the link Public_transport.

This syntax cannot just be copied; TWiki has its own spaced out wiki word interpretation:

Go to the homepage at [[web home]].
becomes:

Go to the homepage at web home
(this links to WebHome)

TWiki's translation of "web home" to WebHome works fine, but the other way around may cause problems. And all-capitals is not always desirable. There should be a way to preserve the spaces and lowercase spelling as intended at topic creation.

This can be achieved by allowing underscores inside bracket notation. In fact, there is nothing in TWiki that prevents doing this right now. For instance, just create the topic Life_outside_of_work. Only the topic will not be auto-linked. In cases where users are instructed to use double bracket notation in preference to WikiWord notation - as is the case with Mediawiki - this will cause no problems. A bonus is that topic names can be copied from the url and pasted to a link.

But we don't want to keep the underscores when rendered. They should stay under the hood. So this proposal is not about relaxing wikiword syntax, but about rendering underscores.

Proposal

Keep TWiki's link syntax as is.

  1. Render underscores inside bracket link notation as spaces.
  2. For all topic references that are not a link (for example in the breadcrumb): upgrade SPACEOUT to render underscores as spaces. For instance: %SPACEOUT{"%TOPIC%" underscoretospace="on"}%

Examples

When realised:

  • Life_outside_of_work would stay: Life_outside_of_work
  • [[Life_outside_of_work]] would become: Life outside of work
  • [[OurFuncs][our_funcs]] would stay: our_funcs
  • %SPACEOUT{"Life_outside_of_work" underscoretospace="on"}% would become: Life outside of work

Impact and Available Solutions

Proposal sub 1

Insert in Render.pm line 491:
# Render underscores as spaces
$theLinkText =~ s/_/ /g;

Proposal sub 2

Insert in TWiki.pm line 3281:
my $underscoreToSpace = $params->{'underscoretospace'} || '';
$spaceOutTopic =~ s/_/ /go if $underscoreToSpace eq 'on';

Implementation

-- Contributors: ArthurClemens

Discussion

Isn't this what the renderWikiWordHandler is for, and is quite well suited to.

While it was not implemented to work inside the square brackets, I have previously made that work, quite trivially, by moving where the Handler is called in Render.pm.

(I have not commited it, because I have not found out why Martin didn't do so in the first place, and because I didn't find sufficient unit tests to give me confidence to proceed).

-- SvenDowideit - 01 Apr 2007

Perhaps renderWikiWordHandler can be called from internalLink.

-- ArthurClemens - 02 Apr 2007

I like this proposal, it's compatible and makes links look nicer.

-- PeterThoeny - 03 Apr 2007

The rendering of underscores as spaces inside brackets must for sure not include the [[ConfigOptionVideoDevice][video_device]] type of syntax because in this case I do really want the _ rendered as _ and not as a space.

But showing [[hello_darling]] with spaces is probably not going to be a big issue for anyone.

-- KennethLavrsen - 06 Apr 2007

Perhaps renderWikiWordHandler can be called from internalLink.

yes, unfortuantly I've always assumed that Martin did not do so because it caused a problem. as Time passes here, with no-one speaking up, I'm going to move towards doing this simple one line move for FreeTownRelease.

-- SvenDowideit - 06 Apr 2007

The question is:

  • Should this be assumed behavior by TWiki Core code or should it only be done in a plugin?
  • At what point are plugins able to override? At this time the only plugin that calls renderWikiWordHandler is SpacedWikiWordPlugin

-- ArthurClemens - 06 Apr 2007

I think I've implemented about 4 custom plugins for different clients, all of which have subtly different requirements from the one you are asking for. So I vote for plugin - Additionally, I personally don't care for your choice, which biases me further towards plugins :).

-- SvenDowideit - 06 Apr 2007

I've implemented this now in SpacedWikiWordPlugin.

I think it now only needs to be documented in a SupplementalDocument.

-- ArthurClemens - 05 May 2007

Edit | Attach | Watch | Print version | History: r13 < r12 < r11 < r10 < r9 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r13 - 2007-05-05 - ArthurClemens
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.