Newlines and Formatted Search

first topic, than expression

SEARCH String:

%SEARCH{
    "NewlinesAndFormattedSearch" 
    scope="topic" 
    nonoise="on"
    format="[[$topic][Open]] $pattern(.*?([A-Z].*?[\n\r]+).*) "
}%

Result:

Open Newlines and Formatted Search

Open ELT-Department

Open KA-1

Question: Are there 2 line feeds behind a result?

Answer: [\n\r] is included inside the (parenthesis), so it includes the newline character(s) that may be found in the topic as a part of the pattern that is extracted. If you don't want the newlines, don't put parenthesis around them (parenthesis mark the bits of a pattern that you want to be extracted into the result)

Corrected version:

%SEARCH{
    "NewlinesAndFormattedSearch" 
    scope="topic" 
    nonoise="on"
    format="[[$topic][Open]] $pattern(.*?([A-Z].*?)[\n\r]+.*) "
}%

Result:

Open Newlines and Formatted Search Open ELT-Department Open KA-1


first expression, than topic

SEARCH String:

%SEARCH{
    "NewlinesAndFormattedSearch"
    scope="topic"
    nonoise="on"
    format="$pattern(.*?([A-Z].*?(([\n\r])+)).*)   [[$topic][Open]] "
}%

Result:

Newlines and Formatted Search Open ELT-Department Open KA-1 Open

Question: Where are the line feeds?

Answer: They are there, but in TML, you need two consecutive linefeeds to make a new paragraph. This is a problem that comes from displaying TML in HTML - HTML does not have a very strong sense of linefeeds; if you want one without creating a new paragraph, you must use <br/>.

Corrected version:

%SEARCH{
    "NewlinesAndFormattedSearch"
    scope="topic"
    nonoise="on"
    separator="<br/>"
    format="$pattern(.*?([A-Z].*?)[\n\r]+.*)   [[$topic][Open]] "
}%

Result:

Newlines and Formatted Search Open
ELT-Department Open
KA-1 Open


first expression, than topic, as bullet list

SEARCH String:

%SEARCH{
    "NewlinesAndFormattedSearch"
    scope="topic"
    nonoise="on"
    format="   * $pattern(.*?([A-Z].*?(([\n\r])+)).*)   [[$topic][Open]] "
}%

Result:

  • Newlines and Formatted Search Open
  • ELT-Department Open
  • KA-1 Open

Question: Why is it now OK?

Answer: The previous answer probably makes this clear: anyway, in TML, you only need one linefeed to separate bullet list items. So the bullets work fine in this example.


first expression, than topic, as table

SEARCH String:

%SEARCH{
    "NewlinesAndFormattedSearch"
    scope="topic"
    nosearch="on"
    header="| *Department* | *Topic* |"
    format="| $pattern(.*?([A-Z].*?(([\n\r])+)).*)  | [[$topic][Open]] |"
}%

Result:

Department Topic
| Newlines and Formatted Search
Open
| ELT-Department
Open
| KA-1
Open
Number of topics: 3

Question: Why no table?

Answer: Too many linefeeds smile You can't have linefeeds in the middle of a table. They may only be used to finish a table row. If you want linefeeds within a table cell, the newlines need to be converted to <br/>.

Here is a fixed version, which avoids extracting the newline characters:

%SEARCH{
    "NewlinesAndFormattedSearch"
    scope="topic"
    nosearch="on"
    header="| *Department* | *Topic* |"
    format="| $pattern(.*?([A-Z].*?)[\n\r]+.*)  | [[$topic][Open]] |"
}%

Result:

Department Topic
Newlines and Formatted Search Open
ELT-Department Open
KA-1 Open
Number of topics: 3

first expression, than topic, as table, expression ends in front of the line feed

SEARCH String:

%SEARCH{
    "NewlinesAndFormattedSearch"
    scope="topic"
    nosearch="on"
    header="| *Department* | *Topic* |"
    format="| $pattern(.*?([A-Z].*?(([^\n\r])+)).*)  | [[$topic][Open]] |"
}%

Result:

Department Topic
Newlines and Formatted Search Open
ELT-Department Open
KA-1 Open
Number of topics: 3

Question: No question, it works

Note: This one is different the other examples. It matches non-newline characters using [^\n\r] instead of previous patterns that used [\n\r]


expression as topic, expression with line feed

SEARCH String:

%SEARCH{
    "NewlinesAndFormattedSearch"
    scope="topic"
    nonoise="on"
    format="[[$topic][$pattern(.*?([A-Z].*?(([\n\r])+)).*)]]"
}%

Result:

[[NewlinesAndFormattedSearch][Newlines and Formatted Search ]] [[NewlinesAndFormattedSearchPortalElt][ELT-Department ]] [[NewlinesAndFormattedSearchPortalKa1][KA-1 ]]

Question: Why no function?

Answer: Linefeeds again. You can't have a

[[link with a
newline in it]]

You don't "see" the newline because in TML, single newlines are ignored - you only get new paragraphs if there are two consecutive newlines.

Here is a corrected version:

%SEARCH{
    "NewlinesAndFormattedSearch"
    scope="topic"
    nonoise="on"
    separator="<br/>"
    format="[[$topic][$pattern(.*?([A-Z].*?)[\n\r]+.*)]]"
}%

Result:

Newlines and Formatted Search
ELT-Department
KA-1


expression as topic, expression without line feed

SEARCH String:

%SEARCH{
    "NewlinesAndFormattedSearch"
    scope="topic"
    nonoise="on"
    format="[[$topic][$pattern(.*?([A-Z].*?(([^\n\r])+)).*)]]"
}%

Result:

Newlines and Formatted Search ELT-Department KA-1

Question: Why no line feed?

Answer: Again, in TML, single newlines are ignored. You must separate results with two linefeeds to generate separate paragraphs or use <br/>. Corrected version:

%SEARCH{
    "NewlinesAndFormattedSearch"
    scope="topic"
    nonoise="on"
    separator="<br/>"
    format="[[$topic][$pattern(.*?([A-Z].*?(([^\n\r])+)).*)]]"
}%

Result:

Newlines and Formatted Search
ELT-Department
KA-1

-- AndreasEllguth - 07 Apr 2010
Topic revision: r1 - 07 Apr 2010, PaulHarvey - This page was cached on 18 Jan 2018 - 01:04.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License