1.0.7 • Published 3 months ago

remark-code-format v1.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

remark-code-format

A remark plugin for formatting code blocks using Prettier.

Install

You can install remark-code-format using npm or yarn:

npm install remark-code-format --save-dev
# or
yarn add remark-code-format --dev

Note: Be sure to install the prettier package as well.

Usage

Once you've installed the plugin, you can use it in your remark configuration. Here's an example of how to configure it:

import { remark } from 'remark'
import remarkCodeFormat from 'remark-code-format'

const markdown = `
\`\`\`html prettier
<div><p>Greetings, traveler! Sign up today!</p></div>
\`\`\`
`

const file = await remark()
  .use(remarkCodeFormat, {
    /* Prettier options */
  })
  .process(markdown)

console.log(String(file))

🚨 Important: The prettier attribute must be specified in code fence blocks for formatting the code.

Yields:

```html
<div>
  <p>Greetings, traveler! Sign up today!</p>
</div>
```

Inline Options

Prettier configuration can be specified in code fence blocks using the prettier attribute, it has a higher priority than plugin Options. For example:

```ts prettier="{ parser: 'typescript' }"
// your code here
```

Related

Contributing

We 💛  issues.

When committing, please conform to the semantic-release commit standards. Please install commitizen and the adapter globally, if you have not already.

npm i -g commitizen cz-conventional-changelog

Now you can use git cz or just cz instead of git commit when committing. You can also use git-cz, which is an alias for cz.

git add . && git cz

License

GitHub

A project by Stilearning © 2023.

1.0.7

3 months ago

1.0.6

5 months ago

1.0.5

6 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago