r2 - 28 May 2002 - 20:48:11 - PeterThoenyYou are here: TWiki >  Support Web > ExtractSingleParagraph
Tags:
, create new tag

Question

For some reason extractions using formatted search that has CR or NL spoils the rendering of tables if you use them in the format field.

To avoid this I´ve been trying to extract a single parragraph out of a twiky page. The paraghaph will start with a known word. Se the following text:


Author: Miguel de Cervantes.
Comment: This is actually a second "text" line but it is rendered by Twiky as a single paragraph. 

TWiki will render it as follows.

Author: Miguel de Cervantes. Comment: This is actually a second text line but it is rendered by Twiky as a single paragraph.


The goal is to extract a "Text paragraph" (see source text) for example to get "Miguel de Cervantes." upon querying "Author:" in the search text. (No CR nor NL at the end of the extraction). Please note that "Commnet:" might not be the next word, so I can not use it as a extractor delimiter. The stractor delimiter should be [\n\r]*.

I know that this kind of extraction might be easier if I use Twiki forms, and or somehow marking-up the start and the end of the text of interest.

  • TWiki version: Sept 2001
  • Web server: Apache
  • Server OS: Linux
  • Web browser: IE
  • Client OS: Windows 98

-- AntonioVega - 27 May 2002

Answer

Each TWiki table row needs to be on one line, this is spec. If you build a table with a formatted search you need to make sure not to include new lines.

Try this:

%SEARCH{ "Miguel de Cervantes" header="| Author | Comment |" format="| $pattern(.*?[\n\r]Author\: ([^\n\r]*).*) | $pattern(.*?[\n\r]Comment\: ([^\n\r]*).*) |" }%

To get this:

Search: Miguel de Cervantes

Author Comment
Miguel de Cervantes. This is actually a second "text" line but it is rendered by Twiky as a single paragraph.
Number of topics: 1

-- PeterThoeny - 28 May 2002

Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r2 < r1 | More topic actions
 
Powered by TWiki
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback SourceForge.net Logo