question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PrismJS collapses all SlateJS codelines in a code block into single string in one line

See original GitHub issue

Information

  • 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 image

once it’s highlightAll() is run it collapses all into this image

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:closed
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
RunDevelopmentcommented, Mar 19, 2020

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.

1reaction
RunDevelopmentcommented, Mar 19, 2020

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 (the code element).

I don’t kown if it’ll work, but try the Keep markup plugin. It should solve your problem.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found