[pmwiki-users] Single Space breaks wrap on entire page

John Rankin john.rankin at affinity.co.nz
Thu Sep 22 17:58:15 CDT 2005


On Friday, 23 September 2005 1:19 AM, Hans <design at softflow.co.uk> wrote:
>how can I replace all empty space characters at the beginning of
>a paragraph with &nbsp; ?
>
>Example:
>   text text text text text text
>
>will become
>&nbsp;&nbsp;&nbsp;text text text text text text
>
>This will produce an indented first line, as the author intended with
>his empty spaces.
>
>Best, 
>~Hans                           

You can do this several ways, depending on what you want to achieve:

     Markup('^ ', '<block',
       '/^(\\s+)/e',
       "str_repeat('&nbsp;',strlen('$1'))");

This turns the spaces into non-breaking ones.

Or you could be a bit more sophisticated and note that the convention 
when indenting the first line of a paragraph is to use one em space.
Then you might do:

     Markup('^ ', '<block',
       '/^(\\s+)/','&emsp;');

Or you could of course use a <p class ='firstlineindent'> approach
via css.

What would you want to do if some paragraphs are indented 5 spaces
and some are indented 3? Is the number of spaces significant in
your context?

Hope this helps

-- 
JR
--
John Rankin






More information about the pmwiki-users mailing list