remark-capitalize icon indicating copy to clipboard operation
remark-capitalize copied to clipboard

Add ability to set title options

Open mxstbr opened this issue 6 years ago • 4 comments

I'm not sure if this is the right way to do it, but this adds another layer of function to add support for title options.

Closes #3

mxstbr avatar Jan 25 '19 09:01 mxstbr

I'd love to see this through 😍 I've been manually using title directly and was hoping to switch to a remark plugin.

Any chance we get some eyes here? 👀 @leo

leerob avatar Mar 19 '20 16:03 leerob

Any updates on that? 🙃 I've tried messing around with the module itself like so,

const title = require('title')
const visit = require('unist-util-visit')

module.exports = (options) => (tree, file) => {
    visit(tree, 'heading', node => {
        visit(node, 'text', textNode => {
            const text = textNode.value ? textNode.value.trim() : ''
            textNode.value = title(text, {special: options})
        })
    })
}

but I can't figure out how to pass those options with the plugin when parsing markdown.... 😕 Also the patch-package link is broken, so no luck there either! Additionally, I peeked at @leerob's blog repo, but his workaround doesn't work on my project. Maybe because I'm using unified? I'm still relatively new to web development, so hopefully this makes sense!

flowsn4ke avatar Dec 09 '20 21:12 flowsn4ke

@theophilelouvel I used the patch approach here since last May and just recently removed it. This plugin was nice, but ultimately I was tired of adding this to my exceptions list that I didn't want title capitalize.

leerob avatar Dec 09 '20 21:12 leerob

@theophilelouvel I used the patch approach here since last May and just recently removed it. This plugin was nice, but ultimately I was tired of adding this to my exceptions list that I didn't want title capitalize.

@leerob That's a drawback for sure... You can either spend time capitalizing or decapitalizing words 😅

It would be tempting to propose to bake a list of special cased words into title itself, but probably not too practical as the list would quickly get out of hands... !

flowsn4ke avatar Dec 09 '20 21:12 flowsn4ke