![]() You can also find the completed code on GitHub. You can paste the CSS from the theme in the code CSS file.Īnd now, if you reload your application, you should see the theme in action, like the image below. In your application, create a new CSS file called code.css, and in the globals.css import it like so: 'code' You can find one here: HighlightJs themesĪnd once you found one, find the respective CSS styles on their GitHub repo We can then find or create a theme for these highlighting classes. The code block still looks the same, but if we look at the HTML created, we can see all kinds of new span elements with different classes. We can still use the md variable in the same way and don't need to change much there: md. ![]() Find all of the Marp tools, integrations, and examples in the. It is optimized to output only the minimum set of assets required. Marpit (independented from Marp) is the framework that transforms Markdown and CSS themes to slide decks composed of HTML/CSS. Then we define a new variable that invokes the markdown package and includes the highlighter as a plugin. The skinny framework for creating slide decks from Markdown. ![]() We changed the way we load the markdown package and the highlighter separately. Then head over to your pages/post/.js file and modify the imports section to look like this: import markdownIt from 'markdown-it' import highlightjs from 'markdown-it-highlightjs' const md = markdownIt (). To install the highlight package, run the following command. Since we are using markdown-it as our markdown parser, we can use highlightjs, an optional plugin. This script converts code blocks into separate span elements with classes to define what each part is. ![]() We can already parse code blocks however, they all look the same and have no highlighting.įor example, this image below shows how it would look: Use this GitHub repo as your starting point if you like to follow along. I guess that the Monokai theme would be the best match to that screenshot of yours. Check out the Highlight.js demo to see what style you want to use. Let's try and add this feature to our new blog. 1 Answer Sorted by: 17 The easiest way to do that, I think, is to simply include highlight.js in your page. Now that we created our markdown powered Next.js blog, we want to show off code blocks.Ĭode blocks like you would have seen on this website look like this: function $initHighlight ( block, cls ) export $initHighlight Making markdown code blocks look nice with a highlighter plugin 3 Feb, 2022 ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |