@dogsbay/site-check 0.2.0-beta.161 → 0.2.0-beta.163

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.
@@ -1,4 +1,4 @@
1
- import { isRelativeHref, linkBaseDir, pageKeyCandidates, resolveLinkPath, splitHref } from "../links.js";
1
+ import { htmlHoldsLinks, isRelativeHref, linkBaseDir, pageKeyCandidates, resolveLinkPath, splitHref } from "../links.js";
2
2
  const EXTERNAL_RE = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
3
3
  const ANCHOR_ONLY_RE = /^#/;
4
4
  const DATA_URI_RE = /^data:/i;
@@ -57,7 +57,8 @@ function walkTree(nodes, visit) {
57
57
  for (const node of nodes) {
58
58
  if (node.inline)
59
59
  walkInline(node.inline, visit);
60
- if (node.html)
60
+ // A code block's `html` is its code: an HTML example's links are not the page's
61
+ if (node.html && htmlHoldsLinks(node))
61
62
  walkHtml(node.html, visit);
62
63
  if (node.props?.href && typeof node.props.href === "string") {
63
64
  visit(node.props.href, "link");
package/dist/links.d.ts CHANGED
@@ -15,6 +15,20 @@
15
15
  * Pure and dependency-free: dogsbay-ssg imports it into a Worker bundle.
16
16
  */
17
17
  /** A scheme (`https:`, `mailto:`, `javascript:`) or protocol-relative `//host`. */
18
+ /**
19
+ * Node types whose `html` is SOURCE TEXT shown on the page, not markup a browser follows: a code
20
+ * block keeps its code there (format-dogsbay-md), and an `<a href="index.html">` in an HTML
21
+ * example is code to show. `site build` rewrote it to a site path, and the link check read it as
22
+ * a link (dogsbay-ssg's comparison, 2026-11-04). Only raw HTML (`html`, `html-container`,
23
+ * `prose`…) holds links. The same list as @dogsbay/site-files' `TEXT_HTML_NODES` (a CLI test keeps
24
+ * them equal).
25
+ */
26
+ export declare const SOURCE_TEXT_NODES: ReadonlySet<string>;
27
+ /** Does this node's `html` hold links, or text to show as written? */
28
+ export declare function htmlHoldsLinks(node: {
29
+ type: string;
30
+ html?: unknown;
31
+ }): boolean;
18
32
  export declare function isExternalHref(href: string): boolean;
19
33
  /** Split "path#frag?q" into its path and the suffix (query and fragment), kept verbatim. */
20
34
  export declare function splitHref(href: string): {
package/dist/links.js CHANGED
@@ -15,6 +15,19 @@
15
15
  * Pure and dependency-free: dogsbay-ssg imports it into a Worker bundle.
16
16
  */
17
17
  /** A scheme (`https:`, `mailto:`, `javascript:`) or protocol-relative `//host`. */
18
+ /**
19
+ * Node types whose `html` is SOURCE TEXT shown on the page, not markup a browser follows: a code
20
+ * block keeps its code there (format-dogsbay-md), and an `<a href="index.html">` in an HTML
21
+ * example is code to show. `site build` rewrote it to a site path, and the link check read it as
22
+ * a link (dogsbay-ssg's comparison, 2026-11-04). Only raw HTML (`html`, `html-container`,
23
+ * `prose`…) holds links. The same list as @dogsbay/site-files' `TEXT_HTML_NODES` (a CLI test keeps
24
+ * them equal).
25
+ */
26
+ export const SOURCE_TEXT_NODES = new Set(["code", "math", "math-block", "diagram", "mermaid"]);
27
+ /** Does this node's `html` hold links, or text to show as written? */
28
+ export function htmlHoldsLinks(node) {
29
+ return typeof node.html === "string" && !SOURCE_TEXT_NODES.has(node.type);
30
+ }
18
31
  export function isExternalHref(href) {
19
32
  return /^[a-z][a-z0-9+.-]*:/i.test(href) || href.startsWith("//");
20
33
  }
package/dist/session.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { flat, titleOf } from "./lib/page.js";
2
- import { isExternalHref } from "./links.js";
2
+ import { htmlHoldsLinks, isExternalHref } from "./links.js";
3
3
  import { parseHtmlFile } from "./parse.js";
4
4
  import { toReport } from "./run.js";
5
5
  export function createAuditSession(opts) {
@@ -98,7 +98,7 @@ function collectRefs(nodes, visit) {
98
98
  for (const node of nodes) {
99
99
  if (node.inline)
100
100
  collectInline(node.inline, visit);
101
- if (node.html) {
101
+ if (node.html && htmlHoldsLinks(node)) {
102
102
  for (const m of node.html.matchAll(/<a\b[^>]*\shref="([^"]+)"/gi))
103
103
  visit(m[1], "link");
104
104
  for (const m of node.html.matchAll(/<img\b[^>]*\ssrc="([^"]+)"/gi))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dogsbay/site-check",
3
- "version": "0.2.0-beta.161",
3
+ "version": "0.2.0-beta.163",
4
4
  "description": "Site audit rules and runner shared by the dogsbay Astro pipeline and dogsbay-ssg; Worker-safe core with a Node adapter",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -26,8 +26,8 @@
26
26
  "dependencies": {
27
27
  "cheerio": "^1.2.0",
28
28
  "picocolors": "^1.1.1",
29
- "@dogsbay/serialize-core": "0.2.0-beta.161",
30
- "@dogsbay/types": "0.2.0-beta.161"
29
+ "@dogsbay/serialize-core": "0.2.0-beta.163",
30
+ "@dogsbay/types": "0.2.0-beta.163"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "^22.20.1",