TiddlyWiki5
TiddlyWiki5 copied to clipboard
Empty Define breaks subsequent macros
If in a tiddler one does this
\define empty-macro() \define valid-macro() any content \define multi-line-macro() Content of valid macro \end
The empty-macro will cause the remainder of the tiddlers macro definitions not be recognised.
This is hard to debug, so could we fix the "fault" caused by empty macros?
Thanks Tony
You are right. The empty-macro()
is not recognized in the right way. The parse-tree looks like this:
[
{
"type": "set",
"attributes": {
"name": {
"type": "string",
"value": "empty-macro"
},
"value": {
"type": "string",
"value": "\\define valid-macro() any content\n\n\\define multi-line-macro()\nContent of valid macro"
}
},
If you add a character "." to the empty-macro it works as expected.
\define empty-macro() .
\define valid-macro() any content
\define multi-line-macro()
Content of valid macro
\end
[
{
"type": "set",
"attributes": {
"name": {
"type": "string",
"value": "empty-macro"
},
"value": {
"type": "string",
"value": "."
}
},
What's the purpose of the empty-macro
?
The empty macro is never something I intended to do but it has happened a few times as I have tried to build more complex macros. When macros are used as variables I try and define them so they can be referenced inside another macro but sometimes I slip up.
It would never be a problem if it was not so easy to overlook and the symptoms quite odd.
It would just be nice if it failed more gracefully if not with a message.
Regards Tony
The empty macro is never something I intended to do but it has happened a few times as I have tried to build more complex macros.
Yes, this happens to me too. I think it is a matter of personality (scattered multi-tasking vs focussed).
duplicate of: Bug: empty macro definitions don't parse as expected #3460
Close in favour of the duplicate #3460 but I hope it is addressed. Another use case is coding with the output preview displayed. In some cases this can give invalid values and generate list of all tiddlers and other time consuming artifacts.
This seems like a different issue than #3460. I created a PR for it at #7911 and it does not address this issue.
To me, the OP looks like a set of valid nested macros:
\define empty-macro()
\define valid-macro() any content
\define multi-line-macro()
Content of valid macro
\end
How can the above be distinguished from nested macros (empty-macro
is the outer macro terminated by the \end
)?
I believe the rule is to nest "macros" you need to name the outer macros in the \end
Your example does not use this suggested approach, but still works. but possibly not in all cases.
- You don't have an empty macro, you have a parent macro.
\define empty-macro()
\define valid-macro() any content
\define multi-line-macro()
Content of valid macro
\end multi-line-macro
this is not empty it is a parent.
\end empty-macro
<<empty-macro>>
- In fact you must close the parent macro or and multiline inner macros otherwise it is ambiguous.
However I would also point out you are using the deprecated \define macro
not the current \procedure
or very useful \function
or the new custom \widgets
.
Note that this Issue was raised in AnthonyMuscio opened this issue on Jun 25, 2019
- A few years now.
But the problem remains is still not resolved in two cases;
\define empty-macro()
\end
\define empty-macro()
\end
The above will "break" subsequent macros.
And the same happens with the new \procedure
s as well.
The rule is to nest "macros" you need to name the outer macros in the \end
Your example does not use this suggested approach, but still works. but possibly not in all cases.
- You don't have an empty macro, you have a parent macro.
\define empty-macro()
\define valid-macro() any content
\define multi-line-macro()
Content of valid macro
\end multi-line-macro
this is not empty it is a parent.
\end empty-macro
<<empty-macro>>
- In fact you must close the parent macro or and multipline inner macros otherwise it is ambiguous.
However I would also point out you are using the deprecated \define macro
not the current \procedure
or very useful \function
or the new custom \widgets
.
Note that this Issue was raised in AnthonyMuscio opened this issue on Jun 25, 2019
- A few years now.
But the reason is still not resolved in two cases;
\define empty-macro()
\end
\define empty-macro()
\end
The above will "break" subsequent macros. including for \procedure
s
Hi @btheado as @AnthonyMuscio says, I think the example in the OP is missing an \end
. As far as I can tell it is processed exactly as expected.
But the reason is still not resolved in two cases;
@AnthonyMuscio that's the issue in #3460 which remains unfixed at the moment.