Skip to content

feat: filter serialize, and mvvdisplayinline serializer#9722

Open
linonetwo wants to merge 7 commits into
TiddlyWiki:masterfrom
linonetwo:feat/mvv-ast-seri
Open

feat: filter serialize, and mvvdisplayinline serializer#9722
linonetwo wants to merge 7 commits into
TiddlyWiki:masterfrom
linonetwo:feat/mvv-ast-seri

Conversation

@linonetwo

@linonetwo linonetwo commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

#8258 (comment) request add serialize for inline-MVV syntax.

And I find adding serialize for filter expression is very simple, so I do it together.

…isplayinline

- Add titleQuote CST metadata to filter parser for double/single/unquoted
  shorthand title syntax, enabling lossless round-trip serialization
- serializeFilterParseTree() now accepts maxRunsPerLine / wrapAt / indent
  options for formatter/linter support
- Add serializeFilterParseTree() utility (filter.js) to wikitext-serialize plugin
- Add mvvdisplayinline serializer rule to wikitext-serialize plugin
- Add tests for all of the above
- Add 5.5.0 release note folder and change note (PR number TBD)
Copilot AI review requested due to automatic review settings March 10, 2026 12:40
@netlify

netlify Bot commented Mar 10, 2026

Copy link
Copy Markdown

Deploy Preview for tiddlywiki-previews ready!

Name Link
🔨 Latest commit b3c2fe4
🔍 Latest deploy log https://app.netlify.com/projects/tiddlywiki-previews/deploys/69b1602a57a7af00082fd0f6
😎 Deploy Preview https://deploy-preview-9722--tiddlywiki-previews.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

Copy link
Copy Markdown

Confirmed: linonetwo has already signed the Contributor License Agreement (see contributing.md)

@github-actions

github-actions Bot commented Mar 10, 2026

Copy link
Copy Markdown

📊 Build Size Comparison: empty.html

Branch Size
Base (master) 2486.7 KB
PR 2487.2 KB

Diff: ⬆️ Increase: +0.6 KB


✅ Change Note Status

All change notes are properly formatted and validated!

📝 $:/changenotes/5.5.0/#9722

Type: enhancement | Category: developer
Release: 5.5.0

Filter serialization

🔗 #9722

👥 Contributors: linonetwo


📖 Change Note Guidelines

Change notes help track and communicate changes effectively. See the full documentation for details.

@linonetwo
linonetwo marked this pull request as draft March 10, 2026 12:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds enhanced filter serialization support to the wikitext-serialize plugin, enabling CST quote-style round-tripping for shorthand title filters and introducing basic formatting/wrapping options. Also adds a serializer for the mvvdisplayinline wiki rule and corresponding tests/release note entry.

Changes:

  • Add $tw.utils.serializeFilterParseTree(tree, options) with shorthand-title quote preservation and optional wrapping (maxRunsPerLine, wrapAt, indent)
  • Extend $tw.wiki.parseFilter() to annotate shorthand title operators with titleQuote CST metadata
  • Add mvvdisplayinline rule serializer plus new unit tests and serialize-spec fixture

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
plugins/tiddlywiki/wikitext-serialize/utils/filter.js New filter AST → string serializer with CST quote round-trip and formatting options
plugins/tiddlywiki/wikitext-serialize/rules/mvvdisplayinline.js New wikiruleserializer for ((var)) / (((filter))) inline display syntax
core/modules/filters.js Annotate shorthand title operators with titleQuote during filter parsing
editions/test/tiddlers/tests/test-filter-serialize.js Unit tests for filter serialization + CST quote preservation + formatting options
editions/test/tiddlers/tests/data/serialize/MvvDisplayInline.tid Wikitext-serialize fixture cases for mvvdisplayinline
editions/tw5.com/tiddlers/releasenotes/5.5.0/#PRNUM.tid Change note describing the new filter serialization behavior/options

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugins/tiddlywiki/wikitext-serialize/utils/filter.js
Comment thread plugins/tiddlywiki/wikitext-serialize/utils/filter.js Outdated
var filter = "[tag[a]] [tag[b]] [tag[c]] [tag[d]]";
var tree = $tw.wiki.parseFilter(filter);
var serialized = $tw.utils.serializeFilterParseTree(tree, {maxRunsPerLine: 2});
expect(serialized).toBe("[tag[a]] [tag[b]]\n [tag[c]] [tag[d]]");

@pmario pmario Mar 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the linebreak before the space? IMO it should be after the space, or the space should be replaced by the line-break.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm testing lint/format of filter expression, this should be configuable. Usually when hard wrap a line, there is an indent.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or I could remove this, leave formatting to future. This API is not good enough.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, if there is a configured linebreak, adding the indent parameter will also happen. So IMO the default should use the same logic as indent, with an empty "". So the logic is the same as indent. Only the test output will be different.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is more configuable now

…onsolidate tests

- serializeOperator: handle deprecated regexp operands /pattern/(flags)
- serializeFilterParseTree: skip empty operations (zero operators)
- serializeFilterParseTree: clarify wrap separator logic (space replaced by newline+indent, no trailing space)
- mvvdisplayinline.js: convert to ES2017 (const/let, template literals, destructuring)
- test-filter-serialize.js: consolidate 31 individual tests into 8 grouped tests
@linonetwo linonetwo changed the title feat: filter serialize CST quote round-trip, formatting options, and mvvdisplayinline serializer feat: filter serialize, and mvvdisplayinline serializer Mar 10, 2026
@linonetwo
linonetwo marked this pull request as ready for review March 11, 2026 12:31
@linonetwo

Copy link
Copy Markdown
Contributor Author

I believe filter expression don't have recursion or tree structure, so its serialization is a simple map-reduce.

@Jermolene

Copy link
Copy Markdown
Member

Excellent idea thank you @linonetwo

@saqimtiaz saqimtiaz moved this to Needs feedback in Planning for v5.5.0 Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs feedback

Development

Successfully merging this pull request may close these issues.

5 participants