tarasglek / chatcraft.org

Developer-oriented ChatGPT clone
https://chatcraft.org/
MIT License
155 stars 35 forks source link

Experiment with rehype-tree-sitter #334

Open humphd opened 10 months ago

humphd commented 10 months ago

Our React Markdown renderer uses plugins to parse and alter what it displays, including Rehype:

https://github.com/tarasglek/chatcraft.org/blob/029165e1f53e7aef8d6df1a35dcd1561ee09a6bb/src/components/Markdown.tsx#L62

https://github.com/haze/rehype-tree-sitter is supposedly a good syntax highlighter. What we use now works, but is not well maintained. We could do an experiment to try this.

tarasglek commented 9 months ago

Good testcase would be hashicorp hcl. It's something we don't support atm, but it exists at https://tree-sitter.github.io/tree-sitter/

source "amazon-ebs" "example" {
  ami_name           = "CI/CD {{timestamp}}"
  instance_type      = "t3.micro"
  region             = "us-east-1"
  ssh_username       = "ubuntu"
  source_ami_filter {
    filters = {
      "name"                = "ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"
      "root-device-type"    = "ebs"
      "virtualization-type" = "hvm"
    }

currently we can't render packer hcl

humphd commented 9 months ago

I did a test with this, and it doesn't look ready for use. No TypeScript support, fails to build properly with vite, etc. We might want to let it bake a bit more.

tarasglek commented 9 months ago

sadness