NobGit
public anord read

Ledger

Why work hard when you can work easier?

Languages

Repository composition by tracked source files.

TypeScript
TypeScript 86% CSS 10% SQL 3% Shell 1% HTML 0%
Create file Wiki Documentation
Clone
https://nobgit.com/orgs/anord/ledger.git
ssh://[email protected]:2222/orgs/anord/ledger.git
markdown.test.ts
import { describe, expect, it } from "vitest";
import { renderMarkdown } from "../utils/markdown.js";

describe("markdown rendering", () => {
  it("sanitizes unsafe html", () => {
    const rendered = renderMarkdown("# Hello\n\n<script>alert('xss')</script><b>safe</b>");
    expect(rendered.bodyHtml).not.toContain("<script>");
    expect(rendered.bodyHtml).toContain("<b>safe</b>");
  });

  it("builds a table of contents from headings", () => {
    const rendered = renderMarkdown("# One\n\n## Two");
    expect(rendered.toc).toEqual([
      { id: "one", text: "One", level: 1 },
      { id: "two", text: "Two", level: 2 }
    ]);
  });
});