Eric Forgeot writes:
  Markup ('txt2tags_bold', 'directives', '/\*\*(.*?)\*\*/', "'''$1'''");

It works but I get wrong output when having for example **this and **this, because this kind of text is not supposed to be marked as bold. (**this and** should be bold on the other hand)

So I modified my rule this way, to exclude white spaces before or after:

Markup ('txt2tags_bold' , 'directives', '/\*\*[^\s](.*?)[^\s] \*\*/' , "'''$1'''");

Now it almost works, **this and **this are not catched, but the bold parts are not correct, the first and last letters are striped out, for example **another** would become nothe (in bold). Do you know why, and how to correct this?

You need to place the parentheses around everything that is meant to be bold, for example '/\*\*([^\s].*?[^\s])\*\*/' .

However, this will not allow you a single bold character. This one will:

  '/\\*\\*(\\S(.*?\\S)?)\\*\\*/'

This means :
 - starts with a '**'
 - opening the first matched pattern (
 - then a non-whitespace-character \\S, same as [^\\s]
 - opening a second pattern (
   - .* anything, ending with a non-whitespace-character \\S
   - closing the second pattern )
   - the ? after the ) means the pattern is optional
 - closing the first matching pattern )
 - once again '**'.

This is fun :-)

Petko


_______________________________________________
pmwiki-users mailing list
[email protected]
http://www.pmichaud.com/mailman/listinfo/pmwiki-users

Reply via email to