A marked extension for formatting code blocks using Prettier
npm install marked-code-formatA marked extension for formatting code blocks using Prettier.
You can install marked-code-format using npm or yarn:
``bash`
npm i marked-code-formator
yarn add marked-code-format
Note: Be sure to install the prettier package as well.
Once you've installed this extension, you can use it in your marked configuration. Here's an example of how to configure it:
Say we have the following file example.html:
`html
`

Say we have the following file example.md:
``mdExample
`graphql prettier`
query Hero($episode: Episode, $withFriends: Boolean!) {
hero(episode: $episode) {
name
friends @include(if: $withFriends) {
name
}
}
}``
🚨 Important: The prettier attribute must be specified in code fence blocks for formatting the code.
And our module example.js looks as follows:
`js
import { readFileSync } from 'node:fs'
import { Marked } from 'marked'
import markedCodeFormat from 'marked-code-format'
const html = new Marked()
.use(
markedCodeFormat({
/ Prettier options /
})
)
.parse(readFileSync('example.md', 'utf8'))
console.log(html)
`
Now, running node example.js yields:
``htmlExample
` Greetings, traveler! Sign up today!html`
``
Prettier configuration can be specified in code fence blocks using the prettier attribute, it has a higher priority than extension Options. For example:
``md`ts prettier="{ parser: 'typescript' }"`
// your code here``
- marked-code-jsx-renderer
- marked-code-preview
We 💛 issues.
When committing, please conform to the semantic-release commit standards. Please install commitizen and the adapter globally, if you have not already.
`bash`
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.
`bash``
git add . && git cz
A project by Stilearning © 2023-2024.