-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: serialize AST node back to wikitext string #8258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
First line is wrapped by a p element, but I haven't find the rule that produce the p element. And there was no p html in the source, so I may need to add some attribute to ast to show this p element is "fake". Anyway, this is just a demo for API, do you like the API name and their usage? The further task is just adding |
IMO the current parser has a "systemic" problem with redundant P-tags, that we probably may need to solve first. Working around this problem with "fake" elements will just increase your code complexity, instead of solving the underlaying problem. It will also create an other dependency, that will make solving the problem, in the core, in backwards compatible way even harder as it is now. |
core/modules/wiki.js
Outdated
}; | ||
|
||
exports.getParser = function(type,options) { | ||
options = $tw.utils.extend({},options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO your code will throw an RSOD if options is undefined
So options = options || {}
should be used instead. We use this pattern all over the places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copy $tw.utils.extend({},options)
from somewhere nearby, I thought this will work.
Can't remove then, many of my plugin style sheet is already depending on this structure. And Another option is handle it like text node, regard it as a special case. |
That's true, but we do have a lot of |
Handle the block rule by adding a I've added some test for it. |
Apologies @linonetwo I appreciate your patience. Now that this PR is planned for v5.4.0 it will be merged once we release v5.3.7, when we'll start v5.4.0. (While we could start v5.4.0 in another branch alongside the development of v5.3.7, the problem is that we would just be shifting the friction you are experiencing with merge conflicts to a different branch). |
📊 Build Size Comparison:
|
Branch | Size |
---|---|
Base (master) | 2528.4 KB |
PR | 2532.1 KB |
Diff: ⬆️ Increase: +3.7 KB
📊 Build Size Comparison:
|
Branch | Size |
---|---|
Base (master) | 2528.4 KB |
PR | 2532.1 KB |
Diff: ⬆️ Increase: +3.7 KB
Okay, I just help other PR fixing its test. Hope AI could help me do that in the future. Looking forward to v5.4.0. I check this PR regularly because when someone in QQ group ask me about WYSIWYG editor's bug I will talk about this PR once and check it... |
Any chance merging this? Do you think this new core plugin is feature completed? |
Hi @linonetwo I'm hoping we can merge #9135 in the next day or two, and then I believe we can start merging v5.4.0 PRs. |
@Jermolene IMO this PR is ready to be merged now. |
📊 Build Size Comparison:
|
Branch | Size |
---|---|
Base (master) | 2421.1 KB |
PR | 2424.8 KB |
Diff: ⬆️ Increase: +3.7 KB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a wikitext serialization feature that can convert parsed AST (Abstract Syntax Tree) nodes back to wikitext format. It implements a new plugin with serializers for various wikitext rules and utilities for reverse-engineering wikitext from parse trees.
Key changes:
- Adds comprehensive serialization support for most wikitext syntax elements
- Introduces a new
void
widget type for handling non-rendering nodes - Updates parser rules to include metadata needed for serialization
Reviewed Changes
Copilot reviewed 115 out of 117 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
plugins/tiddlywiki/wikitext-serialize/utils/parsetree.js | Core serialization utilities with main serializeWikitextParseTree function |
plugins/tiddlywiki/wikitext-serialize/rules/*.js | Individual serializers for each wikitext rule (tables, headings, emphasis, etc.) |
core/modules/widgets/void.js | New void widget for handling non-rendering parse tree nodes |
core/modules/parsers/wikiparser/rules/*.js | Updates to parser rules to add serialization metadata |
editions/test/tiddlers/tests/*.js | Test files and test data for serialization functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
plugins/tiddlywiki/wikitext-serialize/rules/filteredtranscludeblock.js
Outdated
Show resolved
Hide resolved
📊 Build Size Comparison:
|
Branch | Size |
---|---|
Base (master) | 2421.1 KB |
PR | 2424.8 KB |
Diff: ⬆️ Increase: +3.7 KB
…block.js Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
📊 Build Size Comparison:
|
Branch | Size |
---|---|
Base (master) | 2421.1 KB |
PR | 2424.8 KB |
Diff: ⬆️ Increase: +3.7 KB
Co-authored-by: Copilot <[email protected]>
📊 Build Size Comparison:
|
Branch | Size |
---|---|
Base (master) | 2421.1 KB |
PR | 2424.8 KB |
Diff: ⬆️ Increase: +3.7 KB
3 similar comments
📊 Build Size Comparison:
|
Branch | Size |
---|---|
Base (master) | 2421.1 KB |
PR | 2424.8 KB |
Diff: ⬆️ Increase: +3.7 KB
📊 Build Size Comparison:
|
Branch | Size |
---|---|
Base (master) | 2421.1 KB |
PR | 2424.8 KB |
Diff: ⬆️ Increase: +3.7 KB
📊 Build Size Comparison:
|
Branch | Size |
---|---|
Base (master) | 2421.1 KB |
PR | 2424.8 KB |
Diff: ⬆️ Increase: +3.7 KB
closes #8255
Currently just a demo, I will gradually move code from https://github.com/tiddly-gittly/wikiast/tree/master/packages/wikiast-util-to-wikitext to here.
Try it with tiddler (Well, if official website have share plugin installed, I can put a link here):
and run this in console: