Where do the surplus closing tags come from?

In my experiments I sometimes see surplus closing tags like </div> in the output. If I just delete one in the code the outcome looks good but the code looks as if there are open tags.

It works but I do not underrstand why it does.

Does the list widget auto-close tags like <div>?

closed-tag-code:

\procedure color-examples(color)
<div class="multicolcontainer">
	<$list filter="red blue green violet white brown yellow gold">
		<$set name="color" value=<<currentTiddler>>
			<div style="break-inside:avoid;">
				<svg width="150" height="100">
  					<circle cx="100" cy="50" r="40" stroke="black" stroke-width="2" fill=`$(color)$` />
				</svg>
				''<<color>>''
			</div>
		</$set>
	</$list>
</div>
\end

<style>
	.multicolcontainer {
  	column-width: 13em;
  	column-rule: 1px solid #ccc;
	}
</style>


<<color-examples>>
Result with surplus tags

opened-tag-code:

\procedure color-examples(color)
<div class="multicolcontainer">
	<$list filter="red blue green violet white brown yellow gold">
		<$set name="color" value=<<currentTiddler>>
			<div style="break-inside:avoid;">			
				<svg width="150" height="100">
  					<circle cx="100" cy="50" r="40" stroke="black" stroke-width="2" fill=`$(color)$` />
				</svg>
				''<<color>>''
			
		</$set>
	</$list>
</div>
\end

<style>
	.multicolcontainer {
  	column-width: 13em;
  	column-rule: 1px solid #ccc;
	}
</style>


<<color-examples>>
Result with *open tags* in code

You are missing a closing “>” in this line:

<$set name="color" value=<<currentTiddler>>

Also, note that instead of writing:

<$list filter="red blue green violet white brown yellow gold">
	<$set name="color" value=<<currentTiddler>>>

You could just write:

<$list filter="red blue green violet white brown yellow gold" variable="color">

and omit the $set widget entirely.

-e

1 Like

Autoclosure may occur at the end of a tiddler in some cases but unless you know exactly it is unwise, in part because if you add code or move your code into a macro or procedure they do need to balance.

If you are tiring of closures write a macro or procedure instead.

I have long sought a method to detect and or highlight all braces and unclosed tags / widgets, perhaps in a preview. Problems in mismatched opens and closes are the majority of syntax errors I see. They are fragile because they break with single character errors and a common symptom is no output.

  • I may raise this in the developer forum.
1 Like

Thank you @EricShulman!
As always a solution and a hint above.

I realy have to teach my eyes that three of a kind is symmetry…

@TW_Tones I can imagine and have read that matching tags is tiring. I am just at the beginning of scripting…
I also read that code is fragile and tags must be closed. TiddlyWiki seams to be robust in a way. I can “fix” the output of an error with a second error. There was a “nice” ouput. I don’t know if it leakes problems to other tiddlers. That is why I wanted to close the tag and wanted to undersatnd what happened and asked. I guess there are “some” places in my Wiki that are “double-error-fixed”. Here the list widget works, although the opening tag was uncomplete and I could “cover it up” by leaving the whole tag open without an error message.
An open-tag-detector sounds reasonable.