mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-04-20 13:51:31 +00:00
Tweak headline changenotes
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
title: $:/changenotes/5.4.0/#8258
|
||||
description: Add ability to serialize WikiText AST nodes back to wikitext strings
|
||||
description: Core plugin to serialize syntax trees back to strings
|
||||
tags: $:/tags/ChangeNote
|
||||
release: 5.4.0
|
||||
change-type: feature
|
||||
@@ -7,32 +7,8 @@ change-category: developer
|
||||
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/8258
|
||||
github-contributors: linonetwo
|
||||
|
||||
This PR introduces a new utility `$tw.utils.serializeWikitextParseTree()` that can convert WikiText Abstract Syntax Tree (AST) nodes back into wikitext strings.
|
||||
This is an internal change that will only be of direct interest to plugin developers but will form the basis of future user-facing features. For example:
|
||||
|
||||
There is also a utility `serializeAttribute` for a single attribute node, like an attribute of a widget.
|
||||
|
||||
!! Use Cases
|
||||
|
||||
* Programmatically manipulating wikitext content by modifying the AST, and use this to write it back
|
||||
* Programmatically manipulating wikitext content by modifying the syntax tree and deserializing it back to wikitext
|
||||
* Building WYSIWYG editors
|
||||
* Creating wikitext formatters and linters
|
||||
|
||||
!! Implementation
|
||||
|
||||
* New core plugin `tiddlywiki/wikitext-serialize` containing most of the logic
|
||||
* Separate serialize handlers for each WikiText rule as `module-type: wikiruleserializer`
|
||||
* Test suite with tag `$:/tags/wikitext-serialize-test-spec`
|
||||
* It uses each parser's name as rule (`nextMatch.rule.name`), each AST node that needs serialization has a `type` property matching the rule name
|
||||
** HTML tags and widgets are handled by the `html` serializer
|
||||
|
||||
!! Example Usage
|
||||
|
||||
```javascript
|
||||
// Parse a tiddler's wikitext to AST
|
||||
var parseTree = $tw.wiki.parseTiddler("MyTiddler").tree;
|
||||
|
||||
// Serialize AST back to wikitext string
|
||||
var wikitextString = $tw.utils.serializeWikitextParseTree(parseTree).trimEnd();
|
||||
```
|
||||
|
||||
This feature offers new tools for JS plugin developers. It is not a user-facing change.
|
||||
* Creating WikiText formatters and linters
|
||||
|
||||
@@ -7,36 +7,19 @@ change-category: hackability
|
||||
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/9055
|
||||
github-contributors: Jermolene
|
||||
|
||||
This PR extends the handling of macro/procedure/function made via the `<<..>>` syntax to allow parameters to be specified dynamically instead of just as static strings. To indicate the new syntax the colon that usually separates a parameter name from its value is replaced by an equals sign.
|
||||
|
||||
For example, by it is now possible to do things like this:
|
||||
This PR extends the handling of macro/procedure/function invocationsmade via the `<<..>>` shortcut syntax to allow dynamic parameters instead of just static strings. To indicate the new syntax the colon that usually separates a parameter name from its value is replaced by an equals sign. For example:
|
||||
|
||||
```
|
||||
<<mymacro param={{Something}}>>
|
||||
```
|
||||
|
||||
Or even this:
|
||||
|
||||
```
|
||||
<div class=<<mymacro param={{Something}}>>>
|
||||
```
|
||||
|
||||
Or this:
|
||||
|
||||
```
|
||||
<div class=<<mymacro param={{{ [<myvar>addprefix[https:] }}}>>>
|
||||
```
|
||||
|
||||
Parameters can also be specified for the inner call:
|
||||
|
||||
```
|
||||
<div class=<<mymacro param={{{ [<innermacro p={{Something}}>addprefix[https:] }}}>>>
|
||||
```
|
||||
|
||||
The extended syntax can be used in three different settings:
|
||||
The extended syntax allows parameter values to be passed as transclusions, filter expressions or nested invocations in three settings:
|
||||
|
||||
* As a standalone construction
|
||||
* As a widget attribute value
|
||||
* As a filter operand value
|
||||
|
||||
In all cases, it is now possible to use an equals sign instead of a colon to allow parameter values to be passed as a transclusion, filter expression or nested call.
|
||||
See [[Calls]] for more details and examples.
|
||||
|
||||
Reference in New Issue
Block a user