Comments (11)
Add
rule = exports.name
field to ast node
See e4c682d where this has been implemented.
Part of the problem that still remains is that the parse tree does not have enough information about whitespace, comments and pragma so recreating the original wikitext still isn't possible.
from tiddlywiki5.
Need to get original wikitext from AST, when writing WYSIWYG editor.
That's not really possible at the moment. While we did add a lot of new start
and end
positions to the AST lately, the <!-- comments -->
are not there. So at the moment it's kind of impossible to create lossless wikitext from the TW AST.
I also think there is not enough information about function, procedure calls in the AST. eg: <<test>>
and <$macrocall $name=test
may not be distinguishable. -- But I'm not really sure about that one. -- But "The devil is in the details" atm
from tiddlywiki5.
There is an unused method getParseTreeText
, it used to work for text-slicer plugin, but it's useless now.
Old usage (don't exist anymore): https://github.com/eyecatchup/TiddlyWiki5/blob/72ed4b26731dd3bbac948af6965b050f33ed1c1c/plugins/tiddlywiki/text-slicer/slicer.js#L79C23-L79C39
Usage: $tw.utils.getParseTreeText($tw.wiki.parseTiddler('HelloThere').tree)
I can gradually add wiki rule support to it. Not need to be lostless, it only need to handle 80% of everyday usecase. People who use WYSIWYG editor won't write comment or procedure, support for then can be delayed.
See e4c682d where this has been implemented.
I see. This is not very obvious. I was only reading files in core\modules\parsers\wikiparser\rules
from tiddlywiki5.
Thanks @linonetwo I hadn't noticed that getParseTreeText()
is no longer used.
I can gradually add wiki rule support to it. Not need to be lostless, it only need to handle 80% of everyday usecase. People who use WYSIWYG editor won't write comment or procedure, support for then can be delayed.
getParseTreeText()
is intended to just extract the value of text nodes. I think you're proposing a function to convert a parse tree back to wiki text? I would think that that should be a separate function.
I take your point that it wouldn't be necessary to handle all wikitext constructions. It would be interesting to see how complex the implementation would be, but if it's not excessive then I would be happy to see that go into the core.
from tiddlywiki5.
I take your point that it wouldn't be necessary to handle all wikitext constructions. It would be interesting to see how complex the implementation would be, but if it's not excessive then I would be happy to see that go into the core.
I think @flibbles knows best, what's needed for a "rewrite" of tiddler content. IMO the relink-plugin does exactly that.
@linonetwo -- I would have a closer look at the relink-AST (if there is one) and I would try to get or reuse the API from the relink plugin. Most users who want to use WYSIWYG will need the relink-plugin anyway.
from tiddlywiki5.
Yes, this is interesting, how relink works when there was no start/end pos in the AST?
After reading for a while, I find it is simply use regex to replace old value, not using AST
from tiddlywiki5.
... I find it is simply use regex to replace old value, not using AST
That may be true. @flibbles -- should know exactly.
from tiddlywiki5.
Yes, this is interesting, how relink works when there was no start/end pos in the AST?
After reading for a while, I find it is simply use regex to replace old value, not using AST
You're looking at the method used to handle substitution attributes. Relink doesn't just use regexp. It also doesn't utilize the existing AST since it's incomplete for reproducing the original text. It modifies the Wikitext parser and has it "parse" text, with each wikitext rule module getting new report
and relink
methods. the "AST" it produces is the modified text.
from tiddlywiki5.
@Jermolene Need to add a new parse rule type
exports.name = "commentblock";
exports.types = {void:true, block:true, pragma:true};
When adding void:true
, the AST node will not be rendered.
Currently without this, commentblock / parsermode will render to some text, cause style error, because they break the stylesheet tiddlers.
from tiddlywiki5.
@Jermolene Need to add a new parse rule type
Yes, that sounds like a reasonable solution.
from tiddlywiki5.
If you are interested, feel free to PR more test to #8258 . I've already pass all basic tests.
In some case, original whitespace is not preserved, may add/remove some of them to make result beautiful, like prettier. And user don't care about this, because in WYSIWYG editor, user don't care underlying text, they just want a text file so it feels safe.
from tiddlywiki5.
Related Issues (20)
- [BUG] float:right element overflows tiddler body.
- [BUG] User Defined Filter Operators Using Functions Do Not Work When Used in Filter Expression in FileSystemPaths HOT 5
- [BUG] Proposal Update to eslint v9.x HOT 2
- [BUG] TiddlyWiki Init Does Not Respect the File Attributes HOT 2
- [BUG] empty shortform transclusion should not do anything HOT 2
- [BUG] .tc-error-form positioning/size issue HOT 2
- [IDEA] add a 'format' attribute to EditTextWidget (and maybe others) HOT 2
- [IDEA] Apply :where() on all of the tiddlywiki styles to ensure the lowest specifity possible / avoid clash with user customisation HOT 2
- [BUG] Confusing Empty Message on Tag Picker DropDown HOT 1
- [BUG] Some list-*-draggable should not accept everything dragged HOT 1
- [BUG] Wrong text alignment Firefox Linux HOT 9
- [IDEA] It should be possible to hide edit toolbar buttons, but keep the keyboard shortcut active HOT 3
- [BUG] View widget's template attribute is broken HOT 8
- Article about Custom Clipboard Formats for the Web HOT 1
- [IDEA] Migrate copy to clipboard function to use native Clipboard API HOT 1
- [BUG] Tables in TW 5.3.6-prerelease Strangely Occupy the Whole Width and Distorts Columns HOT 4
- [BUG] MWS - tests fail on windows 11 - branch multi-wiki-support
- [BUG] HelloThere Cards do not adjust colours to selected palettes
- [BUG] Readme contains an empty "Stats" image HOT 1
- [BUG] disabled $droppable widgets "eat" dropped values
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tiddlywiki5.