remark-inline-code-language
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

remark-inline-code-language

A Remark plugin that allows passing a language to inline code. This is useful for syntax highlighting.

Note: This is not a standard markdown feature.

Example

`_js console.log()`

Installation

npm i -D remark-inline-code-language
import { unified } from "unified"
import remarkParse from "remark-parse"
import remarkInlineCodeLanguage from "remark-inline-code-language"

const mdast = await unified()
	.use(remarkParse)
	.parse("`_js console.log()`")

const result = unified()
	.use(remarkInlineCodeLanguage)
	.runSync(mdast)

console.log(JSON.stringify(result.children[0].children[0], null, 4))
{
	"type": "inlineCode",
	"value": "console.log()",
	"lang": "js"
}

Options

You can customize the syntax!

If you are going to only change 1 option, sadly you need to add in all other options too.

.use(remarkInlineCodeLanguage, {
	// ...
})

separator_character

This is the character(s) that separates the language name from the code content itself.

  • Type: string
  • Default: "_"

Examples

  • "_" => _js console.log()
  • "+" => +js console.log()
  • "=" => =js console.log()

separator_position

  • Type: "before" | "after" | "both"
  • Default: "before"

Examples

  • "before" => _js console.log()
  • "after" => js_ console.log()
  • "both" => _js_ console.log()

Readme

Keywords

Package Sidebar

Install

npm i remark-inline-code-language

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

7.38 kB

Total Files

7

Last publish

Collaborators

  • babakfp