Thanks for your complementary explanation about order, Tones, and you're 
quite right.
But as I wrote in a previous message, in that particular TW instance I am 
adamant that I won't change the field order.

Concatenating / Joining snippets of text from two fields in immutable 
order, while retaining Wikitext or HTML formatting or links is exactly what 
I want to do.

The basic example I gave earlier is thus:

if field1 contains: 'The cat is eating'
field2 might contain: ' a mouse.' or ' cat food.' (note the space),  or ', 
while the dog is playing.' or '.' (no space required before a full stop / 
period or a comma).

Actually I need that to reference sources for tiddler contents. It is a bit 
more complex because field1 is in the source tiddler, providing general 
info, whereas field2 is in the content tiddler, with references specific to 
that content.

As an example:
field1 in 'source' tiddler might contain: 'Doe, John. //My Great Book.// 
(2020)'
while field2 in 'excerpt' or 'content' tiddler might contain details such 
as: ', p. 22.' or ' — see chapter 8.' or '. John Doe develops that idea in 
the first 3 chapters.'
So the leading character in field2 might either be a period, a comma, a 
space, depending on how I wish to gracefully join the two parts 
punctuation-wise.
It is pretty similar to connecting words and parts of speech in a sentence.

What I have achieved so far works fine, except for the space trimming in 
the transclusion of field 2.

I first thought there would have been a more straightforward solution to 
that issue, but actually I come to think that it should be possible to 
inspect the first character in the contents of field 2:

If value of field2 starts with space, then insert ` ` between the 
transclusions, else just proceed with both transclusions.
But I don't think I have enough TW knowledge to do that, unfortunately.

Best,

Stéphane

Le dimanche 15 août 2021 à 15:22:31 UTC+2, TW Tones a écrit :

> I think you can have your cake and eat it, as long as you use the 
> tiddlywiki recipe/ingredients.
>
> First lets see if I can explain about order.
>
> If this was my first design (with space between them)
> <$transclude field="field1" /> <$transclude field="field2" />
>
> And I decided I wanted;
> <$transclude field="field2" /> <$transclude field="field1" />
>
>
>    - I modify the presentation in the above code, I do not need to modify 
>    my data, just its presentation. This may be happening inside a list widget 
>    for example.
>    - In your case you may need to change both the presentation and the 
>    data.
>
>
> Now, If I understand correctly you want to correctly treat the joining of 
> "snipits" found in fields correctly, you would be better served building 
> some standards for your data and tools to do the joining. Since there are 
> already implied standards for handling those values lets adopt them, then 
> if you can identify occasions where appending one snippet to the other by 
> separation with a space, is not working, let us detect and alter that case.
>
> In the original post I think you go down the path of altering the way they 
> are presented by modifying the data.
>
> *Could you give us some examples where you are finding it hard to join 
> such snippets?*
>
> I would suggest {{!!foo}}<space>{{!!bar}} for your first example (As did 
> Mario)
>
> Tones
>
> On Sunday, 15 August 2021 at 22:54:39 UTC+10 Misterel85 wrote:
>
>> Thank you for your replies, PMario, Joshua and Tones.
>>
>> @ Joshua: Thanks a lot for taking the time to write this comprehensive 
>> and clear explanation.
>>
>> I have followed your solution to insert `\whitespace notrim` at the 
>> beginning of a tiddler text, but unfortunately, it doesn't work.
>>
>> I also tried to place it into a macro like this:
>>
>> ```
>> \define mymacro()
>> \whitespace notrim
>> <$transclude field="field1" /><$transclude field="field2" />
>> \end
>> ```
>>
>> but in vain. In the documentation <https://tiddlywiki.com/#Pragma>, the 
>> default is set to 'notrim', so adding such an instruction in a macro is 
>> useless.
>>
>>
>> @ PMario:
>>
>> I am aware of the solution you provide, but inserting a normal or 
>> non-breakable space between the two transclusions is not an option.
>>
>> A very simplified example of what I would like to do is connecting two 
>> parts of something similar to a sentence together, but that sentence may 
>> not need a complement in the second part.
>> For instance:
>> if field1 contains: 'The cat is eating'
>> field2 might contain: ' a mouse.' or ' cat food.' (note the space), or 
>> '.' (no space required before a full stop / period).
>>
>> Your solution would always insert a space, even before a punctuation sign 
>> such as a period or a comma...
>>
>>
>>
>> @ Tones
>>
>> Your advice is worth following 'for standard use cases'. But what I wish 
>> to implement is probably not an ordinary one.
>>
>> You wrote:
>>
>>    - The spacing you wish is something best done in the display of the 
>>    data and not in the data, what if they changed order? 
>>
>>
>> I don't understand what you mean by 'what if they changed order?'.
>> What would change order? The data? The fields? No, I wouldn't need to 
>> change their order. See my example above. Why would I need the 
>> 'complementary' part of the data to show before the 'main' part?
>>
>> As for the spacing, it is an integral part of the data here (as a word 
>> separator within a sencence, for instance). Therefore putting it anywhere 
>> else in this case wouldn't be a wise choice.
>>
>>
>>    - A field containing a list of titles or tiddlers is typically space 
>>    delimited. So we often need the leading and trailing spaces not to be 
>>    included.
>>
>>
>> Sure, but that's not my use case. And 'often' is not 'always'! ;-)
>>
>>
>>    - You can access fields in a different way if you really need to have 
>>    leading or training spaces as part of the data
>>
>>
>> Well, that's exactly what I'm after!
>>
>>
>> > '{{{ [all[current]get[afield]] }}}'
>>
>> > The transcluded filter output demonstrates the field contains a leading 
>> space of it has one.
>>
>> That filter output is interesting. But it doesn't render HTML tags or 
>> Wikitext, contrary to $transclude.
>> If 'afield' contains: ` This is <strong>my</strong> //field//. `, 
>> then 
>> '{{{ [all[current]get[afield]] }}}'
>> '<$text text={{{ [all[current]get[afield]] }}} />'
>> '<$view field=afield />'
>> all render raw text as: 
>> ' This is <strong>my</strong> //field//. '
>> whereas
>> '<$transclude field=afield/>'
>> renders as:
>> 'This is *my* *field*.'
>>
>> Seems that I have to trade in the leading space for formatting and 
>> vice-versa. Can't have my cake and eat it.
>>
>> Regards,
>>
>> Stéphane
>>
>>
>>

-- 
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/8ad060fe-7a06-446f-9523-d3131f586ab4n%40googlegroups.com.

Reply via email to