Some checks failed
CD / Build and push images (push) Successful in 1m50s
CI / Lint, typecheck, test (push) Failing after 52s
CI / Auth e2e pack (push) Successful in 1m47s
CI / Build container images (push) Has been skipped
CD / Deploy to Test (push) Successful in 8s
CD / Smoke tests against Test (push) Successful in 1m5s
CD / Promote to Int (push) Successful in 10s
ProseMirror schema (headings 1-4, lists incl. task lists, blockquote, code block, tables via prosemirror-tables, images, hard breaks; bold/ italic/code/strikethrough/link marks) plus docToMarkdown, markdownToDoc, docToPlainText, docToHtml, and extractOutline built on it. Markdown parsing extends markdown-it's default preset with a token-stream transform for GFM task lists and table-cell paragraph wrapping. docToHtml hand-rolls escaping and link-protocol allowlisting with zero DOM dependencies, so it runs in the API/collab server as well as the browser. Node names `wikilink` and `plugin_block` are reserved for later stories. Closes #24
24 lines
910 B
TypeScript
24 lines
910 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { markdownToDoc } from './markdown';
|
|
import { extractOutline } from './outline';
|
|
|
|
describe('extractOutline (issue #24)', () => {
|
|
it('returns the heading tree with levels and text', () => {
|
|
const doc = markdownToDoc(
|
|
'# Handbook\n\nIntro paragraph.\n\n## Onboarding\n\n### Day one\n\n## Offboarding',
|
|
);
|
|
expect(extractOutline(doc)).toEqual([
|
|
{ id: 'handbook', level: 1, text: 'Handbook' },
|
|
{ id: 'onboarding', level: 2, text: 'Onboarding' },
|
|
{ id: 'day-one', level: 3, text: 'Day one' },
|
|
{ id: 'offboarding', level: 2, text: 'Offboarding' },
|
|
]);
|
|
});
|
|
|
|
it('deduplicates repeated heading text with stable numeric suffixes', () => {
|
|
const doc = markdownToDoc('# Notes\n\n## Notes\n\n## Notes');
|
|
expect(extractOutline(doc).map((entry) => entry.id)).toEqual(['notes', 'notes-2', 'notes-3']);
|
|
});
|
|
});
|