I thought I had not tested my code, which is not the way to behave in this
forum. So I got to test it. And...
I was still WRONG !
I mean, I've come up with code that can output a wikitext fit for coding a
simple table. But no way to get the table rows... Even if my code is not
within a macro, the result is the same. What's wrong there?
The code (not in a macro):
|les <$count filter="[all[current]tagging[]butfirst[]]"/> critères liés aux
{{!!title}}|c
| Code | Tests|Énoncé|h
<$list filter="[all[current]tagging[]butfirst[]]"
variable="crit">|[[{{<$transclude tiddler=<<crit>>
field="code"/>!!code}}|<<crit>>>]]|<$countfilter="[tag<crit>]butfirst[]"
/>|<$transclude
tiddler=<<crit>> field="criterion"/>|
</$list>
The output (captured beween "pre" and "/pre"):
|les 2 critères liés aux cadres|c
| Code | Tests|Énoncé|h
|2.1|1|Chaque cadre a-t-il un titre de cadre ?|
|2.2|1|Pour chaque cadre ayant un titre de cadre, ce titre de cadre est-il
pertinent ?|
If I copy paste this out put, yes I have my table OK. But if I see the
output of my code within the tiddler it is written, I get the table headers
and title, and then the rows as raw text condensed within one line. Must be
a magic somewhere beyond my knowledge...
[image: bug-with-simple-table.png]
Le samedi 10 octobre 2020 à 08:37:14 UTC+2, Jean-Pierre Rivière a écrit :
> Thank you Eric. When I got up one hour ago, I got myself the revelations
> that I had done the error of using the \whitespace trim pragma error! So I
> immediatly corrected my macro, before anything else (including going here
> to check any answer).
>
> I got a way to produce the raw ouput I wanted. But it is not correctly
> rendered, even though by copying the output between pre and /pre I have the
> table output I want (that's shown at the bottom of the picture). Yes, I had
> to make some clever but ugly layout of the markup to achieve that goal of
> getting the raw text I needed.
>
> But the table was still not well rendered. Yet, as I copied the output
> within "pre" and "/pre" tags I used to check my code, I got my table right!
>
> And then I got the illumination :o)
>
> In my copied-text table, I had no links! Whereas I got them between the
> "pre" and "/pre" tags! That was just because, in fact, I was not looking at
> the wikintext code I would have coded manually. Which means that I would
> need to reproduce that code as a result of my macro. Which would clutter
> the macro code. Way worse than using html for table as I've been told twice!
>
> SO I will obey your wise counsel and go for direct html table coding.
>
> However, here is the example code for getting a wiki text of a table (a
> simple wiki text with no links or other fancy stuff, including in what tou
> transclude (which was not hte case for the "criterion" filed in my case).
>
> \define listCriterions()
> |les <$count filter="[all[current]tagging[]butfirst[]]"/> critères liés
> aux {{!!title}}|c
> | Code | Tests|Énoncé|h
> <$list filter="[all[current]tagging[]butfirst[]]"
> variable="crit">|<$transclude
> tiddler=<<crit>> field="code"/>|<$count
> filter="[tag<crit>]butfirst[]" />|<$transclude
> tiddler=<<crit>> field="criterion"/>|
> </$list>
> \end
>
> The trick is to open the next widget after a pipe "|" at the end of a
> line, but to terminate that widget on the new line to avoid getting one
> very long line!
>
> Thank you all for your help! I've learnt a lot once again.
> Le samedi 10 octobre 2020 à 03:43:46 UTC+2, Eric Shulman a écrit :
>
>> On Friday, October 9, 2020 at 3:51:35 PM UTC-7, Jean-Pierre Rivière wrote:
>>>
>>> I have confirmation of a problem with end of line with macro rendering
>>> text, not with wiki parsing after the macro has done its job.
>>> simply surrond the macro call by pre and /pre tags. And behold below!
>>>
>>
>> Table syntax requires newlines to terminate each row. However, your
>> macro specifies "\whitespace trim",
>> which eliminates the newlines. Thus, your generated table output
>> becomes one long run-on line of text
>> and the "|" dividers are treated as literals.
>>
>> Wikitext table syntax can be very sensitive to subtle issues with
>> whitespace (e.g., a single
>> space character following the last "|" on a row will break the table
>> output. Also, as you've discovered,
>> you can't use <$list>...</$list> to generate rows with wikitext table
>> syntax, since the presence of the
>> widgets also breaks the table output.
>>
>> In general, when programmatically constructing complex table output, I
>> suggest using HTML table
>> syntax (i.e., table, caption, th, tr, td) instead of wikitext table
>> syntax, as it will permit much greater
>> flexibility and produce more controllable results.
>>
>> -e
>>
>>
>>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/1f60af0b-5afd-496f-9b24-b41e4527677en%40googlegroups.com.