-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat: serialize AST node back to wikitext string #8258
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. |
The LLM prompt
|
All tests passed, opened for review. |
Hi @linonetwo this is looking very promising. It is going to be hard to manually check all the new serialiser functions so we really need to make the tests solid. I have two suggestions:
|
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: