Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
remark-github-admonitions-to-directives
Advanced tools
A Remark plugin to convert Github style alerts to admonitions directives.
Github introduced alerts in markdown files with their own proprietary syntax instead of using Remark directives. This plugin converts Github's blockquote alert style to Remark admonitions syntax.
It will transform this:
> [!NOTE]
> Content
Into this:
:::note
Content
:::
You can install this plugin with:
pnpm add -D remark-github-admonitions-to-directives
This plugin is just a generic unified (remark) plugin to transform one syntax into another. Below are some examples of how to use it with various plugins / systems:
import { remark } from "remark";
import remarkDirective from "remark-directive";
import remarkGithubAdmonitionsToDirectives from "remark-github-admonitions-to-directives";
const processor = remark()
.use(remarkGithubAdmonitionsToDirectives)
.use(remarkDirective);
const result = processor.processSync(`
> [!NOTE]
> content
`);
console.log(result.toString());
// should output:
// :::note
// content
// :::
Admonitions are a core feature of Docusaurus and this plugin was actually built with the use case of reusing markdown files, written with Github's syntax, in Docusaurus.
To use this plugin, just use the instructions for adding MDX plugins and add this plugin to the beforeDefaultRemarkPlugins
section of your docusaurus.config.js
file:
import remarkGithubAdmonitionsToDirectives from "remark-github-admonitions-to-directives";
export default {
presets: [
[
"@docusaurus/preset-classic",
{
docs: {
path: "docs",
beforeDefaultRemarkPlugins: [remarkGithubAdmonitionsToDirectives],
},
},
],
],
};
[!IMPORTANT] Because this plugin converts Github's syntax to the directives syntax, and Docusaurus then uses the directives syntax to create the adminitions, this plugin has to be processed before any of the Docusaurus plugins. This is why it's added to the
beforeDefaultRemarkPlugins
array and not theremarkPlugins
array.
By default, this plugin will map the Github alerts to the Remark admonitions as follows:
NOTE
-> note
TIP
-> tip
WARNING
-> warning
IMPORTANT
-> info
CAUTION
-> danger
If you want to customize this mapping, you can pass an object with the mapping to the plugin:
import { remark } from "remark";
import remarkDirective from "remark-directive";
import remarkGithubAdmonitionsToDirectives, {
DEFAULT_MAPPING,
DirectiveName,
GithubAlertType,
type AlertTypeMapping,
} from "remark-github-admonitions-to-directives";
const mapping: AlertTypeMapping = {
...DEFAULT_MAPPING,
[GithubAlertType.IMPORTANT]: DirectiveName.WARNING,
};
const processor = remark()
.use(remarkGithubAdmonitionsToDirectives, { mapping })
.use(remarkDirective);
const result = processor.processSync(`
> [!IMPORTANT]
> content
`);
console.log(result.toString());
// should output:
// :::info
// content
// :::
This plugin was created and is maintained by Incentro. If you're running into issues, please open an issue. If you want to contribute, please read our contributing guidelines.
FAQs
A Remark plugin to convert Github style alerts to admonitions directives.
The npm package remark-github-admonitions-to-directives receives a total of 886 weekly downloads. As such, remark-github-admonitions-to-directives popularity was classified as not popular.
We found that remark-github-admonitions-to-directives demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.