Skip to content

armgit / hypit

Public Imported from GitHub
0

Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.

fix: count selection nesting by position, not by line

rpone847e9dfb808d
diff --git a/docs/.vitepress/theme/components/SemanticVideoDemo.vue b/docs/.vitepress/theme/components/SemanticVideoDemo.vue
index 88d80404..c69ededa 100644
--- a/docs/.vitepress/theme/components/SemanticVideoDemo.vue
+++ b/docs/.vitepress/theme/components/SemanticVideoDemo.vue
@@ -37,27 +37,49 @@ const sourceLines = config.lines;
const sceneSelections = config.selections.filter((selection) => selection.layer === "scene");
const overlaySelections = config.selections.filter((selection) => selection.layer === "overlay");
+type Point = { line: number; column: number };
+
type RangeBounds = {
id: string;
start: number;
end: number;
+ opensAt: Point;
+ closesAt: Point;
depth: number;
};
type DisplayLine = SourceDisplayEntry<DemoSourceLine>;
-const rawBounds = config.selections.map((selection) => ({
- id: selection.id,
- start: sourceLines.findIndex((line) => line.html.includes(`>@${selection.id}</span>`)),
- end: sourceLines.findIndex((line) => line.html.includes(`>@/${selection.id}</span>`)),
-})).filter((range) => range.start >= 0 && range.end >= range.start);
+/**
+ * Containment is measured at (line, column), not by line number alone. Two
+ * markers can share a line — one closing exactly where the next opens — and
+ * comparing only line numbers counts those siblings as nested, colouring one of
+ * them a level deeper than the items beside it.
+ */
+function atOrBefore(a: { line: number; column: number }, b: { line: number; column: number }) {
+ return a.line !== b.line ? a.line < b.line : a.column <= b.column;
+}
+
+const rawBounds = config.selections.map((selection) => {
+ const open = `>@${selection.id}</span>`;
+ const close = `>@/${selection.id}</span>`;
+ const start = sourceLines.findIndex((line) => line.html.includes(open));
+ const end = sourceLines.findIndex((line) => line.html.includes(close));
+ return {
+ id: selection.id,
+ start,
+ end,
+ opensAt: { line: start, column: start < 0 ? -1 : sourceLines[start].html.indexOf(open) },
+ closesAt: { line: end, column: end < 0 ? -1 : sourceLines[end].html.indexOf(close) },
+ };
+}).filter((range) => range.start >= 0 && range.end >= range.start);
const rangeBounds: RangeBounds[] = rawBounds.map((range) => ({
...range,
depth: rawBounds.filter((candidate) => (
candidate.id !== range.id
- && candidate.start <= range.start
- && candidate.end >= range.end
+ && atOrBefore(candidate.opensAt, range.opensAt)
+ && atOrBefore(range.closesAt, candidate.closesAt)
)).length,
}));
diff --git a/docs/.vitepress/theme/components/SvmlPlayground.vue b/docs/.vitepress/theme/components/SvmlPlayground.vue
index 4ca6b1f4..82c66880 100644
--- a/docs/.vitepress/theme/components/SvmlPlayground.vue
+++ b/docs/.vitepress/theme/components/SvmlPlayground.vue
@@ -149,25 +149,47 @@ const lines: SourceLine[] = [
{ html: '<span class="syn-tag">&lt;/broll-track&gt;</span>' },
];
+type Point = { line: number; column: number };
+
type SemanticRangeBounds = {
id: SelectionId;
start: number;
end: number;
+ opensAt: Point;
+ closesAt: Point;
depth: number;
};
-const rawRangeBounds = semanticSelections.map((selection) => ({
- id: selection.id,
- start: lines.findIndex((line) => line.html.includes(`>@${selection.id}</span>`)),
- end: lines.findIndex((line) => line.html.includes(`>@/${selection.id}`)),
-})).filter((range) => range.start >= 0 && range.end >= range.start);
+/**
+ * Containment is measured at (line, column), not by line number alone. Two
+ * markers can share a line — one closing exactly where the next opens — and
+ * comparing only line numbers counts those siblings as nested, colouring one of
+ * them a level deeper than the items beside it.
+ */
+function atOrBefore(a: { line: number; column: number }, b: { line: number; column: number }) {
+ return a.line !== b.line ? a.line < b.line : a.column <= b.column;
+}
+
+const rawRangeBounds = semanticSelections.map((selection) => {
+ const open = `>@${selection.id}</span>`;
+ const close = `>@/${selection.id}`;
+ const start = lines.findIndex((line) => line.html.includes(open));
+ const end = lines.findIndex((line) => line.html.includes(close));
+ return {
+ id: selection.id,
+ start,
+ end,
+ opensAt: { line: start, column: start < 0 ? -1 : lines[start].html.indexOf(open) },
+ closesAt: { line: end, column: end < 0 ? -1 : lines[end].html.indexOf(close) },
+ };
+}).filter((range) => range.start >= 0 && range.end >= range.start);
const semanticRangeBounds: SemanticRangeBounds[] = rawRangeBounds.map((range) => ({
...range,
depth: rawRangeBounds.filter((candidate) => (
candidate.id !== range.id
- && candidate.start <= range.start
- && candidate.end >= range.end
+ && atOrBefore(candidate.opensAt, range.opensAt)
+ && atOrBefore(range.closesAt, candidate.closesAt)
)).length,
}));
diff --git a/docs/zh/guide/caption-playground.md b/docs/zh/guide/caption-playground.md
deleted file mode 100644
index 56c476ae..00000000
--- a/docs/zh/guide/caption-playground.md
+++ /dev/null
@@ -1,34 +0,0 @@
----
-title: 字幕 Playground
-description: 直接编辑真实 Fine Caption SVS 配方与精确字体栈,并实时查看结果。
----
-
-# 字幕 Playground
-
-字幕样式确实需要可视化编辑,但编辑器不能变成第二套作者系统。字幕
-Playground 直接读写普通 Build 使用的同一份 `.svml` 与 `.svs`。
-
-```bash
-pnpm caption:playground -- \
- --source examples/talking-film-graph-check/main.svml \
- --style base-caption \
- --display story.caption \
- --recipe examples/talking-film-graph-check/studio.svs#caption.base \
- --font examples/talking-film-graph-check/main.svml#caption-font \
- --canvas 1080x1920 \
- --fps 30
-```
-
-打开 `http://localhost:5178`。
-
-启动命令显式选择源码、Style 导出、Display 导出、SVS Recipe、字体栈以及本地预览画布。系统没有中央组件注册表、隐藏默认样式或
-Playground 私有工程文件。
-
-表单编辑的是作者语汇,例如 `size`、`padding`、`fill`,不会暴露
-`fontSizePx`、`paddingXPx` 之类编译 DTO。字体家族、字重、字形只在
-SVML 的 `<fonts:Stack>` 中声明;SVS 负责字号、位置、绘制、文字盒、卡拉 OK 与动画。
-
-字体画廊使用每种开源字体自己的固定字节直接展示。选择字体会原子地修改真实字体栈并重新编译。编辑器或 Agent 修改同一文件也会触发刷新;浏览器提交时带有旧文件摘要,过期写入不会覆盖更新内容。
-
-为了拖动查看动画,浏览器会临时安排一条展示时间线。这条时间线不写入
-Record、SemanticMap、BuildState 或源文件,不会把猜测时间传播进图中。