forked from y-crdt/ypy
-
Notifications
You must be signed in to change notification settings - Fork 1
[USING, DON'T MERGE THO] Enable Lexical-style parsing #1
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
Open
zswaff
wants to merge
58
commits into
main
Choose a base branch
from
zack/enable-lexical-parsing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
cf619fd
Set up tests
zswaff e606efe
Improve comments
zswaff 4b1b72f
Update tests
zswaff d5785dc
Start implementing rust version and add JS version for reference
zswaff 9441f3d
Set up python binding for direct function
zswaff bec43ee
Added parse_nested_xml_text_nodes test
59379af
Clean up
022f618
Removed playground.ts
c1623a9
Clean up lexical parsing XML text nodes
cc486a1
Clean up tests
c3582f6
Reverted non related changes in tests
0f64aeb
Moved parse_nested_xml_text_nodes test to y_doc module
ef62cbd
Polish
zswaff 08bd33b
Tweak version to fix issues with pip resolution
zswaff fdbb622
Added more tests
bf079d5
Refactored, removed rust tests
6ce5e4d
Clean up
7bd93d4
Cleanup test
zswaff f2903d9
ypy reverse direction
54a944f
Tweak comments
zswaff 7f93c38
Tweak again
zswaff ae613ba
Merge pull request #2 from its-dart/ahonko/DA-54-ypy-reverse-direction
zswaff d8d5aa8
ypy enable ints and nulls
712cb3a
Merge pull request #3 from its-dart/ahonko/DA-148-ypy-enable-ints-and…
zswaff c61b1c7
Update version in Cargo.toml
zswaff 8a4c454
ypy use XmlText rather than XmlElement for tree
f9d0507
Clean up
627e0ef
Clean up
f8359b2
Merge pull request #4 from its-dart/ahonko/DA-159-ypy-use-XmlText-rat…
zswaff f9732ab
Update Cargo.toml
zswaff c6e6f17
Revert BigInt stuff
zswaff 93f432e
Simplify version
zswaff b9c796a
Merge pull request #5 from its-dart/zack/revert-bigint
zswaff c1accaf
Set up library workflow
zswaff ffa6bad
Update Cargo.toml
ahonko fcbd331
Install correct lib for testing
zswaff 8b09e9a
Keep improving wheel build process
zswaff b1ec2a0
Bump version
zswaff 3e21db2
Comment out macos tests
zswaff 0161dbd
Remove all mac tests
zswaff c4519c7
Rename package
zswaff 496a023
Bump version to get new y-crdt
zswaff d2b3a37
Revert package rename
zswaff a34b648
Bump pyo3 version
zswaff d519732
Bump pyo3 version
zswaff 8002cea
Fix version
zswaff 6720b0c
Create test
zswaff a2ecb74
Added parsing Element and Fragment XML nodes while processing Text node
8ec52e9
Fixed tests
52b1afc
Merge pull request #6 from its-dart/zack/parse-nested-elements
zswaff de73c6b
Bump version
zswaff e9d95e6
Attempt to enable pushing xml elements
zswaff 9bc1a79
Bump 0.6.3-alpha.18 version
37c2e4f
Fix wheels GH workflow
8c97274
Fix and clean up wheels GH workflow
5a2341c
Added support for binary data in attributes (#7)
jonathon-love 24019a2
Add node_modules to gitignore
f9ed0e5
Bump 0.6.3-alpha.19 version
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ahonko marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import * as Y from "yjs"; | ||
|
|
||
| const processNodeRecursive = (node: Y.XmlFragment | Y.Map<Y.Item> | Y.Text): Record<string, any> => { | ||
| const result = Object.fromEntries([...node._map].map(([k, v]) => [k, v.content.getContent()[0]])); | ||
| const children: Record<string, any>[] = []; | ||
|
|
||
| if ("firstChild" in node) { | ||
| let currentChild = node.firstChild; | ||
| while (currentChild) { | ||
| children.push(processNodeRecursive(currentChild)); | ||
| currentChild = currentChild.nextSibling; | ||
| } | ||
| result.children = children; | ||
| } | ||
|
|
||
| if ("toDelta" in node) { | ||
| node.toDelta().forEach(({ insert }: { insert?: Y.Map<Y.Item> | Y.Text}) => { | ||
| if (!insert) { | ||
| return; | ||
| } | ||
|
|
||
| if (typeof insert === "string") { | ||
| children[children.length - 1].text = insert; | ||
| return; | ||
| } | ||
|
|
||
| children.push(processNodeRecursive(insert)); | ||
| }); | ||
| result.children = children; | ||
| } | ||
|
|
||
| return result; | ||
| }; | ||
|
|
||
| const rawStateAsUpdate = '\x01a\x9CµäÏ\x0E\x00(\x01\x04root\x05__dir\x01w\x03ltr\x07\x01\x04root\x06(\x00\x9CµäÏ\x0E\x01\x06__type\x01w\tparagraph(\x00\x9CµäÏ\x0E\x01\b__format\x01}\x00(\x00\x9CµäÏ\x0E\x01\b__indent\x01}\x00(\x00\x9CµäÏ\x0E\x01\x05__dir\x01w\x03ltr\x07\x00\x9CµäÏ\x0E\x01\x01(\x00\x9CµäÏ\x0E\x06\x06__type\x01w\x04text(\x00\x9CµäÏ\x0E\x06\b__format\x01}\x00(\x00\x9CµäÏ\x0E\x06\x07__style\x01w\x00(\x00\x9CµäÏ\x0E\x06\x06__mode\x01}\x00(\x00\x9CµäÏ\x0E\x06\b__detail\x01}\x00\x84\x9CµäÏ\x0E\x06\x01a\x87\x9CµäÏ\x0E\x01\x06(\x00\x9CµäÏ\x0E\r\x06__type\x01w\x04list(\x00\x9CµäÏ\x0E\r\b__format\x01}\x00(\x00\x9CµäÏ\x0E\r\b__indent\x01}\x00!\x00\x9CµäÏ\x0E\r\x05__dir\x01(\x00\x9CµäÏ\x0E\r\n__listType\x01w\x06number(\x00\x9CµäÏ\x0E\r\x05__tag\x01w\x02ol(\x00\x9CµäÏ\x0E\r\x07__start\x01}\x01\x07\x00\x9CµäÏ\x0E\r\x06(\x00\x9CµäÏ\x0E\x15\x06__type\x01w\blistitem(\x00\x9CµäÏ\x0E\x15\b__format\x01}\x00(\x00\x9CµäÏ\x0E\x15\b__indent\x01}\x00!\x00\x9CµäÏ\x0E\x15\x05__dir\x01(\x00\x9CµäÏ\x0E\x15\x07__value\x01}\x01\x01\x00\x9CµäÏ\x0E\x15\x01\x00\x05\x81\x9CµäÏ\x0E\x1B\x01\x84\x9CµäÏ\x0E\f\x01 \x87\x9CµäÏ\x0E"\x01(\x00\x9CµäÏ\x0E#\x06__type\x01w\x04text(\x00\x9CµäÏ\x0E#\b__format\x01}\x01(\x00\x9CµäÏ\x0E#\x07__style\x01w\x00(\x00\x9CµäÏ\x0E#\x06__mode\x01}\x00(\x00\x9CµäÏ\x0E#\b__detail\x01}\x00\x84\x9CµäÏ\x0E#\x01b¡\x9CµäÏ\x0E\x11\x01¡\x9CµäÏ\x0E\x19\x01¨\x9CµäÏ\x0E*\x01w\x03ltr¨\x9CµäÏ\x0E+\x01w\x03ltr\x87\x9CµäÏ\x0E!\x01(\x00\x9CµäÏ\x0E.\x06__type\x01w\x04text(\x00\x9CµäÏ\x0E.\b__format\x01}\x00(\x00\x9CµäÏ\x0E.\x07__style\x01w\x00(\x00\x9CµäÏ\x0E.\x06__mode\x01}\x00(\x00\x9CµäÏ\x0E.\b__detail\x01}\x00\x84\x9CµäÏ\x0E.\x01c\x81\x9CµäÏ\x0E\x15\x01\x00\x05\x87\x9CµäÏ\x0E5\x06(\x00\x9CµäÏ\x0E;\x06__type\x01w\blistitem(\x00\x9CµäÏ\x0E;\b__format\x01}\x00(\x00\x9CµäÏ\x0E;\b__indent\x01}\x00!\x00\x9CµäÏ\x0E;\x05__dir\x01(\x00\x9CµäÏ\x0E;\x07__value\x01}\x02\x07\x00\x9CµäÏ\x0E;\x06(\x00\x9CµäÏ\x0EA\x06__type\x01w\x04list(\x00\x9CµäÏ\x0EA\b__format\x01}\x00(\x00\x9CµäÏ\x0EA\b__indent\x01}\x00(\x00\x9CµäÏ\x0EA\x05__dir\x01w\x03ltr(\x00\x9CµäÏ\x0EA\n__listType\x01w\x06number(\x00\x9CµäÏ\x0EA\x05__tag\x01w\x02ol(\x00\x9CµäÏ\x0EA\x07__start\x01}\x01\x07\x00\x9CµäÏ\x0EA\x06(\x00\x9CµäÏ\x0EI\x06__type\x01w\blistitem(\x00\x9CµäÏ\x0EI\b__format\x01}\x00(\x00\x9CµäÏ\x0EI\b__indent\x01}\x00!\x00\x9CµäÏ\x0EI\x05__dir\x01(\x00\x9CµäÏ\x0EI\x07__value\x01}\x01¨\x9CµäÏ\x0EM\x01w\x03ltr\x07\x00\x9CµäÏ\x0EI\x01(\x00\x9CµäÏ\x0EP\x06__type\x01w\x04text(\x00\x9CµäÏ\x0EP\b__format\x01}\x00(\x00\x9CµäÏ\x0EP\x07__style\x01w\x00(\x00\x9CµäÏ\x0EP\x06__mode\x01}\x00(\x00\x9CµäÏ\x0EP\b__detail\x01}\x00\x84\x9CµäÏ\x0EP\x01d\x81\x9CµäÏ\x0EI\x01\x00\x05\x81\x9CµäÏ\x0E;\x01\x00\x05¨\x9CµäÏ\x0E?\x01~\x87\x9CµäÏ\x0E\r\x06(\x00\x9CµäÏ\x0Ed\x06__type\x01w\tparagraph(\x00\x9CµäÏ\x0Ed\b__format\x01}\x00(\x00\x9CµäÏ\x0Ed\b__indent\x01}\x00!\x00\x9CµäÏ\x0Ed\x05__dir\x01¨\x9CµäÏ\x0Eh\x01w\x03ltr\x07\x00\x9CµäÏ\x0Ed\x01(\x00\x9CµäÏ\x0Ej\x06__type\x01w\x04text(\x00\x9CµäÏ\x0Ej\b__format\x01}\x00(\x00\x9CµäÏ\x0Ej\x07__style\x01w\x00(\x00\x9CµäÏ\x0Ej\x06__mode\x01}\x00(\x00\x9CµäÏ\x0Ej\b__detail\x01}\x00\x84\x9CµäÏ\x0Ej\x01e\x01\x9CµäÏ\x0E\t\x11\x01\x19\x01\x1B\x07*\x025\x06?\x01M\x01W\fh\x01'; | ||
| const update = new Uint8Array([...rawStateAsUpdate].map((e) => e.charCodeAt(0))); | ||
| const doc = new Y.Doc(); | ||
| Y.applyUpdate(doc, update) | ||
| const root = doc.getXmlFragment("root"); | ||
| const result = processNodeRecursive(root); | ||
| console.log(JSON.stringify(result, null, 2)); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.