1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2026-06-17 18:58:52 +00:00

Compare commits

..

248 Commits

Author SHA1 Message Date
jeremy@jermolene.com 8816efa737 Restore standard sitetitle 2023-04-19 11:51:32 +01:00
jeremy@jermolene.com 093274f0fa Remove custom CI step for this branch 2023-04-19 11:51:21 +01:00
jeremy@jermolene.com 3b3879df03 Update 5.3.0 release note 2023-04-19 11:35:25 +01:00
jeremy@jermolene.com 55e38eb89a Update modification times of doc tiddlers
So that they are at the top of the recent tab
2023-04-19 11:32:34 +01:00
jeremy@jermolene.com b91872bed1 Merge branch 'master' into parameterised-transclusions 2023-04-18 10:48:39 +01:00
jeremy@jermolene.com f41051b621 Merge branch 'master' into parameterised-transclusions 2023-04-12 17:11:38 +01:00
jeremy@jermolene.com 3689171198 Merge branch 'master' into parameterised-transclusions 2023-04-10 16:07:54 +01:00
jeremy@jermolene.com a2cbb6f992 Merge branch 'master' into parameterised-transclusions 2023-04-06 16:11:54 +01:00
jeremy@jermolene.com 5b271bb4f4 Fix nonstandard initialisation code for fill/parameter/slot widgets 2023-04-06 08:50:47 +01:00
jeremy@jermolene.com bb2dea2414 Remove 5.2.8 release note 2023-04-02 14:42:39 +01:00
jeremy@jermolene.com 7ba666bd53 Merge branch 'master' into parameterised-transclusions 2023-04-02 14:00:47 +01:00
jeremy@jermolene.com cff3db6eaa Merge branch 'master' into parameterised-transclusions 2023-03-26 08:29:41 +01:00
jeremy@jermolene.com 8c98fc4ab1 Merge branch 'master' into parameterised-transclusions 2023-03-21 08:08:18 +00:00
jeremy@jermolene.com e2cc32aa75 Merge branch 'master' into parameterised-transclusions 2023-03-18 16:04:20 +00:00
jeremy@jermolene.com f9751f19b6 Merge branch 'master' into parameterised-transclusions 2023-03-12 16:19:30 +00:00
jeremy@jermolene.com 2a2939f4eb Merge branch 'master' into parameterised-transclusions 2023-03-10 09:10:27 +00:00
jeremy@jermolene.com f417bdb742 Merge branch 'master' into parameterised-transclusions 2023-03-06 09:06:41 +00:00
jeremy@jermolene.com ea055f2ba5 Merge branch 'master' into parameterised-transclusions 2023-02-28 08:45:56 +00:00
jeremy@jermolene.com 0d1667c467 Merge branch 'master' into parameterised-transclusions 2023-02-10 16:04:08 +00:00
jeremy@jermolene.com 86569e5ade Merge branch 'master' into parameterised-transclusions 2023-01-30 21:43:00 +00:00
jeremy@jermolene.com 1dea0a03b8 Merge branch 'master' into parameterised-transclusions 2023-01-30 09:43:54 +00:00
jeremy@jermolene.com 59895db097 Merge branch 'master' into parameterised-transclusions 2023-01-23 16:36:56 +00:00
jeremy@jermolene.com 683414f51e Fix positional parameters in widget.evaluateVariable()
This should clear up the remaining anomalies in #7009, let me know how you get on @btheado
2023-01-23 16:34:08 +00:00
jeremy@jermolene.com 34afe4e143 Refactor function invocation
* Introduce new widget helper function to evaluate variables.Functions are evaluated as parameterised filter strings, macros as text with textual substitution of parameters and variables, and procedures and widgets as plain text
* Refactor the function operator and unknown operator to use the new helper
* Use the new helper to evaluate variables within filter strings, thus fixing a bug whereby functions called in such a way were being returned as plain text instead of being evaluated
* Refactor the transclude widget to use the new helper
* Update tests
2023-01-21 22:07:34 +00:00
jeremy@jermolene.com d4ab427ceb Refactor wikified function tests 2023-01-21 21:04:43 +00:00
jeremy@jermolene.com a62d7f1b0d Merge branch 'master' into parameterised-transclusions 2023-01-21 20:45:21 +00:00
jeremy@jermolene.com 66cf779abb Merge branch 'master' into parameterised-transclusions 2023-01-18 09:05:48 +00:00
jeremy@jermolene.com 81002f9f30 Merge branch 'master' into parameterised-transclusions 2023-01-17 16:40:47 +00:00
jeremy@jermolene.com 923f9084f8 New test missed off a45349cc99 2023-01-11 09:15:40 +00:00
jeremy@jermolene.com a45349cc99 Fix detection of empty transclusions
See https://talk.tiddlywiki.org/t/exploring-default-tiddler-links-hackability-in-v5-3-0/5745/25?u=jeremyruston
2023-01-11 08:57:54 +00:00
jeremy@jermolene.com 7a4a8bd3f6 Rename test 2023-01-07 09:41:39 +00:00
jeremy@jermolene.com 4f96465141 Merge branch 'master' into parameterised-transclusions 2023-01-07 09:34:11 +00:00
jeremy@jermolene.com 76e3a341da Merge branch 'master' into parameterised-transclusions 2022-12-21 17:26:10 +00:00
jeremy@jermolene.com 34bd0f0ae5 Merge branch 'master' into parameterised-transclusions 2022-12-13 17:31:51 +00:00
jeremy@jermolene.com 34ce7cacc3 Merge branch 'master' into parameterised-transclusions 2022-12-13 11:08:54 +00:00
jeremy@jermolene.com 2bf9e97eb5 Merge branch 'master' into parameterised-transclusions 2022-12-08 08:29:56 +00:00
jeremy@jermolene.com be65819441 Docs note about nested macro definitions 2022-12-07 10:01:58 +00:00
jeremy@jermolene.com 5bb7168c02 Merge branch 'master' into parameterised-transclusions 2022-12-07 10:01:38 +00:00
jeremy@jermolene.com 31f4c1f6af Merge branch 'master' into parameterised-transclusions 2022-12-05 17:21:33 +00:00
jeremy@jermolene.com b802b0cb09 Merge branch 'master' into parameterised-transclusions 2022-11-27 13:56:33 +00:00
jeremy@jermolene.com b5e4b21707 Merge branch 'master' into parameterised-transclusions 2022-11-27 12:40:51 +00:00
jeremy@jermolene.com 52592a4dbc Add support for named end markers for procedures, functions and widgets 2022-11-23 16:30:20 +00:00
jeremy@jermolene.com b78f8769a9 Docs: move tiddlers to correct directory 2022-11-23 16:27:39 +00:00
jeremy@jermolene.com 39d88bf156 Docs: Update \define pragma to cover named ends 2022-11-23 09:02:39 +00:00
jeremy@jermolene.com 778b8dec7f Merge branch 'master' into parameterised-transclusions 2022-11-23 09:01:42 +00:00
jeremy@jermolene.com 45958db074 Merge branch 'master' into parameterised-transclusions 2022-11-22 16:29:45 +00:00
jeremy@jermolene.com 846edbfaa4 Merge branch 'master' into parameterised-transclusions 2022-11-16 08:27:00 +00:00
jeremy@jermolene.com 4e3566745e Merge branch 'master' into parameterised-transclusions 2022-11-15 11:46:04 +00:00
jeremy@jermolene.com 70930e16b2 Merge branch 'master' into parameterised-transclusions 2022-11-15 10:39:29 +00:00
jeremy@jermolene.com 149d6c2d73 Docs: clarify function operator invocation
See discussion at https://github.com/Jermolene/TiddlyWiki5/issues/6991#issuecomment-1301703599
2022-11-05 10:13:35 +00:00
jeremy@jermolene.com 478b585a8c Merge branch 'master' into parameterised-transclusions 2022-11-02 08:21:17 +00:00
jeremy@jermolene.com 9029588b2c Merge branch 'master' into parameterised-transclusions 2022-10-30 21:21:48 +00:00
jeremy@jermolene.com 38ac1e4bfd Merge branch 'master' into parameterised-transclusions 2022-10-30 21:21:21 +00:00
jeremy@jermolene.com e7caa0c739 Docs typo
Thanks @twMat
2022-10-30 21:17:55 +00:00
jeremy@jermolene.com 9f42007899 Filter run prefixes should use widget.makeFakeWidgetWithVariables 2022-10-25 14:13:38 +01:00
jeremy@jermolene.com b426724f35 Fix macrocall refresh issue
It turns out that this.transcludeTitle is always truthy, even if we are transcluding a variable

Fixes #7001
2022-10-20 15:08:05 +01:00
jeremy@jermolene.com ffc2594fef Add parenthesis to the visible transclusion definition
Parenthesis were made mandatory in 5194b24108

Fixes #6998
2022-10-19 15:35:43 +01:00
jeremy@jermolene.com c171c441f5 Update release note 2022-10-19 09:42:41 +01:00
jeremy@jermolene.com 33de634606 Adjust modified times of docs tiddlers to make them easier to find 2022-10-19 09:15:38 +01:00
jeremy@jermolene.com 120b93c242 New test for undefined parameters 2022-10-19 08:37:27 +01:00
jeremy@jermolene.com 14e0a271d4 New New Release Banner 2022-10-19 08:37:04 +01:00
jeremy@jermolene.com bc375c04b9 Temporary new release banner for v5.3.0 2022-10-19 08:14:29 +01:00
jeremy@jermolene.com 55c7eea52d Add release note etc for 5.3.0 2022-10-18 17:40:13 +01:00
jeremy@jermolene.com 45f1cf6cff Attempt to build this branch with CI 2022-10-18 17:27:47 +01:00
jeremy@jermolene.com 32710ef9e6 Merge branch 'master' into parameterised-transclusions 2022-10-18 17:23:57 +01:00
jeremy@jermolene.com 5194b24108 Parameter parenthesis should be mandatory in function/procedure/widget definitions
See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1280404387
2022-10-17 08:31:07 +01:00
jeremy@jermolene.com 3a4589dc79 Transcluding functions: fix missing parameters passed as undefined
Thanks @btheado – see https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1276187372
2022-10-12 17:15:39 +01:00
jeremy@jermolene.com 76bc3a7358 Docs typo
https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r990811220

Thanks @btheado
2022-10-09 17:48:24 +01:00
jeremy@jermolene.com 85a203bcf2 Revert modified date of docs that have only had minor tweaks 2022-10-09 17:43:38 +01:00
jeremy@jermolene.com c25129584c Docs updates 2022-10-09 17:34:22 +01:00
jeremy@jermolene.com 1c73460ecc Fix doc file locations 2022-10-09 13:56:36 +01:00
jeremy@jermolene.com ef93fc29bf More docs updates 2022-10-09 13:54:33 +01:00
jeremy@jermolene.com 9d4aa47356 Clarify/simplify some tests 2022-10-09 13:54:08 +01:00
jeremy@jermolene.com 12a87840fd Merge branch 'master' into parameterised-transclusions 2022-10-07 16:57:54 +01:00
jeremy@jermolene.com dcbff82460 Docs updates 2022-10-07 16:56:21 +01:00
jeremy@jermolene.com 6be996a858 Docs update 2022-10-06 21:37:14 +01:00
jeremy@jermolene.com bf41e08c2f Revert change to setwidget docs 2022-10-06 10:30:40 +01:00
jeremy@jermolene.com 9641345b92 Docs updates 2022-10-03 14:40:27 +01:00
jeremy@jermolene.com 93100a1c8f Remove support for conditional definitions
It was introduced for use cases associated with the global mechanism that was dropped in e3d13696c8
2022-10-03 14:39:45 +01:00
jeremy@jermolene.com b6796863e8 Merge branch 'master' into parameterised-transclusions 2022-10-01 14:05:54 +01:00
jeremy@jermolene.com 0a309f4865 Merge branch 'master' into parameterised-transclusions 2022-10-01 10:18:34 +01:00
jeremy@jermolene.com 668168dfea Some widget.js cleanups 2022-09-27 08:58:10 +01:00
jeremy@jermolene.com 502a1ab70d Merge branch 'master' into parameterised-transclusions 2022-09-27 08:56:58 +01:00
jeremy@jermolene.com 109edd1b76 Docs update 2022-09-24 15:09:12 +01:00
jeremy@jermolene.com d950835e2f Docs clarification 2022-09-24 15:05:54 +01:00
jeremy@jermolene.com a482f01352 Merge branch 'master' into parameterised-transclusions 2022-09-24 14:08:44 +01:00
jeremy@jermolene.com e3d13696c8 Remove implementation of $:/globals/
Performance with this implementation is inherently poor because of the need to perform a wiki lookup for each child widget created.
2022-09-24 12:56:06 +01:00
jeremy@jermolene.com 1aba8a1f65 Slight optimisation to user defined widgets 2022-09-24 12:41:28 +01:00
jeremy@jermolene.com fddaa9fdb1 Merge branch 'master' into parameterised-transclusions 2022-09-24 11:07:53 +01:00
jeremy@jermolene.com 0c88467111 Merge branch 'master' into parameterised-transclusions 2022-09-22 10:35:01 +01:00
jeremy@jermolene.com c3589357bf Huge Documentation Update
Not quite finished, but definitely on the home stretch
2022-09-21 10:41:03 +01:00
jeremy@jermolene.com 0196844f17 Merge branch 'master' into parameterised-transclusions 2022-09-21 09:33:24 +01:00
jeremy@jermolene.com 6847906bea Docs typo 2022-09-16 16:33:04 +01:00
jeremy@jermolene.com fe6186b1c1 Docs update 2022-09-16 16:07:58 +01:00
jeremy@jermolene.com 3090bb104e Fix visible transclude 2022-09-16 16:07:44 +01:00
jeremy@jermolene.com 8f9d5cabaa Missing tests for parameters widget 2022-09-16 16:07:32 +01:00
jeremy@jermolene.com fa86631d2e Improve indentation
See https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r967655251
2022-09-13 16:29:09 +01:00
jeremy@jermolene.com ef677c39c0 Docs tweaks 2022-09-11 10:57:35 +01:00
jeremy@jermolene.com a3ba6f9370 Tests and docs for function operator 2022-09-11 10:49:02 +01:00
jeremy@jermolene.com cc7b276787 Remove negation from function operator
This implementation was not useful.
2022-09-11 10:48:37 +01:00
jeremy@jermolene.com 68a1d61f33 Update function operator to return the input list if the function is missing 2022-09-11 10:48:05 +01:00
jeremy@jermolene.com ecd467496d Add custom view template body for globals, and a new sidebar tab under "more"
And also a custom view template title that greys out the $:/global/ part of the title
2022-09-10 11:03:40 +01:00
jeremy@jermolene.com 580e33d30f Merge branch 'master' into parameterised-transclusions 2022-09-10 11:01:45 +01:00
jeremy@jermolene.com 977a133028 Tweak comments 2022-09-09 14:16:08 +01:00
jeremy@jermolene.com 7aba21c1be Docs updates 2022-09-09 14:15:56 +01:00
jeremy@jermolene.com 32a6b6bb90 Docs updates 2022-09-09 12:05:08 +01:00
jeremy@jermolene.com b751f7e793 Parameters widget: protect against negative $depth 2022-09-09 12:04:50 +01:00
jeremy@jermolene.com 82b22523aa Rejig genesis widget to be easier to use 2022-09-09 10:37:39 +01:00
jeremy@jermolene.com e3697e29bb When transcluding functions, pass an empty item list to the filter, and just return the first item 2022-09-09 10:22:06 +01:00
jeremy@jermolene.com 7b465888c8 Revert "WIP"
This reverts commit 8654dfc679.
2022-09-04 16:43:40 +01:00
jeremy@jermolene.com 8654dfc679 WIP 2022-09-04 16:41:25 +01:00
jeremy@jermolene.com 5c860ed39b Fix error in 25312b3e32 2022-09-04 16:26:47 +01:00
jeremy@jermolene.com 25312b3e32 Refactor filter recursion detection to avoid an unneeded wrapper function 2022-09-04 16:23:49 +01:00
jeremy@jermolene.com 11e0c66a4c Transcluded functions should operate on the entire store 2022-09-03 20:11:45 +01:00
jeremy@jermolene.com a439cb58be Fix caching of parse variables/macros/procedures 2022-09-03 20:11:23 +01:00
jeremy@jermolene.com 966707ea1c More comments 2022-09-03 16:57:38 +01:00
jeremy@jermolene.com 1b08cd40bf Coding style tweak 2022-09-03 16:36:36 +01:00
jeremy@jermolene.com 00b6645c94 Disable overriding core widgets in safe mode 2022-09-03 12:58:10 +01:00
jeremy@jermolene.com f6ee0cdf4c Add test to show that global widgets need not use the _parameters field 2022-09-03 12:57:45 +01:00
jeremy@jermolene.com 36058cba89 Merge branch 'master' into parameterised-transclusions 2022-09-03 10:55:29 +01:00
jeremy@jermolene.com 389330436d Revert changes to parse tree preview
This implementation requires #6666
2022-09-03 10:52:34 +01:00
jeremy@jermolene.com 15ea3ffa9a Remove tests related to obsolete changes to boot.js
Should have been part of 2f494ba152
2022-09-02 20:10:11 +01:00
jeremy@jermolene.com bf4a187ee1 Fix inadvertent whitespace change 2022-09-02 20:05:24 +01:00
jeremy@jermolene.com 2f494ba152 Revert obsolete changes to boot.js 2022-09-02 20:03:33 +01:00
jeremy@jermolene.com f0fa1af3a8 Merge branch 'master' into parameterised-transclusions 2022-09-02 18:17:32 +01:00
jeremy@jermolene.com d852123f61 Tweak semantics of JSON operators to match #6932
This allows us to later bring in the optimisations without breaking backwards compatibility.
2022-09-02 17:14:50 +01:00
jeremy@jermolene.com 54e1083dd6 Merge branch 'master' into parameterised-transclusions 2022-09-01 09:00:57 +01:00
jeremy@jermolene.com 2b8b133d4a Merge branch 'master' into parameterised-transclusions 2022-08-17 18:11:21 +01:00
jeremy@jermolene.com 9317804464 FIx transcluding of functions
This first implementation concatenates the results of the filter (with no separator) and then wikifies the result.

The test in this commit is quite interesting...
2022-08-04 09:28:56 +01:00
jeremy@jermolene.com 6207ec4812 Merge branch 'master' into parameterised-transclusions 2022-08-02 17:49:28 +01:00
jeremy@jermolene.com 0366d6d7ba Merge branch 'master' into parameterised-transclusions 2022-07-21 10:11:23 +01:00
jeremy@jermolene.com b1cf9f241e Merge branch 'master' into parameterised-transclusions 2022-07-21 10:10:49 +01:00
jeremy@jermolene.com 17c9bf7546 Protect against excessively recursive functions 2022-07-21 09:17:57 +01:00
jeremy@jermolene.com 745707fea3 Parameters widget: Be defensive about negative depths 2022-07-19 10:27:36 +01:00
jeremy@jermolene.com d4e0eb193b Slot widget: be more defensive about negative depth values 2022-07-19 10:26:20 +01:00
jeremy@jermolene.com a2182255cc Simplify the fill widget
We can rely on the default processing in the base class
2022-07-19 10:02:09 +01:00
jeremy@jermolene.com 7d90083d14 Docs: Transclude widget 2022-07-18 19:44:53 +01:00
jeremy@jermolene.com 30f7b37cba Make use of type attribute consistent 2022-07-18 19:44:37 +01:00
jeremy@jermolene.com 189fe428b7 Merge branch 'master' into parameterised-transclusions 2022-07-04 21:15:42 +01:00
jeremy@jermolene.com 945c9e619a Merge branch 'master' into parameterised-transclusions 2022-06-22 08:51:46 +01:00
jeremy@jermolene.com 6e1138e504 Merge branch 'master' into parameterised-transclusions 2022-06-17 16:40:54 +01:00
jeremy@jermolene.com cdf5d7bd4a Fix new selection tracker to return relative coordinates 2022-06-16 17:00:20 +01:00
jeremy@jermolene.com 05d2c029a4 Merge branch 'master' into parameterised-transclusions 2022-06-14 08:34:47 +01:00
jeremy@jermolene.com 4e6efed58f Revert "Fix #6721"
This reverts commit b216579255 which was committed to the wrong branch
2022-06-14 08:34:42 +01:00
Jeremy Ruston b216579255 Fix #6721 2022-06-13 15:43:28 +00:00
jeremy@jermolene.com 3e33d309ed Docs: format:json
Also tweak to the behaviour of format:json if the input string is not valid JSON
2022-06-11 17:29:20 +01:00
jeremy@jermolene.com 688c3bc5f6 Docs: JSON operators and tweaks to genesis widget 2022-06-11 15:22:43 +01:00
jeremy@jermolene.com 227079f3da Add format:json operator
I've been finding this useful for debugging, and it kind of goes with the JSON operators
2022-06-10 09:29:56 +01:00
jeremy@jermolene.com 79b20bdaa8 Fix up handling of slot/fill for custom widgets
Previously we were wrapping the body in an implicit `<$fill $name="ts-body">` widget
2022-06-09 18:02:47 +01:00
jeremy@jermolene.com defe3e42e6 Adjust naming of transclusion metaparameter 2022-06-05 16:10:41 +01:00
jeremy@jermolene.com 7680280d87 Fix typo 2022-06-05 15:59:03 +01:00
jeremy@jermolene.com 542df63ccf Simplify metaparameters implementation 2022-06-03 11:21:32 +01:00
jeremy@jermolene.com b57a6da548 Mark docs as v5.3.0 2022-06-03 09:22:19 +01:00
jeremy@jermolene.com c42df2233a Make slot fill data available to transclusions
Allows transcluded content to dynamically process <$fill> widgets within the calling transclusion
2022-06-03 08:53:51 +01:00
jeremy@jermolene.com 139047b4f8 Typo from f513b403fe 2022-06-01 10:06:27 +01:00
jeremy@jermolene.com f513b403fe Remove support for $:/tags/Global
It is not needed now that we have true global variables
2022-06-01 08:24:20 +01:00
jeremy@jermolene.com 613f4af20f Fix refreshing of global variables
Global variables access within attributes will automatically trigger a refresh if the attribute text changes, but that wasn't happening for transclusions.
2022-05-31 09:19:01 +01:00
jeremy@jermolene.com 006ae6e759 Refactor $parameters widget
The objective is to add a $depth attribute so that it is possible to reach up to retrieve the parameters of ancestor transclusions. However, doing so requires changing the encoding of parameter names so that it is not possible for a user parameter to clash with an attribute like $depth. So now we have to double up dollars on any attribute names seen by the parameters widget, just like with the transclude widget itself.
2022-05-31 09:03:20 +01:00
jeremy@jermolene.com 150266c731 Use underscores for new system fields for global variable tiddlers
For consistency with `_canonical_uri`; unlike many system fields, the behaviour of these fields is baked into the core JS code.
2022-05-30 18:38:25 +01:00
jeremy@jermolene.com 3af2cc2691 Introduce function operator for calling functions
Can invoke any functions, not just those start with a period. And can pass zero parameters (in contrast when invoked as a custom filter operator there's no way to omit the first parameter).
2022-05-30 18:05:54 +01:00
jeremy@jermolene.com bd9d7c3d6a Clean up unknown filter 2022-05-30 18:04:37 +01:00
jeremy@jermolene.com 0c3f82855b Minor cleanups 2022-05-29 10:55:15 +01:00
jeremy@jermolene.com 8106ad390d Merge branch 'master' into parameterised-transclusions 2022-05-29 10:52:45 +01:00
jeremy@jermolene.com 9424e9d1f2 Cleaning up after f636349007 2022-05-28 17:32:09 +01:00
jeremy@jermolene.com f803e00567 Test showing how to un-override a core widget 2022-05-28 16:58:20 +01:00
jeremy@jermolene.com 58f01c9a20 Fix tabs global so it doesn't crash when viewed directly 2022-05-28 13:50:08 +01:00
jeremy@jermolene.com 5d413d3e2d Change to ? for conditional definitions 2022-05-28 13:49:02 +01:00
jeremy@jermolene.com 0d78b3fa38 Convert the tabs macro into a global
So far it appears to be totally backwards compatible... In practice, I think maybe this and the conversion of the other macros should go into a separate subsequent PR.
2022-05-28 12:24:48 +01:00
jeremy@jermolene.com f636349007 Introduce true global variables
The basic idea is that if we don't find a variable `foo` then we fallback to retrieving the value from the tiddler `$:/global/foo`, if it exists.

This allows us to replace the usual importvariables-based mechanism for global definitions, avoiding cluttering up the variable namespace with every macro.

In order to permit subprocedures to be overridden, we also introduce a mechanism for conditional definitions: preceding the word definition|procedure|function|widget with a + causes the definition only to occur if the specified variable doesn't already exist. In the next commit we'll apply this mechanism to the tabs macro
2022-05-28 12:23:50 +01:00
jeremy@jermolene.com a2fbebf509 Add utility function for parsing macro parameter definitions 2022-05-27 18:37:42 +01:00
jeremy@jermolene.com 7fc65d0d1a Remove accidental commit 6cc99fcbe3 2022-05-27 08:36:31 +01:00
jeremy@jermolene.com 6f9f92fa69 Add support for $:/tags/Global 2022-05-26 21:11:53 +01:00
jeremy@jermolene.com dec45f0fc3 Fix importvariables to work with setvariables as well as set (they are aliases) 2022-05-26 21:11:32 +01:00
jeremy@jermolene.com 45b7b4bc6d Make is[variable] and variables[] operators resilient to fake widgets 2022-05-26 08:23:54 +01:00
jeremy@jermolene.com e2d45e176a Merge branch 'master' into parameterised-transclusions 2022-05-25 18:08:17 +01:00
jeremy@jermolene.com 0e08150028 Remove unneeded test tiddler 2022-05-25 18:04:32 +01:00
jeremy@jermolene.com d59eec74a8 Merge branch 'master' into parameterised-transclusions 2022-05-25 15:23:20 +01:00
jeremy@jermolene.com 6cc99fcbe3 WIP 2022-05-25 15:15:17 +01:00
jeremy@jermolene.com cbce4ebb7b Allow custom functions to be invoked as attributes 2022-05-23 20:18:54 +01:00
jeremy@jermolene.com 9e8d05f699 Require period prefix for custom filter operator functions
To ensure that custom filter operators cannot clash with future core operators.
2022-05-23 16:40:21 +01:00
jeremy@jermolene.com 3e09eacd20 Missed off 22e7ec2381 2022-05-23 16:32:19 +01:00
jeremy@jermolene.com 22e7ec2381 Procedures and widgets inherit whitespace trim setting from their definition 2022-05-23 15:30:33 +01:00
jeremy@jermolene.com 170c4b1799 Merge branch 'master' into parameterised-transclusions 2022-05-23 11:28:12 +01:00
jeremy@jermolene.com d11893752c Experimental update of the parse-tree preview visualisation
An experiment to try out using the new JSON operators for rendering the JSON parse tree that we get back from the wikify widget.

As usual with these experiments, this one is going to require quite a lot more work to finish up:

* The formatting is via direct styles rather than classes
* The formatting for attributes and properties is not yet completed
* The same thing needs to also be done to the widget tree preview
2022-05-23 10:24:51 +01:00
jeremy@jermolene.com ec1ec8ccd8 Fix invocation of JS macros 2022-05-21 16:31:34 +01:00
jeremy@jermolene.com e50101322f Require $$ for custom widgets, and that overridden JS widgets must exist
See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1133637763
2022-05-21 15:47:19 +01:00
jeremy@jermolene.com bbd9e2f243 Rename <$value> widget to <$fill> 2022-05-13 09:18:25 +01:00
jeremy@jermolene.com 36cf50aa96 Use \widget for custom widget definitions, and remove need for angle brackets
Need to do some refactoring of all those isFunctionDefinition/isProcedureDefinition/isWidgetDefinition flags into a single property
2022-05-13 08:49:53 +01:00
jeremy@jermolene.com 904e30a0e2 Detect recursion by tracking widget tree depth
The old recursion marker approach was very slow, and didn't catch test cases like editions/test/tiddlers/tests/data/transclude/Recursion.tid
2022-05-12 16:26:33 +01:00
jeremy@jermolene.com 413dc86d05 Rename internal "unknown" filter operator so that users cannot invoke it 2022-05-11 14:52:25 +01:00
jeremy@jermolene.com 774459fa73 Transclude: replace paramNames/paramValues with more robust JSON payload
More details at https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1123719153
2022-05-11 13:51:11 +01:00
jeremy@jermolene.com a827290332 Fix stringifying/parsing string arrays containing newlines
A very old bug.

Fixes the ActionListOpsWidget problem @btheado
2022-05-10 10:22:35 +01:00
jeremy@jermolene.com 0b11b499c2 Better backwards compatibility for legacy recursion marker
Fixes the problem with tag dropdowns @btheado
2022-05-10 10:21:56 +01:00
jeremy@jermolene.com eef7d180a5 Remove obsolete code
Left over after refactoring
2022-05-10 10:21:19 +01:00
jeremy@jermolene.com 8e4c13382b Fix visible transclusion example 2022-05-10 08:10:32 +01:00
jeremy@jermolene.com e092113f9f Switch to using \procedure to define new-style macros, and \function for custom filter operator functions
I now need to update the OP!
2022-05-09 18:00:09 +01:00
jeremy@jermolene.com 64448ae774 Make the macrocall widget delegate to the transclude widget 2022-05-08 20:48:33 +01:00
jeremy@jermolene.com 4f2f689ab9 Clarify that the recent changes allow functions to be invoked with the double bracket syntax
In other words, the transclude widget distinguishes between functions and macros and handles the parameters appropriately
2022-05-08 16:05:32 +01:00
jeremy@jermolene.com e9630328f1 Extend transclude widget to work with old-style macros and use it for the macrocall shortcut syntax 2022-05-08 15:59:20 +01:00
jeremy@jermolene.com 9be05f6f38 Use consistent parse tree node property for params 2022-05-07 13:22:53 +01:00
jeremy@jermolene.com 2fe2d20ddf Genesis widget should pass raw attributes onto child widget...
...so that it can more efficiently handle refreshing itself.
2022-05-07 11:41:28 +01:00
jeremy@jermolene.com c5b10d5c1d Add visible transclusions component and demo
Very useful to see transclusions explicitly

Makes a good demo of a super-complicated widget override.
2022-05-06 15:39:45 +01:00
jeremy@jermolene.com e01dfa1507 Experimental support for custom filter operators
Just as we can define custom widgets we can also define custom parameterised filter operators
2022-05-06 15:01:17 +01:00
jeremy@jermolene.com a9938a6c67 Improve recursion detection
While retaining backwards compatibility
2022-05-06 15:00:10 +01:00
jeremy@jermolene.com 7caaf82571 Fix variable retrieval bug with test harness 2022-05-06 10:32:20 +01:00
jeremy@jermolene.com e5164113c4 Don't create variables with value undefined for missing parameters 2022-05-05 14:47:22 +01:00
jeremy@jermolene.com 7ead87bd29 Use enlist:raw to preserve duplicates 2022-05-05 11:34:30 +01:00
jeremy@jermolene.com f56e316c86 Fix genesis widget example 2022-05-05 11:34:06 +01:00
jeremy@jermolene.com ea51b8a3fe Merge branch 'master' into parameterised-transclusions 2022-05-05 08:30:48 +01:00
jeremy@jermolene.com f307f00e32 Fixes to enable the transclude widget itself to be overridden
There are two big changes here:

Replace the previous "ts-wrapper" mechanism, which we had been using to redefine custom widgets inside their definitions to prevent recursive calls. Now we've got the genesis widget we can instead control recursion through a new "$remappable" attribute that allows the custom widget mechanism to be skipped.

We also extend the slot widget to allow a depth to be specified; it then reaches up by the indicated number of transclusion widgets to find the one from which it should retrieve the slot value.
2022-05-05 08:20:14 +01:00
jeremy@jermolene.com 35430d09ed Fix bug with empty strings ignored in $tw.utils.stringifyList/parseStringArray
I will pull this out into a separate PR. Fixing it doesn't cause problems for the core but I imagine it might cause issues for 3rd party code.
2022-05-05 08:16:20 +01:00
jeremy@jermolene.com e99137f4cc Cache parse trees when transcluding variables 2022-05-03 17:59:45 +01:00
jeremy@jermolene.com 719a5614cb Change tiddler separator used in wikitext tests
Underscore looked ambiguous; I kept typing dashes by accident
2022-05-03 16:53:00 +01:00
jeremy@jermolene.com 56c2242e4e Introduce genesis widget for dynamically creating widgets
See the "RedefineLet" test for a contrived example of usage
2022-05-03 12:55:10 +01:00
jeremy@jermolene.com e1df50d981 Fix parameter handling 2022-05-03 12:54:29 +01:00
jeremy@jermolene.com c4743ebbec Fix importing of function definitions 2022-05-03 09:39:05 +01:00
jeremy@jermolene.com 8f69c27632 Reuse attribute objects when executing custom widgets 2022-05-03 09:38:41 +01:00
jeremy@jermolene.com 0163c04b7d Fix addAttributeToParseTreeNode handling of ordered attributes 2022-05-03 09:37:49 +01:00
jeremy@jermolene.com 2ea0374b55 Allow the let widget to create variables starting with $ 2022-05-03 08:44:33 +01:00
jeremy@jermolene.com 3000d3339c Remove extraneous code 2022-05-03 08:11:00 +01:00
jeremy@jermolene.com a888cd57cd Unquoted parameters should not eat a succeeding comma
Fixes #6672
2022-05-02 13:49:41 +01:00
jeremy@jermolene.com a10106a4a6 Fix crash when transcluding an undefined variable
Thanks @pmario

See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1114692359
2022-05-02 11:15:18 +01:00
jeremy@jermolene.com fbd0357cae Mustn't allow commas in parameter names 2022-05-02 11:04:32 +01:00
jeremy@jermolene.com 689a6c5b6a Rewrite some tests to use the shortcut syntaxes 2022-05-02 10:56:22 +01:00
jeremy@jermolene.com ea7199600d Be as permissive as possible with parameter names
Previously restricted to upper and lower case, digits and dash and underscore
2022-05-02 10:56:09 +01:00
jeremy@jermolene.com 5f02cc49fd Add support for accessing function parameters as name/value pairs 2022-05-02 10:00:50 +01:00
jeremy@jermolene.com bbc6661192 Remove erroneous "tag" property 2022-05-02 09:26:18 +01:00
jeremy@jermolene.com 8b867be8ef Add pragma rule for parameters declarations 2022-05-02 09:15:45 +01:00
jeremy@jermolene.com 99750d78b5 Allow brackets to be omitted for function definitions with no parameters 2022-04-30 13:06:28 +01:00
jeremy@jermolene.com c9bd1b5274 Add wikitext shortcut for new-style function definitions 2022-04-30 12:44:26 +01:00
jeremy@jermolene.com 886c8620f5 Replace ubertransclude widget with transclude widget 2022-04-30 10:00:38 +01:00
jeremy@jermolene.com aac2d6ccb0 Refactor ubertransclude functionality into transclude widget 2022-04-30 09:54:55 +01:00
jeremy@jermolene.com c4991fff9e Refactor transclude widget before uberfying it 2022-04-30 09:30:25 +01:00
jeremy@jermolene.com f78e1f6f7d Importvariables should skip parameters widgets 2022-04-29 22:36:07 +01:00
jeremy@jermolene.com 5bcf7b9edd Add support for shortcut syntax for positional transclusion parameters 2022-04-29 22:35:47 +01:00
jeremy@jermolene.com 89b7a3bd28 Ubertransclusion positional parameters should be based on name, not position 2022-04-29 16:28:03 +01:00
jeremy@jermolene.com 9713da5071 Add support for positional parameters 2022-04-26 21:55:43 +01:00
jeremy@jermolene.com 31c3abb7ab Add a definition for the value widget just so that it doesn't cause errors
Of course, it doesn't actually need to be a JS widget, it could be a wikitext widget...
2022-04-26 14:36:05 +01:00
jeremy@jermolene.com a401732995 Use ts- prefix for system slot names 2022-04-26 14:27:28 +01:00
jeremy@jermolene.com fae038dcbc Remove need to explicitly clear widget mapping variable when invoking overridden widget 2022-04-26 14:24:31 +01:00
jeremy@jermolene.com 35616a0b39 Don't worry about ordered attributes
The changes in 0bffae2108 mean that we don't need to explicitly maintain the ordered attributes
2022-04-26 14:05:56 +01:00
jeremy@jermolene.com 7299d4fd1d Merge branch 'master' into parameterised-transclusions 2022-04-26 14:03:03 +01:00
jeremy@jermolene.com 66d4b07f7e Add a test for custom action widgets 2022-04-26 13:05:44 +01:00
jeremy@jermolene.com 0e4e037bb7 Changed transclude widget in binary parser to ubertransclude 2022-04-26 13:05:31 +01:00
jeremy@jermolene.com cd0617f033 Use the ubertransclude widget for the wikitext transclusion syntax 2022-04-26 12:45:05 +01:00
jeremy@jermolene.com 05b582a202 Fix and test missing target handling 2022-04-26 12:32:46 +01:00
jeremy@jermolene.com 54b48876f7 Fix test execution 2022-04-26 12:32:34 +01:00
jeremy@jermolene.com 21b10a225f Initial commit
Everything is draft.
2022-04-24 21:24:38 +01:00
31 changed files with 84 additions and 425 deletions
+2 -8
View File
@@ -1920,7 +1920,7 @@ $tw.loadTiddlersFromSpecification = function(filepath,excludeRegExp) {
// Read the specification
var filesInfo = $tw.utils.parseJSONSafe(fs.readFileSync(filepath + path.sep + "tiddlywiki.files","utf8"));
// Helper to process a file
var processFile = function(filename,isTiddlerFile,fields,isEditableFile,rootPath) {
var processFile = function(filename,isTiddlerFile,fields,isEditableFile) {
var extInfo = $tw.config.fileExtensionInfo[path.extname(filename)],
type = (extInfo || {}).type || fields.type || "text/plain",
typeInfo = $tw.config.contentTypeInfo[type] || {},
@@ -1941,12 +1941,6 @@ $tw.loadTiddlersFromSpecification = function(filepath,excludeRegExp) {
} else {
var value = tiddler[name];
switch(fieldInfo.source) {
case "subdirectories":
value = path.relative(rootPath, filename).split('/').slice(0, -1);
break;
case "filepath":
value = path.relative(rootPath, filename);
break;
case "filename":
value = path.basename(filename);
break;
@@ -2029,7 +2023,7 @@ $tw.loadTiddlersFromSpecification = function(filepath,excludeRegExp) {
var thisPath = path.relative(filepath, files[t]),
filename = path.basename(thisPath);
if(filename !== "tiddlywiki.files" && !metaRegExp.test(filename) && fileRegExp.test(filename)) {
processFile(thisPath,dirSpec.isTiddlerFile,dirSpec.fields,dirSpec.isEditableFile,dirSpec.path);
processFile(thisPath,dirSpec.isTiddlerFile,dirSpec.fields,dirSpec.isEditableFile);
}
}
} else {
-2
View File
@@ -279,8 +279,6 @@ TranscludeWidget.prototype.getTransclusionTarget = function() {
defaultType: this.transcludeType
});
}
// Set 'thisTiddler'
this.setVariable("thisTiddler",this.transcludeTitle);
// Return the parse tree
if(parser) {
return {
@@ -5,10 +5,7 @@ title: $:/core/save/all-external-js
\define saveTiddlerFilter()
[is[tiddler]] -[prefix[$:/state/popup/]] -[prefix[$:/temp/]] -[prefix[$:/HistoryList]] -[status[pending]plugin-type[import]] -[[$:/core]] -[[$:/boot/boot.css]] -[type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] +[sort[title]] $(publishFilter)$
\end
<!-- Important: core library is provided by serving URI encoded $:/core/templates/tiddlywiki5.js -->
\define defaultCoreURL() %24%3A%2Fcore%2Ftemplates%2Ftiddlywiki5.js
<$let coreURL={{{ [[coreURL]is[variable]then<coreURL>else<defaultCoreURL>] }}}>
{{$:/core/templates/tiddlywiki5-external-js.html}}
</$let>
@@ -1,7 +0,0 @@
created: 20230314153132081
modified: 20230314153243008
title: $:/DefaultTiddlers
type: text/vnd.tiddlywiki
GettingStarted
[[Using the external JavaScript template]]
@@ -1,4 +0,0 @@
title: $:/config/SaveWikiButton/Filename
type: text/vnd.tiddlywiki
external-<<version>>.html
@@ -1,8 +0,0 @@
{
"tiddlers": [
{
"file": "../../../tw5.com/tiddlers/webserver/Using the external JavaScript template.tid",
"isTiddlerFile": true
}
]
}
+3 -2
View File
@@ -2,7 +2,8 @@
"description": "Client-server edition with external tiddlywiki.js",
"plugins": [
"tiddlywiki/tiddlyweb",
"tiddlywiki/filesystem"
"tiddlywiki/filesystem",
"tiddlywiki/highlight"
],
"themes": [
"tiddlywiki/vanilla",
@@ -12,7 +13,7 @@
"listen": [
"--listen","root-tiddler=$:/core/save/all-external-js","use-browser-cache=yes"],
"index": [
"--render","$:/core/save/offline-external-js","[[external-]addsuffix<version>addsuffix[.html]]","text/plain",
"--render","$:/core/save/offline-external-js","index.html","text/plain",
"--render","$:/core/templates/tiddlywiki5.js","[[tiddlywikicore-]addsuffix<version>addsuffix[.js]]","text/plain"],
"static": [
"--render","$:/core/templates/static.template.html","static.html","text/plain",
@@ -1,29 +0,0 @@
title: ThisTiddler/Simple
description: Simple usage of thisTiddler variable
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
\import Macro
\define print-this-tiddler()
<$text text=<<thisTiddler>>/>
\end
(<$text text=<<thisTiddler>>/>)
(<<print-this-tiddler>>)
(<<imported-print-this-tiddler>>)
+
title: Macro
\define imported-print-this-tiddler()
<$text text=<<thisTiddler>>/>
\end
+
title: ExpectedResult
<p>(Output)</p><p>(Output)</p><p>(Output)</p>
@@ -5,7 +5,7 @@ modified: 20230410105035569
<span style="float:right;">[img width=340 [Xememex Logo]]</span>
Xememex is a multiuser TiddlyWiki from [[Federatial]]. It allows large groups of people to work together on intertwingled wikis that can share content. It is implemented as a serverless application on Amazon Web Services.
Xememex is a multiuser TiddlyWiki from [[Federatial]]. It allows large groups of people to work together on intertwingled wikis that can share content.
The largest customer implementation has hundreds of online wikis with thousands of users. See https://manuals.annafreud.org/
@@ -29,8 +29,6 @@ Each field can be specified as either a ''string'' or ''array'' value to be assi
** //extname// the extension of the filename of the file containing the tiddler
** //created// the creation date/time of the file containing the tiddler
** //modified// the modification date/time of the file containing the tiddler
** <<.from-version "5.3.0">> //filepath// the path of the file containing the tiddler, relative to the ''path'' property of the directory (only usable in ''directories'' declarations)
** <<.from-version "5.3.0">> //subdirectories// an array of the subdirectories in the file's path relative, to the ''path'' property of the directory (only usable in ''directories'' declarations)
* ''prefix'' - (optional) a string to be prepended to the value of the field
* ''suffix'' - (optional) a string to be appended to the value of the field
@@ -54,7 +52,7 @@ Directory specifications in the `directories` array may take the following forms
** ''filesRegExp'' - (optional) a [[regular expression|https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions]] that matches the filenames of the files that should be processed within the directory
** ''isTiddlerFile'' - (required) if `true`, the file will be treated as a [[tiddler file|TiddlerFiles]] and deserialised to extract the tiddlers. Otherwise, the raw content of the file is assigned to the `text` field without any parsing
** ''isEditableFile'' - <<.from-version "5.1.23">> (optional) if `true`, changes to the tiddler be saved back to the original file. The tiddler will be saved back to the original filepath as long as it does not generate a result from the $:/config/FileSystemPath filters, which will override the final filepath generated if a result is returned from a filter.
** ''searchSubdirectories'' - <<.from-version "5.1.23">> (optional) if `true`, all subdirectories of the //path// are searched recursively for files that match the (optional) //filesRegExp//. If no //filesRegExp// is provided, all files in all subdirectories of the //path// are loaded. Tiddler titles generated via the //source// attribute //filename// (see above) will only include the filename, not any of the subdirectories of the path. If this results in multiple files with loaded with the same tiddler title, then only the last file loaded under that tiddler title will be in memory. In order to prevent this, you can use the //filepath// attribute instead of //filename//. Alternately, you can include multiple directory objects and customise the title field with a //prefix// or //suffix// alongside the //source// attribute.
** ''searchSubdirectories'' - <<.from-version "5.1.23">> (optional) if `true`, all subdirectories of the //path// are searched recursively for files that match the (optional) //filesRegExp//. If no //filesRegExp// is provided, all files in all subdirectories of the //path// are loaded. Tiddler titles generated via a //source// attribute (see above) will only include the filename, not any of the subdirectories of the path. If this results in multiple files with loaded with the same tiddler title, then only the last file loaded under that tiddler title will be in memory. In order to prevent this, you must have multiple directory objects listed and customise the title field with a //prefix// or //suffix// alongside the //source// attribute.
** ''fields'' - (required) an object containing values that override or customise the fields provided in the tiddler file (see above)
Fields can also be overridden for particular files by creating a file with the same name plus the suffix `.meta` -- see TiddlerFiles.
@@ -97,7 +95,6 @@ This example retrieves all the files with the extension `.pdf` from a folder spe
]
}
```
!! Importing a folder of text files
This example retrieves all the files with the extension `.txt` from a folder specified by a relative path. This folder is within the wiki's base directory, and the current config file is in a directory within the wiki's "tiddlers/" directory. So, in this case the path starts with "../../" to traverse upwards two directory levels, and then down into the "externalnotes/" directory. Each tiddler is set up with the following fields:
@@ -133,39 +130,4 @@ This will load all text files in the `../../externalnotes/` directory into the w
From the examples in [[Customising Tiddler File Naming]] we see that the final `[!tag[externalnote]addprefix[wiki/]]` filter in the $:/config/FileSystemPaths tiddler excludes all tiddlers tagged with `externalnotes` (that have not matched an earlier filter). These tiddlers have their filepath retrieved from the $:/config/OriginalTiddlerPaths generated upon boot startup.
Then, the `[tag[.txt]then[.txt]]` filter in the $:/config/FileSystemExtensions tiddler forces all these tiddlers to be saved back to disk as *.txt and accompanying *.txt.meta files (overriding the normal tiddler-type to file-type mapping). In this case, allowing the snippets of Tiddlywiki wikitext or markdown-text to be saved back to "text" *.txt files.
!! Importing and auto-tagging images
This example imports all the image files in the `files` directory and all its subdirectories as external-image tiddlers, and tags them based on their filepath. Each tiddler is set up with the following fields:
* ''title'' - set to the URI decoded base filename of the text file
* ''created'' - set to the creation date/time of the text file
* ''modified'' - set to the modification date/time of the text file
* ''type'' - set to `image/jpeg`. There is currently no way to infer the correct ContentType of the image tiddler from the file, but `image/jpeg` tiddlers should render correctly even with png or gif images. As an alternative, you could create separate definitions for jpg, png, and gif files with the `image/jpeg`, `image/png`, and `image/gif` types respectively.
* ''tags'' - generated based on the path of the image relative to the parent directory (`files` in this case). Eg, images in `files/photos` will be tagged with `photos`, those in `files/photos/family` will be tagged with both `photos` and `family`, and those in the root `files` directory will have no tags.
* ''text'' - set to an empty string
* ''_canonical_uri'' - set to the full filepath of the image relative to the wiki root
```
{
"directories": [
{
"path": "../../files/",
"filesRegExp": "^.*\\.(?:jpg|jpeg|png|gif)$",
"isTiddlerFile": false,
"searchSubdirectories": true,
"fields": {
"title": {"source": "basename-uri-decoded"},
"created": {"source": "created"},
"modified": {"source": "modified"},
"type": "image/jpeg",
"tags": { "source": "subdirectories" },
"text": "",
"_canonical_uri": { "source": "filepath", "prefix": "files/" }
}
}
]
}
```
Then, the `[tag[.txt]then[.txt]]` filter in the $:/config/FileSystemExtensions tiddler forces all these tiddlers to be saved back to disk as *.txt and accompanying *.txt.meta files (overriding the normal tiddler-type to file-type mapping). In this case, allowing the snippets of Tiddlywiki wikitext or markdown-text to be saved back to "text" *.txt files.
@@ -28,7 +28,7 @@ For example:
```
\procedure sayhi(name:"Bugs Bunny")
Hi, I'm <<name>>.
Hi, I'm $name$.
\end
<<sayhi "Jeremy">>
@@ -37,7 +37,7 @@ Hi, I'm <<name>>.
Alternatively, the entire definition can be presented on a single line without an `\end` marker:
```
\procedure sayhi(name:"Bugs Bunny") Hi, I'm <<name>>.
\procedure sayhi(name:"Bugs Bunny") Hi, I'm $name$.
```
Procedure definitions can be nested by specifying the name of the procedure in the `\end` marker. For example:
@@ -47,7 +47,7 @@ Procedure definitions can be nested by specifying the name of the procedure in t
<$action-sendmessage $message="tm-notify" $param="HelloThere"/>
\end actions
<$button actions=<<actions>>>
<<caption>>
$caption$
</$button>
\end special-button
@@ -7,7 +7,7 @@ type: text/vnd.tiddlywiki
!! Introduction
This tiddler describes the different ways in which [[procedure|Procedures]] can be called.
This tiddler describes the different ways in which [[macros|Procedures]] can be called.
!! Procedure Call Transclusion Shortcut
@@ -1,3 +1,4 @@
caption: Macro Definitions
created: 20221007125701001
modified: 20230419103154329
tags: WikiText Procedures
@@ -1,3 +1,4 @@
caption: Macro Definitions
created: 20221007130538285
modified: 20230419103154329
tags: WikiText Procedures
@@ -134,11 +134,7 @@ This is an example tiddler. See [[Table-of-Contents Macros (Examples)]].
</dl>
<blockquote class="doc-example-result">
<$reveal default="$egvar$" type="match" text="NO-SUCH-VAR">
$$$text/vnd.tiddlywiki
$eg$
$$$
$eg$
</$reveal>
<$reveal default="$egvar$" type="nomatch" text="NO-SUCH-VAR">
<<$egvar$>>
@@ -1,13 +0,0 @@
created: 20230304123606350
modified: 20230304124149055
tags: [[currentTiddler Variable]] [[Variable Examples]]
title: thisTiddler Variable (Examples)
type: text/vnd.tiddlywiki
<$macrocall $name=".example" n="1" eg="""<$text text=<<thisTiddler>>/>"""/>
<$macrocall $name=".example" n="2" eg="""\define example() <$text text=<<thisTiddler>>/>
<<example>>
"""/>
@@ -1,12 +0,0 @@
caption: currentTiddler
created: 20230304122810114
modified: 20230304123557862
tags: Variables [[Core Variables]]
title: thisTiddler Variable
type: text/vnd.tiddlywiki
<<.from-version "5.3.0">> The <<.def thisTiddler>> [[variable|Variables]] is set by the <<.wlink TranscludeWidget>> widget to contain the title of the tiddler that was transcluded. This means that within a tiddler <<.def thisTiddler>> will contain the title of that tiddler. It is not affected by macros, which means that within a macro <<.def thisTiddler>> will contain the title of the tiddler from which the macro was invoked. Intermediate, nested macro calls are ignored.
Compare <<.vlink storyTiddler>> and <<.vlink currentTiddler>>.
<<.variable-examples "thisTiddler">>
@@ -1,154 +0,0 @@
created: 20230421020225031
modified: 20230422144812613
tags:
title: Variable Usage
type: text/vnd.tiddlywiki
\define m1(a1) $a1$ - <<__a1__>> - <<a1>>
\procedure p1(a1) $a1$ - <<__a1__>> - <<a1>>
\function f1(a1) "$a1$" "-" [<__a1__>] ="-" [<a1>] :and[join[ ]]
!Ways to define variables and parameters
|! how declared|! how parameters are defined|! accessing parameter values in the body|
|\define|`()`|`$param$, <<__param__>>`|
|~|<<.wlink ParametersWidget>> or `\parameters`|`<<param>>`|
|<<.wlink SetWidget>>, <<.wlink LetWidget>>, <<.wlink VarsWidget>>|<<.wlink ParametersWidget>> or `\parameters`|`<<param>>`|
|\procedure, \widget|`()`, <<.wlink ParametersWidget>> or `\parameters`|`<<param>>`|
|\function|`()`|`<param>`|
|javascript macros|`exports.params` javascript property array|passed as normal javascript function parameter and so accessed as a normal javascript variable|
!!Examples
These examples are meant to provide insight into the various ways of defining and using parameters. In many cases they do not illustrate best practices.
!!! \define
<$let eg='\define mp1(a1) $a1$ - <<__a1__>>
\define mp2() <$parameters a1><<a1>></$parameters>
\define mp3()
\parameters(a1)
<<a1>>
\end
|<<mp1 foo>>|<<mp2 foo>>|<<mp3 foo>>|
'>
<$macrocall $name="copy-to-clipboard-above-right" src=<<eg>>/>
<$codeblock code=<<eg>>/>
</$let>
!!! $set, $let, $vars
<$let eg='<$set name="sp1" value="<$parameters a1><<a1>></$parameters>">
<$set name="sp2" value="""
\parameters(a1)
<$parameters a1><<a1>></$parameters>
""">
<$vars vp1="<$parameters a1><<a1>></$parameters>" vp2="""
\parameters(a1)
<$parameters a1><<a1>></$parameters>
""">
<$let lp1="<$parameters a1><<a1>></$parameters>" lp2="""
\parameters(a1)
<$parameters a1><<a1>></$parameters>
""">
|<<sp1 foo>>|<<sp2 foo>>|
|<<vp1 foo>>|<<vp2 foo>>|
|<<lp1 foo>>|<<lp2 foo>>|
</$let>
</$vars>
</$set>
</$set>
'>
<$macrocall $name="copy-to-clipboard-above-right" src=<<eg>>/>
<$codeblock code=<<eg>>/>
</$let>
!!! \procedure, \widget
<$let eg='\procedure pp1(a1) <<a1>>
\procedure pp2() <$parameters a1><<a1>></$parameters>
\procedure pp3()
\parameters(a1)
<<a1>>
\end
\procedure wp1(a1) <<a1>>
\widget wp2() <$parameters a1><<a1>></$parameters>
\widget wp3()
\parameters(a1)
<<a1>>
\end
|<<pp1 foo>>|<<pp2 foo>>|<<pp3 foo>>|
|<<wp1 foo>>|<<wp2 foo>>|<<wp3 foo>>|
'>
<$macrocall $name="copy-to-clipboard-above-right" src=<<eg>>/>
<$codeblock code=<<eg>>/>
</$let>
!!! \function
<$let eg='\function fp1(a1) [<a1>]
|<<fp1 foo>>|'>
<$macrocall $name="copy-to-clipboard-above-right" src=<<eg>>/>
<$codeblock code=<<eg>>/>
</$let>
!Behavior of invoked variables depends on how the variable was declared
|!how invoked|!how declared|!behavior|
|`<$transclude $variable=macro/>` or `<<macro>>` in normal wikitext context|\define|All wikitext and variable substitution and textual substitution takes place|
|~|<<.wlink SetWidget>>, <<.wlink LetWidget>>, <<.wlink VarsWidget>>, \procedure, \widget|All wikitext and variable substitution takes place|
|~|\function|Invoking a function in this way (`<<macro>>`) is a synonym for `<$text text={{{[function[macro]]}}}/>`. As with any filtered transclusion (i.e. triple curly braces), all results except the first are discarded.|
||||
|widget attribute: `<div class=<<macro>>/>`|\define|Textual substitution of parameters is performed on the body text. No further processing takes place. The result after textual substitution is used as the attribute's value|
|~|<<.wlink SetWidget>>, <<.wlink LetWidget>>, <<.wlink VarsWidget>>, \procedure, \widget|Body text is retrieved as-is and used as the attribute's value.|
|~|\function|When a function is invoked as `<div class=<<macro>>/>`, it is a synonym for `<div class={{{[function[macro]]}}}/>`. As with any filtered transclusion (i.e. triple curly braces), all results except the first are discarded. That first result is used as the attribute's value. Note that functions are recursively processed even when invoked in this form. In other words a filter expression in a function can invoke another function and the processing will continue|
||||
|filter operator parameter: `[<macro>]`|\define|Textual substitution of parameters is performed on the body text. No further processing takes place. The result after textual substitution is used as the filter operator's parameter.|
|~|<<.wlink SetWidget>>, <<.wlink LetWidget>>, <<.wlink VarsWidget>>, \procedure, \widget|Body text is retrieved as-is and used as the filter operator's parameter.|
|~|\function|The body text of the function is treated as a filter expression and evaluated. The first result is passed to the operator as a parameter. The remaining results are discarded|
||||
|function call in a filter expression: `[function[macro]]`|\define, <<.wlink SetWidget>>, <<.wlink LetWidget>>, <<.wlink VarsWidget>>, \procedure, \widget|Every function is a variable, but only variables defined using \function are invokable using the <<.olink function>> filter operator. Attempts to use a non-function variable is the same as if the function doesn't exist. The behavior in this case is like the identity function. All filter input is passed unchanged to the output.|
|~|\function|The body text of the function is treated as a filter expression and evaluated. This filter expression can itself contain a function call. Filter expressions can be factored out into functions arbitrarily deep.|
!! Examples
Below is an example macro, procedure and function definition. All three forms of parameter substitution `$a1$`, `<<__a1__>>`, and `<<a1>>` are included in each definition. The output helps illustrate when each form of substitution will or will not have affect.
```
\define m1(a1) $a1$ - <<__a1__>> - <<a1>>
\procedure p1(a1) $a1$ - <<__a1__>> - <<a1>>
\function f1(a1) $a1$ "-" [<__a1__>] ="-" [<a1>] :and[join[ ]]
```
| !Variable transclusion|!output |
| `<<m1 foo>>`|<<m1 foo>>|
| `<<p1 foo>>`|<<p1 foo>>|
| `<<f1 foo>>`|<<f1 foo>>|
| !Widget attribute|!output |
| `<$text text=<<m1 foo>>/>`|<$text text=<<m1 foo>>/>|
| `<$text text=<<p1 foo>>/>`|<$text text=<<p1 foo>>/>|
| `<$text text=<<f1 foo>>/>`|<$text text=<<f1 foo>>/>|
| !Filter operator parameter|!output |
| `[<m1 foo>]`|<$text text={{{[<m1 foo>]}}}/>|
| `[<p1 foo>]`|<$text text={{{[<p1 foo>]}}}/>|
| `[<f1 foo>]`|<$text text={{{[<f1 foo>]}}}/>|
| !Function call in filter expression|!output |
| `[function[m1],[foo]]`|<$text text={{{[function[m1],[foo]]}}}/>|
| `[function[p1],[foo]]`|<$text text={{{[function[p1],[foo]]}}}/>|
| `[function[f1],[foo]]`|<$text text={{{[function[f1],[foo]]}}}/>|
!Namespaces
*''tiddler titles'' - tiddlers are uniquely identified by their title. The namespace for tiddler titles and variable names are completely separate.
*''variables'' - \define, <<.wlink SetWidget>>, <<.wlink LetWidget>>, <<.wlink VarsWidget>>, \procedure, \widget, \function all create variables. If the same name is used, then later define will overwrite earlier defined
*''<<.op function>> filter operator parameter'' - only variables defined using \function can be called using the <<.olink function>> operator
*''filter operators'' - only the [[javascript defined filter operators|Filter Operators]] and variables defined using \function with name starting with a dot can be called
*''widgets'' - variables defined using \widget can be invoked using `<$widget/>` syntax ONLY if the name starts a dollar sign (to override existing javascript defined widgets) or double dollar sign (to define [[custom widgets|Custom Widgets]]). Without the dollar sign prefix, defining variables using \widget is no different than using \procedure.
@@ -1,5 +1,5 @@
created: 20141002133113496
modified: 20230422150445336
modified: 20230419103154329
tags: Concepts Reference WikiText
title: Variables
type: text/vnd.tiddlywiki
@@ -25,8 +25,6 @@ There are several special kinds of variable that extend their basic capabilities
Note that these special kinds of variable can only be created with the associated shortcut definition syntax.
For a more detailed comparison of these special kinds of variables, see [[Variable Usage]].
!! Defining Variables
The following core widgets are commonly used to define variables:
@@ -1,13 +1,9 @@
created: 20180905075846391
modified: 20230319130830880
modified: 20221207112242775
tags: [[WebServer Guides]]
title: Using the external JavaScript template
type: text/vnd.tiddlywiki
<!--
This tiddler is also included in the "server-external-js" edition. Take care before editing or moving it.
-->
You can use a special template to externalise ~TiddlyWiki's core code into a separate file. This configuration allows the browser to cache the core for improved efficiency.
! Background
@@ -64,7 +60,7 @@ The "server-external-js" edition lets you save the snapshot from the command lin
tiddlywiki YOUR_WIKI_FOLDER --build index
```
The files `external-5-x-x.html` and `tiddlywikicore-5.x.x.js` will be saved in your wiki folder's `output` directory.
The files `index.html` and `tiddlywikicore-5.x.x.js` will be saved in your wiki folder's `output` directory.
!! Obtaining the ~TiddlyWiki core in the browser
@@ -52,7 +52,7 @@ These attributes provide low level access to the contents of the transcluding wi
Here the <<.wlink ParametersWidget>> widget is used to declare a parameter whose default value is transcluded from another tiddler.
<$macrocall $name='wikitext-example-without-html'
src="""\procedure mymacro()
src="""\procedure mymacro
<$parameters name={{$:/SiteTitle}} age="21">
My name is <<name>> and my age is <<age>>.
</$parameters>
@@ -1,3 +1,4 @@
caption: Macro Definitions
created: 20150220181617000
modified: 20230419103154328
tags: WikiText Macros
@@ -1,3 +1,4 @@
caption: Macro Definitions
created: 20220917154902906
modified: 20230419103154328
tags: WikiText Macros
@@ -1,3 +0,0 @@
title: $:/config/Dynannotate/LegacySelectionTracker/Enable
no
@@ -1,3 +0,0 @@
title: $:/config/Dynannotate/SelectionTracker/Enable
no
@@ -25,7 +25,7 @@ The `<$dynannotate>` widget uses the selection tracker to support a popup that d
|popup |Popup state tiddler to be used to trigger a popup when an annotation is clicked |
|search |Search text to be highlighted within the widget |
|searchDisplay |"overlay" or "snippet" (see below) |
|searchMode |"literal" (default), "regexp", "whitespace", "words" or "some" (see below) |
|searchMode |"normal" (default), "regexp" or "whitespace" (see below) |
|searchMinLength |Optional minimum length of search string |
|searchCaseSensitive |"yes" (the default) for a case sensitive search, or "no" for a case insensitive search|
|searchClass |Optional CSS class to be added to search overlays |
@@ -46,10 +46,9 @@ The values supported by the `searchDisplay` attribute are:
The search modes supported by the `searchMode` attribute are:
* `literal` or `normal` - a literal string of plain text to match (default).
* `normal` - a literal string of plain text to match
* `regexp` - a JavaScript-style regular expression (without the quoting backslashes and flags)
* `whitespace` - a literal string to match while normalising runs of whitespace. Thus `A B` matches `A B`.
* `words` or `some` - treats the search string as a list of tokens separated by whitespace, and matches all tokens (regardless of ordering and whether there is other text in between)
* `whitespace` - a literal string to match while normalising runs of whitespace. This allows `a. b` to match `a. b`
When the selection popup is triggered, the currently selected text can be found in the tiddler named in the `selection` attribute, with the disambiguating prefix and suffix in the tiddlers named in the `selectionPrefix` and `selectionPopup` tiddlers. Note that the selection text will be an empty string if the selection popup was triggered in response to a click (ie zero width selection).
@@ -96,7 +95,7 @@ Note that using the `annotate-tiddler` field to associate an annotation with the
!! Selection Trackers
The selection trackers are enabled when the following configuration tiddlers are set to ''yes''.
The following configuration tiddlers can be used to control whether the selection trackers are enabled when the following configuration tiddlers are set to ''yes'' (the default).
* $:/config/Dynannotate/SelectionTracker/Enable for the main selection tracker
* $:/config/Dynannotate/LegacySelectionTracker/Enable for the legacy selection tracker
@@ -10,33 +10,16 @@ caption: Simple
$example$
\end
\define search-example-code()
<!--
The inline filters update the displayed codeblock to reflect the choices the user has made in the UI.
The rules pragma is used here to evaluate only these filters, but leave everything else untouched.
The tabs and linebreaks within the parameters to addprefix, though maybe confusing, help with the readability of the codeblock output.
-->
\rules only filteredtranscludeinline
<$dynannotate
search="{{{ [{$:/temp/dynannotate-example/search}!is[blank]else[The human mind]] }}}"{{{ [{$:/temp/dynannotate-example/searchMode}!search::some[literal normal]addprefix[
searchMode="]addsuffix["]] }}}
searchCaseSensitive="{{{ [{$:/temp/dynannotate-example/searchCaseSensitive}!is[blank]else[yes]] }}}"{{{ [{$:/temp/dynannotate-example/searchClass}!is[blank]addprefix[
searchClass="]addsuffix["]] }}}
>
<$transclude tiddler="$:/plugins/tiddlywiki/dynannotate/example-text-1" mode="block"/>
<$transclude tiddler="$:/plugins/tiddlywiki/dynannotate/example-text-2" mode="block"/>
</$dynannotate>
\end
<div class="tc-dynannotation-example-info">
!! Annotations with `target`
!! Simple annotation
We use the `target*` attributes to specify a target string for the annotation and optionally a prefix and suffix for disambiguating multiple occurences.
We use the `target*` attributes to specify a target string for the annotation and optionally a prefix and suffix for disambiguating multiple occurances.
</div>
<<show-example """<$dynannotate
<<show-example """
<$dynannotate
target="the"
targetPrefix="Yet "
targetSuffix=" speed"
@@ -47,35 +30,55 @@ We use the `target*` attributes to specify a target string for the annotation an
<div class="tc-dynannotation-example-info">
!! Highlights with `search`
!! Plain text searching
We use the `search` attribute to specify a search string for highlighting.
The search type can be set with the `searchMode` and `searchCaseSensitive` attributes.
We can style the highlights with the `searchClass` attribute, which has some predefined values.
We use the `search` attribute to specify a search string for highlighting:
</div>
|tc-table-no-border tc-dynannotate-search-parameters|k
|search term |<$edit-text tiddler="$:/temp/dynannotate-example/search" field="text" tag="input" default="The human mind" />|
|search mode |<$select tiddler="$:/temp/dynannotate-example/searchMode" field="text" default="literal"><option value="literal">literal</option><option value="normal">normal</option><option value="regexp">regexp</option><option value="whitespace">whitespace</option><option value="some">some</option><option value="words">words</option></$select> |
|case sensitive |<$checkbox tiddler="$:/temp/dynannotate-example/searchCaseSensitive" field="text" checked="yes" unchecked="no" default="yes"> <$text text={{{ [{$:/temp/dynannotate-example/searchCaseSensitive}!is[blank]else[yes]] }}} /></$checkbox> |
|search class |<$select tiddler="$:/temp/dynannotate-example/searchClass" field="text" default=""><option value="">(none)</option><option value="tc-dynannotation-search-overlay-animated">tc-dynannotation-search-overlay-animated</option><option value="tc-dynannotation-search-overlay-blurred">tc-dynannotation-search-overlay-blurred</option></$select> |
<<show-example """
<$dynannotate
search={{{ [{$:/temp/dynannotate-example/search}!is[blank]else[The human mind]] }}}
searchMode={{{ [{$:/temp/dynannotate-example/searchMode}] }}}
searchCaseSensitive={{{ [{$:/temp/dynannotate-example/searchCaseSensitive}!is[blank]else[yes]] }}}
searchClass={{{ [{$:/temp/dynannotate-example/searchClass}] }}}
search="the"
>
<$transclude tiddler="$:/plugins/tiddlywiki/dynannotate/example-text-1" mode="block"/>
<$transclude tiddler="$:/plugins/tiddlywiki/dynannotate/example-text-2" mode="block"/>
</$dynannotate>
""">>
<$wikify name="wikifiedCode" text=<<search-example-code>> mode="block" output="text">
<$codeblock code=<<wikifiedCode>>/>
</$wikify>
<div class="tc-dynannotation-example-info">
!! Regular expression searching
We use the `mode` attribute set to `regexp` to highlight matches of a regular expression:
</div>
<<show-example """
<$dynannotate
search="the|an"
searchMode="regexp"
searchClass="tc-dynannotation-search-overlay-blurred"
>
<$transclude tiddler="$:/plugins/tiddlywiki/dynannotate/example-text-1" mode="block"/>
</$dynannotate>
""">>
<div class="tc-dynannotation-example-info">
!! Normalised whitespace searching
We use the `mode` attribute set to `whitespace` to search for a string with whitespace normalised (ie runs of whitespace are collapsed to a single space for matching purposes):
</div>
<<show-example """
<$dynannotate
search="does not work that way. It operates"
searchMode="whitespace"
searchClass="tc-dynannotation-search-overlay-animated"
>
<$transclude tiddler="$:/plugins/tiddlywiki/dynannotate/example-text-1" mode="block"/>
</$dynannotate>
""">>
<div class="tc-dynannotation-example-info">
@@ -87,7 +90,8 @@ Annotation tiddlers can be used to describe annotations. This example references
<<list-links "[all[shadows+tiddlers]annotate-tiddler[$:/plugins/tiddlywiki/dynannotate/example-text-1]]">>
<<show-example """<$dynannotate
<<show-example """
<$dynannotate
filter="[all[shadows+tiddlers]annotate-tiddler[$:/plugins/tiddlywiki/dynannotate/example-text-1]]"
>
<$transclude tiddler="$:/plugins/tiddlywiki/dynannotate/example-text-1" mode="block"/>
@@ -34,7 +34,6 @@ title: $:/plugins/tiddlywiki/dynannotate/examples/viewtemplate/text
selectionPopup={{{ [<currentTiddler>addprefix[$:/state/dynannotate/popup-selection/]] }}}
search={{$:/temp/search}}
searchClass="tc-dynannotation-search-overlay-blurred"
searchCaseSensitive="no"
searchMinLength={{$:/config/Search/MinLength}}
>
<$transclude mode="block">
@@ -1,69 +1,28 @@
caption: View Template
tags: $:/tags/dynannotateExamples
title: $:/plugins/tiddlywiki/dynannotate/examples/viewtemplate
\define show-example(example)
<$codeblock code=<<__example__>>/>
//''Displays as:''//
$example$
\end
tags: $:/tags/dynannotateExamples
caption: View Template
<div class="tc-dynannotation-example-info">
!! Using Dynannotate in the view template
This example shows how to override the core view template with a custom template that includes dynannotate. It is disabled by default but can be enabled by clicking the corresponding button below. The example transcludes the [[Searching in TiddlyWiki|$:/plugins/tiddlywiki/dynannotate/searching-in-tiddlywiki]] tiddler for illustration purposes, but the chosen view template is applied to all open tiddlers.
This example shows how to override the core view template with a custom template that includes dynannotate. It is disabled by default but can be enabled by clicking the button below. (Clicking the button below copies the custom view template from $:/plugins/tiddlywiki/dynannotate/examples/viewtemplate/text to $:/core/ui/ViewTemplate/body).
Once enabled, this example demonstrates several features of Dynannotate:
Once enabled, this example demonstrates several features:
* Highlight text within tiddler bodies -- any text entered in the sidebar search input will be highlighted (in all tiddlers)
* Create annotations (on any tiddler) by selecting text and then clicking //Create annotation// in the resulting dropdown
(Clicking the buttons below either puts the custom body view template [[$:/plugins/tiddlywiki/dynannotate/examples/viewtemplate/text]] in front of the default in the [[View Template Body Cascade|https://tiddlywiki.com/#View%20Template%20Body%20Cascade]] or removes it from the cascade).
* Highlighting of search results within tiddler bodies
* Creating annotations on any tiddler by selecting text and then clicking a colour in the resulting dropdown
</div>
<$button>
<$action-setfield $tiddler="$:/config/ViewTemplateBodyFilters/dynannotate" tags="$:/tags/ViewTemplateBodyFilter" text="[[$:/plugins/tiddlywiki/dynannotate/examples/viewtemplate/text]]" list-before="$:/config/ViewTemplateBodyFilters/default"/>
<$action-setfield $tiddler="$:/config/ViewTemplateTitleFilters/dynannotate" tags="$:/tags/ViewTemplateTitleFilter" text="[[$:/plugins/tiddlywiki/dynannotate/examples/viewtemplate/text]]" list-before="$:/config/ViewTemplateBodyFilters/default"/>
Click here to use the custom view template
</$button>
<$button>
<$action-deletetiddler $tiddler="$:/config/ViewTemplateBodyFilters/dynannotate"/>
<$action-deletetiddler $tiddler="$:/config/ViewTemplateTitleFilters/dynannotate"/>
Click here to revert to the core view template
</$button>
<p/>
<div class="tc-dynannotation-example-info">
!! Using Dynannotate to highlight text on a per-tiddler basis
Using state tiddlers containing the text which is to be highlighted, Dynannotate highlights can be applied on a per-tiddler basis when used in the body view template. This can also be combined with the [[GenesisWidget]] to insert the Dynannotate widget into the DOM only when such a highlight is configured.
This example uses a transcluded tiddler, but Dynannotate could be added to the view template (to show highlights in all parts of a tiddler) or to the body view template (to show highlights only in the tiddler body) in the same way. Note how in this example, Dynannotate only affects the transcluded content.
</div>
<<show-example """<$button set="$:/state/dynannotate/examples/viewtemplate" setTo="tiddler">Highlight "tiddler"</$button>
<$button set="$:/state/dynannotate/examples/viewtemplate" setTo="created">Highlight "created"</$button>
<$button set="$:/state/dynannotate/examples/viewtemplate" setTo="">Clear highlights</$button>
<p/>
<$let dynannotateText={{$:/state/dynannotate/examples/viewtemplate}}>
<$genesis $type={{{ [<dynannotateText>!is[blank]then[$dynannotate]] }}}
search=<<dynannotateText>>
searchDisplay="overlay"
searchClass="tc-dynannotation-search-overlay-animated"
searchCaseSensitive="no">
<div class="tc-dynannotate-example-frame">
!! `$:/core/ui/ControlPanel/TiddlerFields`:
<$transclude tiddler="$:/core/ui/ControlPanel/TiddlerFields" mode="block" />
</div>
</$genesis>
</$let>
""">>
When used in the view template, the state tiddler title could be derived from the current tiddler, e.g. `<$let dynannotateText={{{ [<currentTiddler>addprefix[$:/state/dynannotate/]get[text]] }}}>`, to configure highlights for each tiddler separately.
<$codeblock code={{$:/plugins/tiddlywiki/dynannotate/examples/viewtemplate/text}}/>
@@ -15,7 +15,7 @@ Structure for modelling mapping between a string and its representation in the D
var PREFIX_SUFFIX_LENGTH = 50;
/*
Build a map of the text content of a DOM node and its descendants:
Build a map of the text content of a dom node and its descendents:
string: concatenation of the text content of child nodes
metadata: array of {start,end,domNode} where start and end identify position in the string
@@ -60,7 +60,7 @@ exports.TextMap.prototype.locateMetadata = function(position) {
};
/*
Search for the first occurrence of a target string within the textmap of a DOM node
Search for the first occurance of a target string within the textmap of a dom node
Returns an object with the following properties:
startNode: node containing the start of the text
@@ -92,10 +92,10 @@ exports.TextMap.prototype.findText = function(targetString,targetPrefix,targetSu
};
/*
Search for all occurrences of a string within the textmap of a DOM node
Search for all occurances of a string within the textmap of a dom node
Options include:
mode: "normal", "literal", "regexp", "whitespace", "some" or "words"
mode: "normal", "regexp" or "whitespace"
caseSensitive: true if the search should be case sensitive
Returns an array of objects with the following properties:
@@ -121,11 +121,6 @@ exports.TextMap.prototype.search = function(searchString,options) {
regExpString = "(" + searchString.split(/\s+/g).filter(function(word) {
return !!word
}).map($tw.utils.escapeRegExp).join("\\s+") + ")";
} else if(options.mode === "words" || options.mode === "some") {
// Match any word separated by whitespace
regExpString = "(" + searchString.split(/\s+/g).filter(function(word) {
return !!word
}).map($tw.utils.escapeRegExp).join("|") + ")";
} else {
// Normal search
regExpString = "(" + $tw.utils.escapeRegExp(searchString) + ")";
-10
View File
@@ -34,16 +34,6 @@ tags: [[$:/tags/Stylesheet]]
animation: ta-dynannotation-search-overlay-animated 12s linear infinite;
}
.tc-dynannotate-example-frame {
border: 1px solid black;
border-radius: 20px;
padding: 1em;
}
.tc-control-panel table.tc-dynannotate-search-parameters, .tc-control-panel table.tc-dynannotate-search-parameters input {
width: initial;
}
.tc-dynannotate-snippet-highlight {
background: #efef53;
}