You are here: Foswiki>Tasks Web>Item11704 (11 Apr 2012, GeorgeClark)Edit Attach

Item11704: Document use of %BR% to create linebreaks in FormattedSearch results

pencil
Priority: Low
Current State: Closed
Released In: 1.1.5
Target Release: patch
Applies To: Engine
Component: Documentation
Branches: Release01x01 trunk
Reported By: RogerioBastos
Waiting For:
Last Change By: GeorgeClark
Hi,

In System/VarSEARCH say that default separator in formatted search is "$n". But when I define format parameter, this is not true.

These is the search expression and the generated HTML:

%SEARCH{ search="name ~ '*'" type="query" limit="10" format="$topic" }%

<a href="/Sandbox/CommentPluginExampleComments">CommentPluginExampleComments</a>
<a href="/Sandbox/CommentPluginExamples">CommentPluginExamples</a>
<a href="/Sandbox/CommentPluginTemplateExample">CommentPluginTemplateExample</a>
<a href="/Sandbox/CompareRevisionsAddOnDemoTopic">CompareRevisionsAddOnDemoTopic</a>
<a href="/Sandbox/ImagePluginTest">ImagePluginTest</a>
<a href="/Sandbox/PluginTestEmptyPlugin">PluginTestEmptyPlugin</a>
<a href="/Sandbox/RedirectPluginDestination">RedirectPluginDestination</a>
<a href="/Sandbox/RedirectPluginTest">RedirectPluginTest</a>
<a href="/Sandbox/SaveIt">SaveIt</a>
<a href="/Sandbox/TableEspinharas">TableEspinharas</a>

%SEARCH{ search="name ~ '*'" type="query" limit="10" separator="$n" format="$topic" }%

<a href="/Sandbox/CommentPluginExampleComments">CommentPluginExampleComments</a>
<a href="/Sandbox/CommentPluginExamples">CommentPluginExamples</a>
<a href="/Sandbox/CommentPluginTemplateExample">CommentPluginTemplateExample</a>
<a href="/Sandbox/CompareRevisionsAddOnDemoTopic">CompareRevisionsAddOnDemoTopic</a>
<a href="/Sandbox/ImagePluginTest">ImagePluginTest</a>
<a href="/Sandbox/PluginTestEmptyPlugin">PluginTestEmptyPlugin</a>
<a href="/Sandbox/RedirectPluginDestination">RedirectPluginDestination</a>
<a href="/Sandbox/RedirectPluginTest">RedirectPluginTest</a>
<a href="/Sandbox/SaveIt">SaveIt</a>
<a href="/Sandbox/TableEspinharas">TableEspinharas</a>

%SEARCH{ search="name ~ '*'" type="query" limit="10" format="$topic$n" }%

<a href="/Sandbox/CommentPluginExampleComments">CommentPluginExampleComments</a>
<p></p>
<a href="/Sandbox/CommentPluginExamples">CommentPluginExamples</a>
<p></p>
<a href="/Sandbox/CommentPluginTemplateExample">CommentPluginTemplateExample</a>
<p></p>
<a href="/Sandbox/CompareRevisionsAddOnDemoTopic">CompareRevisionsAddOnDemoTopic</a>
<p></p>
<a href="/Sandbox/ImagePluginTest">ImagePluginTest</a>
<p></p>
<a href="/Sandbox/PluginTestEmptyPlugin">PluginTestEmptyPlugin</a>
<p></p>
<a href="/Sandbox/RedirectPluginDestination">RedirectPluginDestination</a>
<p></p>
<a href="/Sandbox/RedirectPluginTest">RedirectPluginTest</a>
<p></p>
<a href="/Sandbox/SaveIt">SaveIt</a>
<p></p>
<a href="/Sandbox/TableEspinharas">TableEspinharas</a>
<p></p>
<div class="foswikiSearchResultCount">Number of topics: <span>10</span></div>
<p></p>

The last is the only that generate the expected result, but I think <p></p> strange.

-- RogerioBastos - 29 Mar 2012

Add separator="%BR%" circumvent the problem.

-- RogerioBastos - 29 Mar 2012

This was discussed in IRC and CrawfordCurrie had the answer ... now obvious once he explained it. In examples 1 and 2, the $n is indeed emitted by the SEARCH, as the results each are on a separate line in the HTML source. However it is rendered as a wrapped list because single newlines in Foswiki are not "breaking" and the browser wraps the lines together for display.

The 3rd example requests a "new paragraph" in Foswiki TML markup - two consecutive newlines, leaving a blank line. Foswiki Render currently creates paragraphs by creating an empty <p></p> paragraph. This is reported in task Item11316.

-- GeorgeClark - 29 Mar 2012

Updating the FormatTokens document to include:
$n or $n() New line. Use $n() if followed by alphanumeric character, e.g. write Foo$n()Bar instead of Foo$nBar
TIP Most macros accept parameter strings which are split over multiple lines. This is usually more readable than using $n tokens. If you are familiar with sectional includes, you might also consider nested sectional includes to hold the newline content outside of the parameter string entirely.
TIP Note that newline is not a line break. The browser will wrap the lines together. If you require a line break, displaying the results on two lines, use %BR%. Or use two consecutive newlines to create a TML "Paragraph".

-- GeorgeClark - 29 Mar 2012
 

ItemTemplate edit

Summary Document use of %BR% to create linebreaks in FormattedSearch results
ReportedBy RogerioBastos
Codebase 1.1.5 RC1, 1.1.4, 1.1.0, trunk
SVN Range
AppliesTo Engine
Component Documentation
Priority Low
CurrentState Closed
WaitingFor
Checkins distro:0dc70ba00aa4 distro:101df312e268
TargetRelease patch
ReleasedIn 1.1.5
CheckinsOnBranches Release01x01 trunk
trunkCheckins distro:101df312e268
Release01x01Checkins distro:0dc70ba00aa4
Topic revision: r8 - 11 Apr 2012, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy