PrismJS collapses all SlateJS codelines in a code block into single string in one line
See original GitHub issueInformation
- Language: JavaScript
- Plugins: none
Does the problem still occur in the latest version of Prism? yes
Description
Before the Prism.highlightAll() is applied, the markup looks like this
once it’s highlightAll()
is run it collapses all into this
Code snippet
useEffect(() => {
Prism.highlightAll();
}, []);
I’ve spent lots of time trying to figure out how to make PrismJS work with SlateJS, please help fellow people in (or not-in) self-isolation. 🤞🙏 🙏 🤞
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Line Numbers Prism plugins
To give all code blocks line numbers, add the line-numbers class to the <body> of the page. This is part of a general...
Read more >Commands - Slate
These commands act on the document based on the current selection . ... Insert a new block at the same level as the...
Read more >slate-edit-code - npm
A Slate plugin to handle code blocks editing. ... insert the right indentation if selection is collapsed or indent all lines in selection ......
Read more >Implement live markdown rendering using slate.js
But if you have better solutions to implement a real-time text editor like Typora or obsidian, I'm happy to know. – Searene. Sep...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You don’t have to call the Keep markup plugin at all. It will do its magic automatically.
Regarding the babel plugin: I feel like @mAAdhaTTah is more qualified to answer your question.
I can already see the problem in the markup.
SlateJS will split the code by lines and put each line in its own
div.codeLine
element, right? The problem is that Prism will remove all markup inside the element it is highlighting (thecode
element).I don’t kown if it’ll work, but try the Keep markup plugin. It should solve your problem.