matklad / djot-rs

36 stars 1 forks source link

ast from typescript #21

Open matklad opened 1 year ago

matklad commented 1 year ago

writing this down the second time, as I've already forgot this idea once :)

The end goal would be to define djot_ast.ts file which precisely specifies the JSON AST:

interface Doc {
  tag: "doc";
  attr: Record<string, string>;
  references: Record<string, ReferenceDefinition>;
  children: (Para | CodeBlock ... )[]
}

interface Para {
  tag: "para";
  ...
}

interface ReferenceDefinition {
  tag: "reference_definition";
  destination: string;
}

and generate the Rust AST from it.

Or rather, we probably want:

We could generate .ts also from some more compact representation, but I think hand-written .ts as a source of truth is probably the sweet spot.

matklad commented 1 year ago

cc https://github.com/jgm/djot/issues/95