From b2459d6e16ff5be15fc59f80b79d0d30041ceedb Mon Sep 17 00:00:00 2001 From: Mark Pipe Date: Mon, 29 Jun 2026 15:57:34 +0100 Subject: [PATCH 1/2] Fix notebook markdown soft line breaks Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/core/package.json | 6 +++++- packages/core/src/markdownit/divs.ts | 11 ++++++----- packages/core/test/markdownit-divs.test.ts | 22 ++++++++++++++++++++++ 3 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 packages/core/test/markdownit-divs.test.ts diff --git a/packages/core/package.json b/packages/core/package.json index a5f9a6525..e2f494b9d 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -13,6 +13,10 @@ }, "devDependencies": { "@types/markdown-it": "^12.2.3", - "@types/markdown-it-attrs": "^4.1.0" + "@types/markdown-it-attrs": "^4.1.0", + "tsx": "^4.7.1" + }, + "scripts": { + "test": "node --import tsx --test test/*.test.ts" } } diff --git a/packages/core/src/markdownit/divs.ts b/packages/core/src/markdownit/divs.ts index 7a3947f51..e2cd65120 100644 --- a/packages/core/src/markdownit/divs.ts +++ b/packages/core/src/markdownit/divs.ts @@ -38,11 +38,6 @@ export const divPlugin = (md: MarkdownIt) => { kDivRuleName, (state, start, _end, silent) => { - // This is a validation run, can ignore - if (silent) { - return true; - } - // Get the line for parsing const lineStart = state.bMarks[start] + state.tShift[start]; const lineEnd = state.eMarks[start]; @@ -85,6 +80,12 @@ export const divPlugin = (md: MarkdownIt) => { } if (match) { + // This is a validation run. Report that actual div markers interrupt + // paragraphs, but avoid mutating div state until the parser consumes it. + if (silent) { + return true; + } + // There is a div here, is one already open? const divFence = match[1]; const attr = match[2]; diff --git a/packages/core/test/markdownit-divs.test.ts b/packages/core/test/markdownit-divs.test.ts new file mode 100644 index 000000000..bd67a61d2 --- /dev/null +++ b/packages/core/test/markdownit-divs.test.ts @@ -0,0 +1,22 @@ +import assert from "node:assert/strict"; +import test from "node:test"; + +import MarkdownIt from "markdown-it"; +import { divPlugin } from "../src/markdownit/divs"; + +const render = (src: string) => { + const md = new MarkdownIt({ html: true }); + md.use(divPlugin); + return md.render(src); +}; + +test("pandoc divs do not turn soft line breaks into paragraph breaks", () => { + assert.equal(render("Hello\nworld"), "

Hello\nworld

\n"); +}); + +test("pandoc div markers still interrupt paragraphs", () => { + assert.equal( + render("Before\n:::\nInside\n:::"), + "

Before

\n

Inside

\n
" + ); +}); From 19f9c7face1dc1bb33143b008bb60cdbb7008d7b Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Mon, 29 Jun 2026 11:00:52 -0600 Subject: [PATCH 2/2] Update CHANGELOG --- apps/vscode/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/vscode/CHANGELOG.md b/apps/vscode/CHANGELOG.md index 307104845..6c9dc658a 100644 --- a/apps/vscode/CHANGELOG.md +++ b/apps/vscode/CHANGELOG.md @@ -4,6 +4,7 @@ - In Positron, running a cell that raises an error no longer results in an error toast message (). - In Positron, Julia code cells in `.qmd` files can now be executed when the `ntluong95.positron-julia` extension is installed, the same way Python and R do (). +- Fixed a bug where soft line breaks within a paragraph were rendered as separate paragraphs in the markdown preview (). ## 1.134.0 (Release on 2026-06-22)