silvenon / remark-smartypants

remark plugin to implement SmartyPants
MIT License
56 stars 3 forks source link

Config for "oldschool"? #1

Closed brycewray closed 4 years ago

brycewray commented 4 years ago

This plugin's default transformation where dashes are concerned appears to be that -- produces an em dash and --- isn't changed. Is there any way to config for the so-called "oldschool" setting in which -- produces an en dash and --- produces an em dash? For those who use MultiMarkdown, this would be especially helpful.

silvenon commented 4 years ago

remark-smartypants forwards all options to retext-smartypants, so this should work:

const content = remark()
  .use(smartypants, { dashes: 'oldschool' })
  .processSync('This should be an em dash: ---')

Let me know if this doesn't work.

brycewray commented 4 years ago

Thanks, @silvenon. Worked great! Actually, am using it in a Gridsome repo I'm setting up so it was even simpler than that: I just added it to gridsome.config.js as follows:

// this is within the overall 'module.exports`...
   transformers: {
      remark: {
     // **global** remark options
    plugins: [
       ['@silvenon/remark-smartypants', {
          dashes: 'oldschool',
        }
      ],
     // ... and so on

... and all's right with the world with my Markdown's em dashes now. Appreciate the quick reply!

silvenon commented 4 years ago

Great! 😉