Merge pull request #1894 from lightpanda-io/semantic-tree-interactive

SemanticTree: implement interactiveOnly filter and optimize token usage
This commit is contained in:
Adrià Arrufat
2026-03-18 22:33:45 +09:00
committed by GitHub
3 changed files with 86 additions and 24 deletions

View File

@@ -52,6 +52,7 @@ fn getSemanticTree(cmd: anytype) !void {
const Params = struct {
format: ?enum { text } = null,
prune: ?bool = null,
interactiveOnly: ?bool = null,
};
const params = (try cmd.params(Params)) orelse Params{};
@@ -64,12 +65,12 @@ fn getSemanticTree(cmd: anytype) !void {
.registry = &bc.node_registry,
.page = page,
.arena = cmd.arena,
.prune = params.prune orelse false,
.prune = params.prune orelse true,
.interactive_only = params.interactiveOnly orelse false,
};
if (params.format) |format| {
if (format == .text) {
st.prune = params.prune orelse true;
var aw: std.Io.Writer.Allocating = .init(cmd.arena);
defer aw.deinit();
try st.textStringify(&aw.writer);