Comments (3)
Nevermind, we arent getting a nix lezer parser.
from motion-canvas.
https://github.com/tree-sitter/node-tree-sitter
Seems to almost match the api you use already.
from motion-canvas.
Here's a really simple example of using the shell
parser from @codemirror/legacy-modes
(There's a few more parsers there than the 15 you've mentioned):
Source code
import {StreamLanguage} from '@codemirror/language';
import {shell} from '@codemirror/legacy-modes/mode/shell';
import {Code, LezerHighlighter, makeScene2D} from '@motion-canvas/2d';
import {createRef, waitFor} from '@motion-canvas/core';
const Bash = new LezerHighlighter(StreamLanguage.define(shell).parser);
export default makeScene2D(function* (view) {
const code = createRef<Code>();
view.add(
<Code
ref={code}
fontSize={28}
highlighter={Bash}
fontFamily={'JetBrains Mono, monospace'}
offsetX={-1}
x={-600}
code={`\
#!/bin/bash
# start the server in HTTPS mode
cd web
sudo node ../server.js 443 'yes' >> ../node.log &
# here is how to stop the server
for pid in \`ps aux | grep 'node ../server.js' | awk '{print $2}'\` ; do
sudo kill -9 $pid 2> /dev/null
done
exit 0
`}
/>,
);
yield* waitFor(0.6);
});
https://github.com/tree-sitter/node-tree-sitter
Seems to almost match the api you use already.
The rendering part of Motion Canvas doesn't run on Node.js. You'd need the WASM bindings.
The API is similar because Lezer is based on Treesitter.
I'm closing this issue because I'm not interested in working on this in the context of this repository.
The CodeHighlighter
interface is independent of Lezer and can be used to integrate any parser/highlighter solution into Motion Canvas without changing our code. When designing the interface, I made sure to account for Treesitter as that's what I used for prototyping.
Sadly, their documentation (both the wasm and node.js one) does not describe how to highlight the parsed tree so I gave up on the implementation and went for Lezer.
If anyone wants to give Treesitter a try, they can easily do that in their own npm package because, again, it's just a matter of implementing an interface - no changes to this repo necessary. Once a package like this exists I'll gladly talk about upstreaming it here.
from motion-canvas.
Related Issues (20)
- Possibility of using Webcodecs for fast rendering HOT 3
- Video stuttering in editor/presentation mode
- Animating `Txt`'s text with emojis causes broken characters HOT 1
- Automatically set the video's speed based on the desired duration
- Tweening the number of points in a line hangs the page
- Animating a `Rect`'s `size` and `padding` simultaneously causes snapping HOT 1
- Project Selection - Project File Name Must be Different HOT 2
- `lineColor` alias for `stroke` HOT 2
- Audio appears choppy in Brave browser HOT 2
- Getting chroma_js error on Quickstart HOT 3
- Add support for programmatically playing sound effects
- LaTeX: if you isolate invisible delimiters they don't work HOT 1
- Improve documentation for Polynomials HOT 1
- `<Latex/>`'s `stroke` doesn't work
- Animating `tex` and `fontSize` of `Latex` at the same time doesn't let `fontSize` animate HOT 1
- Error to run built animations
- Question about absolutePosition HOT 1
- Code component BBox doesn't take into account transitions
- Incorrect animation to color #000000 HOT 1
- `Video.completion` overrides `Curve.completion`
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 motion-canvas.