-
Notifications
You must be signed in to change notification settings - Fork 10
[CC Projects] Extra line added to the start of some code blocks #1268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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)+/, ""); | ||
| }); | ||
|
Comment on lines
+32
to
+37
|
||
| prismConfigured = true; | ||
| } | ||
| }, []); | ||
| const [showModal, setShowModal] = useState(false); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a module-level variable to track configuration state may cause issues if the component is unmounted and remounted, or in React strict mode where effects run twice. Consider using
useRefinstead to track whether Prism has been configured within the component's lifecycle.