Neither example produces the expected output: the line starting with \end function marker shows up in the rendered output, regardless or having the name of the function or not:
\endmyfunc() function body
---
\end myfuncmyfunc() function body
Again, single-line functions — that is, those whose body is part of the same line as the \function name() — do not need and cannot use \end. \end is thus rendered as text because it isn’t parsed as the end of a multi-line pragma.
Finally I think I get it. So going back to the original code snippet in the other thread, if I want to keep the \end even for single line functions, I can just write
Besides me being a slow thinker and not paying enough attention to the relevant documentation tiddlers about functions and function pragma, I would like to point out that writing code directly in vanilla TiddlyWiki tends to emphasize these subtleties somehow vaguely, because there are no line numbers. I know I can get line numbers by adding the CodeMirror plugin to a wiki, but this solves just half of the problem - with preview pane open to see the live rendering, long lines (so filters especially, and transitively - functions too) tend to get wrapped. I’m hesitating to add CodeMirror to all my wikis, since this grows up single file wiki size and the performance impact is even bigger for encrypted wikis.
I understand the concern; some of the larger plugins can bloat your total file size very quickly!
If you have multiple single-file wikis in the same local folder and you’d like them all to use a certain set or subset of plugins, you may be interested in the External JS plugin, which lets you move the TW version core and, optionally, any plugins of your choice out of the HTML file and into a .js file that gets saved separately. This would let you keep a single copy of Code Mirror that could be used by all properly configured wikis.
I’ve been using this system for more than a year now, and it’s saved me a lot of space, particularly in my backup folder. It also makes it substantially faster to save changes to an external JS wiki, since the only tiddlers being saved to the HTML file are the ones you’ve created or modified yourself.
That’s the problem, they are in different locations, and they also travel often between multiple devices, so I have to keep them maximally independent and self-sufficient.
Yet I may need to give this suggestion additional thought (and hope that on Android browsers won’t refuse to directly load files from storage, like they sometimes do; this is premature and speculative, but I’ve seen something related to this in the past here in the forum).
I haven’t tested an external JS setup on a mobile device before, but I do regularly move wikis between folders and desktop machines, and I haven’t experienced any issues as long as each destination folder has a copy of the relevant JS file(s). If for some reason it doesn’t, all I have to do is add the JS file and then reload the wiki. I’d say it’s worth exploring if you’re regularly loading multiple wikis from the same location!
I have developed a certain level of scepticism when finding out that Firefox on Android won’t open a single html file wiki from storage, I would have to run a local webserver and access it by URL. Fortunately Tiddloid app is very stable and so far has been life saving.