diff --git a/markdoc/nodes/customSoftbreak.markdoc.ts b/markdoc/nodes/customSoftbreak.markdoc.ts new file mode 100644 index 00000000..85b1cb2b --- /dev/null +++ b/markdoc/nodes/customSoftbreak.markdoc.ts @@ -0,0 +1,12 @@ +// Markdoc automatically inserts a "softbreak" node in the document +// AST in places where there is a single line break. +// By default, a softbreak renders as a single space, +// https://github.com/markdoc/markdoc/discussions/338 + +const softbreakNode = { + transform() { + return "\n"; + } +}; + +export default softbreakNode; diff --git a/markdoc/nodes/index.ts b/markdoc/nodes/index.ts index f1c0989d..4f1ae708 100644 --- a/markdoc/nodes/index.ts +++ b/markdoc/nodes/index.ts @@ -1,2 +1,3 @@ export { default as fence } from "./Fence.markdoc" export { default as link } from "./customLink.markdoc" +export { default as softbreak } from "./customSoftbreak.markdoc"