remark-capitalize
remark-capitalize copied to clipboard
Add ability to set title options
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
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
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!
@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.
@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... !