Tags:
create new tag
view all tags

Question

MartinCleaver_: I have a table, inside of the cells of which are includes. Performing the include seems to instruct TWiki to stop the table

[10:31am] MartinCleaver: I want the included data IN the table
[10:32am] xored: To stop the table means, that the HTML code is broken or what does that mean ?
[10:32am] MartinCleaver: it means TWiki emits a /table
[10:32am] MartinCleaver: it fact, it emits a /tr /tbody /table
[10:32am] MartinCleaver: does the include
[10:33am] MartinCleaver: and then starts a table tbody tr td after the include
[10:33am] det_re joined the chat room.
[10:34am] xored: Cant help you with that sorry
[10:34am] xored: not using TML tables at all
[10:34am] MartinCleaver: It's as if the INCLUDE is processing
[10:34am] • MartinCleaver reads VarINCLUDE
[10:35am] MartinCleaver: thanks anyway xored
[10:35am] MartinCleaver: INCLUDE raw didn't help
[10:38am] • MartinCleaver curses
[10:45am] You left the chat by being disconnected from the server.
[10:46am] You rejoined the room.
[10:48am] det_re_ left the chat room. (Read error: 110 (Connection timed out))
[10:55am] MartinCleaver: seems to be the <br/> in the include that breaks the table
[10:55am] &#8226; MartinCleaver wonders why

[11:10am] MartinCleaver: y, if the included topic has <br>line1</br><br>line2</br><br>line3</br> instead of line1<br/>line2<br/>line3</br> the table does not break
[11:10am] MartinCleaver: its because it thinks br/ is unmatched
[11:10am] MartinCleaver: which is not true.

Environment

TWiki version: TWikiRelease04x02x00
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: Debian
Web server: Apache
Perl version:  
Client OS:  
Web Browser:  
Categories:  

-- MartinCleaver - 13 May 2008

Answer

ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.

TextFormattingRules says "Recommendations when using HTML: Use XHTML 1.0 Transitional syntax".

That page says "Empty elements must either have an end tag or the start tag must end with />. For instance, <br/> or <hr></hr>."

In other words, <br/> is supposed to be supported by TWiki, so it sounds like a bug.

-- SeanCMorgan - 13 May 2008

Sorry, but I doubt that it is a bug. The actual, and not always easy task is to keep an exact track of linefeeds, which are critical to TWiki's table rendering (as well as for lists). As far as I can say TWiki does not care for <br> elements, whether unbalanced or not.

Consider the following single line:

%INCLUDE{"%TOPIC%" section="includedtable"}%

This is an INCLUDE tag followed by a line feed. When the INCLUDE tag is processed, it is replaced by whatever it points to, from the opening to the closing percent character. *The line feed remains as it is*.

So, if whatever you include in such a way ends with a line feed, you end up with two consecutive line feeds. Two consecutive line feeds will break the table. And a list. And will break paragraphs.

I'd always assume that TWiki topics end with a line feed, and if I recall correctly TWiki enforces this if you edit a topic without a line feed at its end. But the situation is even more tricky with named sections, like the following:

%STARTSECTION{"brokensection"}%
|  m11  |  m12  |
|  m21  |  m22<br>broken  |
|  m31  |  m32  |
%ENDSECTION{"brokensection"}%

This section ranges from the closing percent sign of the STARTSECTION tag up to the opening percent sign of the ENDSECTION tag. It starts with a line feed, and it ends with a line feed.

Better, and more consistent with included topics, is to always make sure that a named block starts without a newline. The most readable way, in my opinion, is to disable the line feed with a backslash \:

%STARTSECTION{"bettersection"}% \
|  m11  |  m12  |
|  m21  |  m22<br>better  |
|  m31  |  m32  |
%ENDSECTION{"bettersection"}%

Now let's proceed to the INCLUDE tag itself. Since we know that the block, or topic, to be included will end with a line feed, the easiest thing is to disable the line feed by again appending a backslash to the include line:

| *column 1* | *column 2* |
%INCLUDE{"%TOPIC%" section="bettersection"}% \
|  just another line  ||
%INCLUDE{"%TOPIC%" section="bettersection"}% \
|  want a footer, too?  ||

This renders as:

column 1 column 2
m11 m12
m21 m22
better
m31 m32
just another line
m11 m12
m21 m22
better
m31 m32
want a footer, too?

Yes, it is a bit tricky. But not trickier as it needs to be, since for other use cases INCLUDE makes perfect sense if and only if it keeps the line feeds. Stray spaces and line feeds have been nerdy since the decades of TeX, through the Template Toolkit (which also has a special syntax to gobble trailing line feeds), and TWiki is no exception.

-- HaraldJoerg - 13 May 2008

As a sidenote, for proper XHTML and browser compatibility use %BR% or <br /> (including space).

-- PeterThoeny - 13 May 2008

Change status to:
Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2008-05-13 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.