Tighten markdown list spacing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { getMarkdownListMarker } from "./markdown-list";
|
||||
import { getMarkdownListMarker, getMarkdownListSpacing } from "./markdown-list";
|
||||
|
||||
describe("getMarkdownListMarker", () => {
|
||||
it("returns a bullet marker for unordered list items", () => {
|
||||
@@ -39,3 +39,49 @@ describe("getMarkdownListMarker", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("getMarkdownListSpacing", () => {
|
||||
it("keeps top-level list spacing as a section boundary", () => {
|
||||
const paragraph = { type: "paragraph" };
|
||||
const list = { type: "bullet_list" };
|
||||
const body = { type: "body", children: [list, paragraph] };
|
||||
|
||||
expect(getMarkdownListSpacing(list, [body])).toEqual({
|
||||
marginTop: 4,
|
||||
marginBottom: 16,
|
||||
});
|
||||
});
|
||||
|
||||
it("does not add bottom spacing after a list at the end of a markdown block", () => {
|
||||
const list = { type: "bullet_list" };
|
||||
const body = { type: "body", children: [list] };
|
||||
|
||||
expect(getMarkdownListSpacing(list, [body])).toEqual({
|
||||
marginTop: 4,
|
||||
marginBottom: 0,
|
||||
});
|
||||
});
|
||||
|
||||
it("uses a smaller gap between adjacent top-level lists", () => {
|
||||
const list = { type: "bullet_list" };
|
||||
const body = { type: "body", children: [list, { type: "ordered_list" }] };
|
||||
|
||||
expect(getMarkdownListSpacing(list, [body])).toEqual({
|
||||
marginTop: 4,
|
||||
marginBottom: 8,
|
||||
});
|
||||
});
|
||||
|
||||
it("does not add section spacing after a nested list", () => {
|
||||
expect(
|
||||
getMarkdownListSpacing({ type: "bullet_list" }, [
|
||||
{ type: "list_item" },
|
||||
{ type: "bullet_list" },
|
||||
{ type: "body" },
|
||||
]),
|
||||
).toEqual({
|
||||
marginTop: 4,
|
||||
marginBottom: 0,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user