I like the fact that I can create a link with custom title using <#123>custom title syntax, but I'm curious why it uses < and > rather than [ and ] like all of the other linodef tags do. This causes problems when using rich text editors because they'll try to convert <> to HTML entities. I propose making the syntax something like
[#123]custom title[/#], or if that won't work, maybe [#123 custom title] or [#123 title="custom title"] or something like that. Anything to make it more consistent with the other tags and avoid using greater-than/less-than signs with their HTML escaping problems.

Comments

Roi Danton’s picture

Status: Active » Needs work
StatusFileSize
new13 KB

Then the WYSIWYG editor has a bad HTML tag recognition since no HTML tag begins with #. ;) But nevertheless you're right - Linodef has to heed such cases so it'd be better if it'll use tag options for this instead of <#232>, e.g. [#232,linktext="custom text"] as you propose.

For this I have to change the regex to support spaces (and all other characters except ") in tag option values enclosed by ": \[#([0-9a-zA-Z_]+),((?:[0-9a-zA-Z]*(?:="[^"\]\r\n]*")*,*)*) ([^\]\r\n]+)\]. That way you can also link to terms and views with a custom linktext. Currently this regex doesn't work in all cases so this still needs work.

Roi Danton’s picture

StatusFileSize
new14.11 KB

Reason for the failure of the patch in #1 was that the regex engine has been stressed too much.

The new version is smarter than all the others before. Furthermore with those modifications the regex search for tag comments needs much less performance than before.

However, things to heed now:

  • always close the " otherwise the following tag options will be treated as tag comment
  • you can't use the character " in your text, e.g. for [#232,tid,linktext="custom text with "direct speech""] the result would be custom text with "direct
  • currently you can't use , and ] inside "", but I'll try to solve that
  • translation=en won't work with RC3 anymore, use translation="en" instead
tonycpsu’s picture

Hi Roi,
Thanks so much for implementing this. The one problem I'm seeing with the patch is that the link text retains the quotation marks. i.e, if I have a tag like [#123,linktext="foo"], the resulting output is "foo" with the quotes printed. Shouldn't the quotes be stripped from the output?

Otherwise, this looks great to me.

tonycpsu’s picture

I'm also seeing what looks like a debug print statement at the top of each page. Probably something you're already aware of, but just in case, I thought I'd mention it.

Roi Danton’s picture

StatusFileSize
new14.49 KB

Ah thanks, I've forgot to delete the debug line.

Quotation marks are now removed before tag is processed. Advantage: Old tags (translation=en) still works. Disadvantage: In messages it says translation=en even if translation="en" has been entered.

Now you may use the , inside "" area. It won't be possible to use ] or " (by design).

Roi Danton’s picture

Status: Needs work » Needs review
tonycpsu’s picture

Works great. Thanks again!

Roi Danton’s picture

Status: Needs review » Fixed

Upgraded help and committed to Drupal 6 branch.

tonycpsu’s picture

Status: Fixed » Needs work

One minor glitch I just noticed is that it seems to be putting an extra space after the link. For example, the following:

Click [#123,linktext="here"]!

is being output as:

Click <a href="/node/123">here</a> !

Not the most important thing in the world, but something I noticed and thought might be worth fixing.

Roi Danton’s picture

Status: Needs work » Fixed

Thx for reporting! This space was added to every tag (Browsers just ignore several spaces in HTML therefore I hadn't recognized it). Now the space will only be added if an inline message is shown.

Bugfix committed to D6 branch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.