Skip to content

flowsn4ke/remark-capitalize

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Remark Capitalize

Transform all markdown titles with title.sh

Getting started

npm install --save remark-capitalize

Usage with Markdown

Works as a remark plugin with either unified or remark.

Without options

import unified from 'unified'
import markdown from 'remark-parse'
import capitalize from 'remark-capitalize'
import html from 'remark-html'

const processedContent = await unified()
        .use(markdown)
        .use(capitalize)
        .use(html)
        .process(content)

With Options

import unified from 'unified'
import markdown from 'remark-parse'
import capitalize from 'remark-capitalize'
import html from 'remark-html'

// Your casing will be enforced for these words
const options = ['iPhone', 'facebook', 'sOmeRanDOMcaSEDtiTle']

const processedContent = await unified()
        .use(markdown)
        .use(capitalize, { options })
        .use(html)
        .process(content)

Usage with MDX

mdx uses remark to transform an MDX document into JSX tags. It has support for passing plugins through the loader options:

Without options

const remarkCapitalize = require('remark-capitalize')
// part of webpack.config.js
{
  test: /\.mdx$/,
  use: [
    defaultLoaders.babel,
    {
      loader: '@compositor/markdown-loader',
      options: {
        plugins: [remarkCapitalize]
      }
    }
  ]
}

With Options

// Your casing will be enforced for these words
const options = ['iPhone', 'facebook', 'sOmeRanDOMcaSEDtiTle']

const remarkCapitalize = require('remark-capitalize')
// part of webpack.config.js
{
  test: /\.mdx$/,
  use: [
    defaultLoaders.babel,
    {
      loader: '@compositor/markdown-loader',
      options: {
        plugins: [
        [remarkCapitalize, {options}]
        ]
      }
    }
  ]
}

About

Transform all markdown titles with title.sh

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%