I want to be able to use abbreviations and acronyms when I edit a tiddler but then have them show as the full text when viewing. Of course I can create a macro for this, but then my TW will be littered with these macro calls. Is there a way to have the text expanded and the result saved? Would be best if done with little ceremony. E.g. maybe &TW&
gets expanded to TiddlyWiki
with a configuration to add new abbreviations (vs. creating a macro for each)
you could use the linkify macro to call the tiddler titled “TW”, and have it view the field “caption”
You can find it here, I replaced linkify() with !!() just so I don’t have to type as much, but that’s a matter of preference, you could change it to be <<$$ TW>>
As far as using &“TiddlerAbbriviation”&, you would have to make your own parsing wikitext(I think that is what it is called?) which isn’t something I’m sure how to do, it is something I am trying to currently learn as well.
Right, I can do it with <<linkify mcr>>s, but then every time I want to call a <<linkify TW>> <<linkify mcr>>, I’ll need to use a <<linkify mcr>> call which will make my text littered with <<linkify mcr>> calls, where all I want is to put it once and then on saver for the TiddlyWiki body to become just a normal text with no macro calls.
Hm, I’m not sure I can help with this, I don’t know of a method of doing that with Tiddlywiki.
There are numerous way to implement such things with TiddlyWiki here are a few;
- Create an editor toolbar button to support this
- Parse tiddlers and convert content from one form to another
- Build smart transclusion or macros that support your objective
- Consider Mario’s Custom Wiki text solution (perhaps overkill in this situation)
- Use existing tools like Marios uni-link or alias plugin ← Sounds like the best bet here
- use other tools that allow predictive text based editing and automation
- New features coming in TW 5.2.4+ may help here as well.
- Such as custom widgets and operators
I think I know a way to avoid to write &TW&
at all.
Eg: If there would be a keyboard shortcut, that shows a list of “text templates”. So you only have to type eg: CTRL-6 t
… where the text associated with “t” would be: TiddlyWiki
. … The last shortcut used will be remembered. So CTRL-6 Enter
will always use the last text template used.
The boilerplate texts have to be defined once. … One “set of text templates” can handle 36 templates. … There can be as many sets as you want. … switching between sets can be done in the same dropdown.
Interesting! So do you have something working, or just an approach ?
Well, I was hoping to find a mechanism. Something along the lines of MediaWiki’s substitution. I think what this means is there needs to be some markup that is evaluated when the tiddler is saved (vs. the current markup that is evaluated when it is viewed). I think such a mechanism can be useful for other things as well (e.g. update other tiddlers on save)
In my all-button-actions solution you can write additional actions to perform on tiddler save, and this is where you could trigger a parsing process. I think such a feature would be useful as a general facility however;
If the basic task is to insert reusable content, expand short hand or insert template text there are many different possibilities but first consider the following;
- Why expand and update the text field when this can just expand it during render?
- Consider leaving it in the shorthand state
- When in “shorthand you can alter what it is rendered into” at a later time thus updating all references to that shorthand in one hit
- If you do not like the look of you shorthand to can make new ones with Mario’s custom markup plugin but you can choose other methods as well, with access to the rendering engine.
- There are already a lot of tools that provide rapid insert of content into the editor, some already in the editor toolbar but other solutions also exist.
- With the SideBar open it is trivial to have a tab containing a list of prepared content by name eg; “my address” and with a tiddler in edit mode simply drag and drop it into the editor to have it expanded immediately.
- This can also be a way to drag a macro call as well eg
<<myaddress>>
that expands to my full address using content in a myaddress tiddler, I can modify and its gets updated everywhere.
- This can also be a way to drag a macro call as well eg
If we return to the original post, the expansion is being requested to avoid the use of the macro in the text when reading it. It is possible to use a content preview to see the coded and expanded versions at one time however, I can see a generic solution could be as follows;
Imagine if we had a special rendering mode that during render the content that is a result of a macro, or widget was highlighted and you could click to edit the macrocall, or click to save the rendered version in place of the macrocall? Other functions and features could be implemented on each and every element that the special rendering mode made visible.
- This would be a hybrid wysiwyg / editor.
- This would support the development of tools where tiddler content could be developed by inserting or dragging and dropping content modules eg; drop a “fancy quote block” on the tiddler in view template and click to paste the quote you copied.
Existing partial solutions
- I have a drop text here zone on tiddlers to add content
- You can setup a button or link or DraggableWidget to have a payload that can be dropwd on or into the editor.
- Mohammad’s Edit section plugin lets you edit sections defined by heading levels, from the view template.
- You can make custom buttons that copy content to the OS clipboard or custom clipboard tiddlers for pasting into the editor
- On windows 11 (at least) Windows+V gives you a popup with the current and past copies from which you can selectively paste. Tiddlywiki’s copy to clipboard action can prefill this clipboard with multiple entries if you want.
It’s finished, but it’s part of a bigger project and it would need to be extracted into it’s own plugin.
@Ittayd: You might want to have a look at some tool that is specialized for that, like https://www.autohotkey.com/.
With that it is very straightforward to define simple text replacements. This way, every time you’d type “&tw&” it would immediately get replaced by e.g. “TiddlyWiki”.
The drawback is that you’d have to install another (small) program on the machine that you use for editing (and sync the abbreviation list if you use more than one machine – but then you’d need to sync you wikis anyway).
I use it all the time in TW, e-mail and more.
Have a nice day
Yaisog
I think, it depends on the amount of text that is substituted. If several tiddlers contain a lot of the same text I personally would like to transclude it, so it can be updated in 1 place and catches all of them.
I think there is a plugin, that can do some substitution, but I can’t remember the name