[pmwiki-users] Fixme icon

Petko Yotov 5ko at 5ko.fr
Mon Dec 2 11:16:27 PST 2019


On 02/12/2019 14:28, Robert Riebisch wrote:
> The following works for me, but I'm not sure about the number of
> backslashes in: \\(:fixme:\\)
> 
>  Markup('fixme', 'directives', '/\\(:fixme:\\)/i',
>    "$PubDirUrl/fixme.gif\"fixme\"");
> 
> Does the number depend on the usage of ' or "?
> I had look at "scripts/stdmarkup.php", but still don't have a clue.

Your backslashes are fine.

If you have one literal backslash in a string, like you did to escape 
parentheses in a regular expression:

* in single quotes you can use both a single backslash (unless it is the 
last character of the quoted string, or unless the next character is a 
single quote, a digit, or "x" followed by a digit)

** OR you can safely double the backslash like you did

* in double quotes, you may be able to use a single backslash unless the 
next character is among nrtevf0\$" or x or u followed by digits, and it 
is not the last character of the quoted string,

** OR you can safely double the backslash.

As you see, in all cases, single or double quotes, with any following 
character, you can safely double the literal backslash, so this is what 
I do.

For example, a common error in PHP configuration on Dos/Windows 
(including PmWiki) is when the path to something is enclosed in double 
quotes and the backslashes are not escaped (doubled) like:

   $Something = "C:\LAMPP\htdocs\test\new\fixme.gif";

Both the \t, the \n and the \f will be expanded to something and will 
break the path.

See https://www.php.net/manual/en/language.types.string.php for more 
information.

BTW there are 2 more types of strings, HEREDOC and NOWDOC but I suggest 
reading the PHP documentation and the changelog if you use them because 
there are changes from one PHP version to another.

Petko




More information about the pmwiki-users mailing list