Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
markdown-it-prism-backticks
Advanced tools
Readme
MarkdownIt plugin for highlighting inline code snippets using Prism.
Using npm:
npm install markdown-it-prism-backticks
Prism is a peer dependency of this plugin and must also be installed:
npm install prismjs
Import it wherever you configure MarkdownIt and then use it as you would any other MarkdownIt plugin:
import MarkdownIt from "markdown-it";
import markdownItPrismBackticks from "markdown-it-prism-backticks";
...
new MarkdownIt().use(markdownItPrismBackticks)
Important! You may also need to import Prism itself. If you are using the markdown-it-prism plugin as well then you do not. If you are already importing Prism then you do not. If neither situation applies then you do need to import Prism:
import "prismjs"; // Ensure the Prism global object is defined.
import MarkdownIt from "markdown-it";
import markdownItPrismBackticks from "markdown-it-prism-backticks";
Now you can add a language annotation to any inline backticks content that you want highlighted by Prism:
An example assembly instruction is `LDA #$22`{lang=asm6502}.
The result is as expected:
(The exact visual appearance will depend on the Prism theme that you are using.)
The rules for the language annotation are simple:
See stevejay/middleengine-website for an example of a repository that uses this plugin.
This plugin can be used in conjunction with the markdown-it-prism plugin. The latter highlights fenced code blocks while this plugin highlights inline backtick content.
This plugin plays well with the markdown-it-attrs plugin. Any content in curly braces that does not match the {lang=some-lang}
format is ignored by this plugin, and you can add extra curly brace content for markdown-it-attrs after the language setting:
This is fine: `LDA #$22`{.someClass}.
This is also fine: `LDA #$22`{lang=asm6502}{.someClass}.
The basic approach to parsing inline backticks comes from the default parser in the MarkdownIt repository.
The structure of this repository comes from the markdown-it-prism project.
FAQs
MarkdownIt plugin for highlighting inline code snippets using Prism.
The npm package markdown-it-prism-backticks receives a total of 9 weekly downloads. As such, markdown-it-prism-backticks popularity was classified as not popular.
We found that markdown-it-prism-backticks demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.