OOKNET                             [ /  search the index  ]  
──────────────────────────────────────────────────────────────────────────────────────
══════════════════════════════════════════════════════════════════════════════════════
OOKNET   [ /  search  ]  
────────────────────────────────────────────────
════════════════════════════════════════════════
 
 
master @ 36 LINES
 
[ HISTORY ]  [ UP ]
 

import { describe, expect, it } from "vitest";
import { describeBody } from "./meta";

describe("describeBody", () => {
  it("takes the first prose paragraph, skipping headings and fences", () => {
    const md = "# Title\n\n```\ncode\n```\n\nThe actual lede sentence.\n\nSecond p
ara.";
    expect(describeBody(md)).toBe("The actual lede sentence.");
  });

  it("skips tables, quotes, and lists", () => {
    const md = "| A | B |\n| - | - |\n\n> quote\n\n- item\n\nProse at last.";
    expect(describeBody(md)).toBe("Prose at last.");
  });

  it("strips wikilinks, links, and emphasis", () => {
    const md = "See [[N217|the bound]] and [docs](/docs/) for *context* on `checkG
rid`.";
    expect(describeBody(md)).toBe("See the bound and docs for context on checkGrid
.");
  });

  it("collapses hard-wrapped lines into one sentence", () => {
    expect(describeBody("wrapped\nacross\nlines")).toBe("wrapped across lines");
  });

  it("truncates at a word boundary with an ellipsis", () => {
    const long = "word ".repeat(60).trim();
    const out = describeBody(long, 40);
    expect([...out].length).toBeLessThanOrEqual(40);
    expect(out.endsWith("...")).toBe(true);
    expect(out).not.toContain("wor...");
  });

  it("returns empty for bodies with no prose", () => {
    expect(describeBody("# Only\n\n## Headings")).toBe("");
  });
});

import { describe, expect, it } from "vitest
";
import { describeBody } from "./meta";

describe("describeBody", () => {
  it("takes the first prose paragraph, skipp
ing headings and fences", () => {
    const md = "# Title\n\n```\ncode\n```\n\
nThe actual lede sentence.\n\nSecond para.";
    expect(describeBody(md)).toBe("The actua
l lede sentence.");
  });

  it("skips tables, quotes, and lists", () =
> {
    const md = "| A | B |\n| - | - |\n\n> qu
ote\n\n- item\n\nProse at last.";
    expect(describeBody(md)).toBe("Prose at 
last.");
  });

  it("strips wikilinks, links, and emphasis"
, () => {
    const md = "See [[N217|the bound]] and [
docs](/docs/) for *context* on `checkGrid`."
;
    expect(describeBody(md)).toBe("See the b
ound and docs for context on checkGrid.");
  });

  it("collapses hard-wrapped lines into one 
sentence", () => {
    expect(describeBody("wrapped\nacross\nli
nes")).toBe("wrapped across lines");
  });

  it("truncates at a word boundary with an e
llipsis", () => {
    const long = "word ".repeat(60).trim();
    const out = describeBody(long, 40);
    expect([...out].length).toBeLessThanOrEq
ual(40);
    expect(out.endsWith("...")).toBe(true);
    expect(out).not.toContain("wor...");
  });

  it("returns empty for bodies with no prose
", () => {
    expect(describeBody("# Only\n\n## Headin
gs")).toBe("");
  });
});
 
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET