diff --git a/CHANGELOG.md b/CHANGELOG.md index 3877cab5c..669dc5b87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -All notable changes to this project will be documented in this file. +All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). @@ -25,6 +25,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Sidebar panel overflow for plugins (#1266, #1269) - Extra border around code output in the instructions panel (#1253) - Line numbering alignment in code blocks in the instructions panel (#1259) +- Extra lines added at the start of some code blocks (#1267) ## [0.33.0] - 2025-10-15 diff --git a/src/components/Menus/Sidebar/InstructionsPanel/InstructionsPanel.jsx b/src/components/Menus/Sidebar/InstructionsPanel/InstructionsPanel.jsx index 9db70ab7e..32c2d74a1 100644 --- a/src/components/Menus/Sidebar/InstructionsPanel/InstructionsPanel.jsx +++ b/src/components/Menus/Sidebar/InstructionsPanel/InstructionsPanel.jsx @@ -17,16 +17,25 @@ import RemoveInstructionsModal from "../../../Modals/RemoveInstructionsModal"; import Prism from "prismjs"; import populateMarkdownTemplate from "../../../../utils/populateMarkdownTemplate"; +let prismConfigured = false; + const InstructionsPanel = () => { useEffect(() => { // prism and prism plugin config Prism.manual = true; - if (Prism.plugins.NormalizeWhitespace) { + if (Prism.plugins.NormalizeWhitespace && !prismConfigured) { Prism.plugins.NormalizeWhitespace.setDefaults({ "remove-indent": false, "remove-initial-line-feed": true, "left-trim": false, }); + Prism.hooks.add("before-sanity-check", function (env) { + if (!env.code) return; + + // Remove multiple leading blank lines (empty or whitespace-only) + env.code = env.code.replace(/^(?:\s*\n)+/, ""); + }); + prismConfigured = true; } }, []); const [showModal, setShowModal] = useState(false);