create-thally-docs 0.10.104 → 0.10.105

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -39,6 +39,9 @@ function parseFrontmatter(raw) {
39
39
 
40
40
  // src/check.ts
41
41
  import { parse as parseYaml2 } from "yaml";
42
+ import remarkMdx2 from "remark-mdx";
43
+ import remarkParse2 from "remark-parse";
44
+ import { unified as unified2 } from "unified";
42
45
 
43
46
  // src/openapi-publication.ts
44
47
  var METHODS = ["get", "post", "put", "patch", "delete", "options", "head", "trace"];
@@ -492,14 +495,48 @@ function renderedHeadingText(source) {
492
495
  }
493
496
  return visible;
494
497
  }
498
+ var mdxParser = unified2().use(remarkParse2).use(remarkMdx2);
499
+ function stringAttribute(node, name) {
500
+ const attribute = node.attributes?.find((item) => item.type === "mdxJsxAttribute" && item.name === name);
501
+ if (!attribute) return void 0;
502
+ return typeof attribute.value === "string" ? attribute.value : null;
503
+ }
504
+ function extractStepHeadings(content) {
505
+ if (!content.includes("<Step")) return [];
506
+ let tree;
507
+ try {
508
+ tree = mdxParser.parse(content);
509
+ } catch {
510
+ return [];
511
+ }
512
+ const steps = [];
513
+ const visit = (node, stepSize) => {
514
+ let childSize = stepSize;
515
+ if (node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement") {
516
+ if (node.name === "Steps") childSize = stringAttribute(node, "titleSize") ?? void 0;
517
+ if (node.name === "Step") {
518
+ const own = stringAttribute(node, "titleSize");
519
+ const size = own === void 0 ? stepSize : own;
520
+ const title = stringAttribute(node, "title")?.trim();
521
+ if (title && size && ["h2", "h3", "h4"].includes(size)) {
522
+ const id = stringAttribute(node, "id")?.trim();
523
+ steps.push({ line: node.position?.start.line ?? 0, base: id || slugify(title), explicit: !!id });
524
+ }
525
+ }
526
+ }
527
+ for (const child of node.children ?? []) visit(child, childSize);
528
+ };
529
+ visit(tree, void 0);
530
+ return steps;
531
+ }
495
532
  function extractHeadingAnchors(content) {
496
533
  const anchors = /* @__PURE__ */ new Set();
497
534
  const headings = [];
498
- forEachNonFencedLine(content, (line) => {
535
+ forEachNonFencedLine(content, (line, lineNumber) => {
499
536
  const heading = /^ {0,3}#{1,6}\s+(.+?)\s*#*\s*$/.exec(line);
500
537
  if (heading) {
501
538
  const explicit = /\{\/\*\s*#(\S+?)\s*\*\/\}$/.exec(heading[1]);
502
- headings.push({ base: explicit?.[1] ?? slugify(renderedHeadingText(heading[1])), explicit: !!explicit });
539
+ headings.push({ base: explicit?.[1] ?? slugify(renderedHeadingText(heading[1])), explicit: !!explicit, line: lineNumber });
503
540
  }
504
541
  for (const idMatch of line.matchAll(EXPLICIT_ID_ATTRIBUTE)) {
505
542
  const id = idMatch[1] ?? idMatch[2] ?? idMatch[3];
@@ -510,6 +547,8 @@ function extractHeadingAnchors(content) {
510
547
  if (name) anchors.add(name);
511
548
  }
512
549
  });
550
+ headings.push(...extractStepHeadings(content));
551
+ headings.sort((left, right) => left.line - right.line);
513
552
  const reserved = new Set(headings.filter((heading) => heading.explicit).map((heading) => heading.base));
514
553
  const used = /* @__PURE__ */ new Set();
515
554
  const occurrences = /* @__PURE__ */ new Map();
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  parseFrontmatter,
7
7
  runCheck
8
- } from "./chunk-2UHO52SA.js";
8
+ } from "./chunk-WV3IBK42.js";
9
9
  import "./chunk-KDLP27DS.js";
10
10
  import {
11
11
  logo,
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runCheck
4
- } from "./chunk-2UHO52SA.js";
4
+ } from "./chunk-WV3IBK42.js";
5
5
  import "./chunk-KDLP27DS.js";
6
6
  import "./chunk-J7255UQA.js";
7
7
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-thally-docs",
3
- "version": "0.10.104",
3
+ "version": "0.10.105",
4
4
  "description": "Scaffold an open-source Thally docs site for people, search engines, and AI tools.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -53,8 +53,8 @@
53
53
  "@anthropic-ai/sdk": "^0.36.0",
54
54
  "@clack/prompts": "^0.11.0",
55
55
  "@inquirer/prompts": "^7.0.0",
56
- "@thallylabs/core": "0.2.15",
57
- "@thallylabs/migrate": "0.2.32",
56
+ "@thallylabs/core": "0.2.16",
57
+ "@thallylabs/migrate": "0.2.33",
58
58
  "p-limit": "^6.1.0",
59
59
  "remark-mdx": "^3.1.1",
60
60
  "remark-parse": "^11.0.0",