remark-code-format v1.0.8
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 --devNote: 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-changelogNow 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 czLicense
A project by Stilearning © 2023.