Skip to content

Vizel API / core/src / assertMarkdownRoundtrip

Function: assertMarkdownRoundtrip()

ts
function assertMarkdownRoundtrip(flavor, samples): Promise<void>;

Defined in: packages/core/src/markdown/roundtrip.ts:40

Assert that every sample round-trips losslessly through the given flavor.

Each sample is parsed into the editor with the flavor's parser and then re-serialized; if the output differs (after .trim()-equivalent whitespace normalisation), the helper throws a typed VizelError with code "MARKDOWN_LOSSY" carrying the sample name and flavor in the error context.

Flavor authors call this helper from their own tests to verify that a custom flavor preserves its inputs.

Parameters

ParameterType
flavorVizelMarkdownFlavor
samplesreadonly VizelRoundtripSample[]

Returns

Promise&lt;void&gt;

Example

ts
import { assertMarkdownRoundtrip, vizelGfmFlavor } from "@vizel/core";

await assertMarkdownRoundtrip(vizelGfmFlavor, [
  { name: "heading", input: "# Hello" },
  { name: "list", input: "- a\n- b\n" },
]);

Released under the MIT License.