Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.


Is there any way to get PmWiki to honor line breaks in the markup text--i.e., so that all text on separate lines in the markup displays on separate lines in the output?


By default, PmWiki wraps consecutive lines of text together. For example, the markup


gets displayed as

one two three

Adding the line

    $HTMLLineBreak='<br />';

to a local customization file will cause PmWiki to honor linebreaks, so that the above markup would be displayed as

<#>? one two three

In addition, the following lines will add [[linebreaks]] and [[nolinebreaks]] markup, so that the behavior can be changed within a page.

    $DoubleBrackets['/\\[\\[linebreaks\\]\\]/e'] = 
      '$GLOBALS["HTMLLineBreak"]="<br />"';
    $DoubleBrackets['/\\[\\[nolinebreaks\\]\\]/e'] =

Thus, the markup


displays as

<#>one? two three <#>four? five six

Update: Note that one extra line is added in place of [[linebreaks]] tag. You can avoid this by writing a function in local/config.php like this:

    function setBr( $text ) {
      $GLOBALS["HTMLLineBreak"] = $text;
      return "";

And using it like:

    $DoubleBrackets['/\\[\\[linebreaks\\]\\]/e'] = 'setBr("<br />")';
    $DoubleBrackets['/\\[\\[nolinebreaks\\]\\]/e'] = 'setBr("")'; 



You can test this feature below.

<#>? I think I like this more than [[<<]]. I also think the "linebreaks" behaviour also is easier for new editors, don't you think? Most of them would expect a linebreak to work like a linebreak. A doubled linebreak then is a paragraph - just like it is displayed in the editarea. Difficult to change this default behaviour now though... -- Balu

Actually, opinion on this has split almost 50-50 since discussions first began in Summer 2003, with about half of respondents saying that PmWiki's default behavior is what they expect/want, and the other half saying they want it to work as described in this page. So it's not an obvious choice. --Pm

<#>My? experience is that the 'missing linebreaks' in the present default is indeed a stumbling stone for new users. So for new installations I think the automatic linebreak would be an improvement. What are the benefits of the present default that a linebreak default would not offer? -- HugoAlroe

<#>? The Text in the edit-mode and the text that appears at the end in the browser are always different in the way they are formatted. Because of this, a clear Text in the edit-mode dont says anything about the format in the browser.

In the Edit-Mode you should enter the Text and "logical" commands, linebreaks are only to keep the text clear in the edit-mode.

The Browser itself is responsible for formatting the text, you can only help him with this logical commands. Because you dont know anything about the fonts or the size or any preferences of the browser you cant help him with a linebreak.

If you visit this Text in the edit-mode, you can see that i use CR intensively :)

Unfortunately PmWiki dont use this mode for tables like LaTex do :( you must put one row in one line, without a chance to use CRs to make the whole thing a bit more clear in the edit-mode. Thats one of the first and IMHO biggest lacks of PmWIki.

My suggestion would be to use this mode for tables, too. --Bernd Schatz?

pmwiki-2.3.34 -- Last modified by {{DBS}}

from IP: ip should be disabled by default for security reasons