Using your excellent suggestion I rewrote one section of the links
function to look like this:
if (strpos($x, "|") !== false) {
list($link,$label,$attrs) = explode('|',$x,3);
$link = trim($link);
$label = trim($label);
$attrs = trim($attrs);
$args= BOLTargs($attrs, 'links');
foreach($args as $f => $v) {
if (! in_array($f, BOLTattrs('link'))) continue;
if (ereg('/[\'#0-9a-zA-Z]+/', $v)) continue;
$attr .= " $f='$v' ";
}
$attr = str_replace('xmllang', 'xml:lang', $attr);
if (isset($args['js'])) $attr = " " . $BOLTlinkJs[$args['js']]
. " $attr" ;
}
It definitely looks better (simpler, clearer) and seems to work fine.
I'll put in the next release and keep our fingers crossed it doesn't
cause any problems!
Cheers,
Dan
On Fri, Oct 24, 2008 at 8:20 AM, alinome.net <[EMAIL PROTECTED]> wrote:
>
> When there are one or more spaces after a link label, one space is
> included in the link if there are additional attributes:
>
> [[page | no spaces included ]]
> [[page | one space included | title='aoeu aoeu aoeu']]
> [[page | one space included | title='aoeu aoeu aoeu']]
>
> It seems a second trim() is needed in BOLTMlinks because of an if
> structure:
>
> if (strpos($x, "|") !== false) {
> $link = substr($x, 0, strpos($x, "|"));
> $label = trim(substr($x, strpos($x, "|") + 1));
> if ($label == '') $label = $link;
> elseif (strpos($label, '|') !== false) {
> $attrs = stripslashes(substr($label, strrpos($label,
> '|') + 1));
> $label = trim(substr($label, 0, strrpos($label,
> '|'))); // TRIM
> ADDED
>
> Another option (to prevent future bugs because of additional if
> structures) is to add the following line:
>
> $label = trim($label);
>
> after the current line:
>
> $link = trim($link);
>
> I'm tinkering deeply with the BOLTMlinks function. I think I will be
> able to make it simpler, faster and more legible, with less control
> structures (in general, they make code harder to debug and modify).
> I.e., the link components can be extracted right at the start with no
> control structure, what saves code later:
>
> list($link,$label,$attrs) = explode('|',$x,3);
> $link = trim($link);
> $label = trim($label);
> $attrs = trim($attrs);
>
> $label = empty($label) || $label=='=' ? $link : $label;
>
> if (!empty($attrs)) {
>
> At the same time I'll try to implement my idea about optional non-
> links for missing pages. There are some points I don't understand in
> the code, so I will need some help.
>
> Regards,
>
> Marcos
>
> --
> http://alinome.net
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"BoltWire" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/boltwire?hl=en
-~----------~----~----~----~------~----~------~--~---