mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-17 01:31:35 +00:00
* refactor(shared): add markdown code span/fence helpers and migrate seven call sites * refactor(normalization-core): add canonical toErrorObject and migrate six copies * refactor: consolidate byte-identical helper pairs onto owner modules * refactor: reuse canonical path and token helpers in session tools and credentials * refactor(packages): dedupe compaction summarization tail and session dir parsing * fix(security): keep missing extensions dir silent in shared plugin dir lister * refactor: reuse media-core chunk reader and shared dreaming session key helper * fix(plugins): register error-coercion subpath in sdk alias table * chore(plugin-sdk): re-pin callable export count after rebase * chore(plugin-sdk): re-pin callable export count after rebase
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { formatFencedCodeBlock, formatInlineCodeSpan } from "./markdown-code.js";
|
|
|
|
describe("formatInlineCodeSpan", () => {
|
|
it("wraps plain text in single backticks without padding", () => {
|
|
expect(formatInlineCodeSpan("echo hi")).toBe("`echo hi`");
|
|
});
|
|
|
|
it("grows the delimiter past embedded backtick runs", () => {
|
|
expect(formatInlineCodeSpan("a `b` c")).toBe("``a `b` c``");
|
|
expect(formatInlineCodeSpan("x ``y`` z")).toBe("```x ``y`` z```");
|
|
});
|
|
|
|
it("pads when content starts or ends with a backtick", () => {
|
|
expect(formatInlineCodeSpan("`edge")).toBe("`` `edge ``");
|
|
expect(formatInlineCodeSpan("edge`")).toBe("`` edge` ``");
|
|
});
|
|
|
|
it("pads multi-line content", () => {
|
|
expect(formatInlineCodeSpan("a\nb")).toBe("` a\nb `");
|
|
});
|
|
});
|
|
|
|
describe("formatFencedCodeBlock", () => {
|
|
it("uses a three-backtick fence for plain text", () => {
|
|
expect(formatFencedCodeBlock("hello")).toBe("```\nhello\n```");
|
|
});
|
|
|
|
it("appends the language to the opening fence", () => {
|
|
expect(formatFencedCodeBlock("ls", "sh")).toBe("```sh\nls\n```");
|
|
});
|
|
|
|
it("grows the fence past embedded triple backticks", () => {
|
|
expect(formatFencedCodeBlock("```js\ncode\n```")).toBe("````\n```js\ncode\n```\n````");
|
|
});
|
|
|
|
it("keeps a three-backtick fence for short inner runs", () => {
|
|
expect(formatFencedCodeBlock("a ``b`` c")).toBe("```\na ``b`` c\n```");
|
|
});
|
|
});
|