Gatsby: 馃悶[gatsby-transformer-remark] Link with double underscore doesn't work

Created on 11 Jun 2019  路  4Comments  路  Source: gatsbyjs/gatsby

Description

When converting all of @CompuIves' Medium posts over to @codesandbox' blog (see codesandbox/codesandbox-client#2011), I came across a bug when a link contains 2 underscores (_).

When I try to include the following Tweet-link, I just see the link with an italic d instead of the d between an underscore on both sides:

https://twitter.com/brian_d_vaughn/status/901488766581227520

I first thought it had something to do with @kentcdodds' remark-embed plugin, but it didn't.

After further investigation, I was able to reproduce it by taking the using-remark example and creating a file with just the link in it.

Steps to reproduce

CodeSandbox link

Expected result

The user should see the correct link without an italic d that's inbetween 2 underscores (_).

https://twitter.com/brian_d_vaughn/status/901488766581227520

Actual result

The user sees an incorrect link with an italic d that's not inbetween 2 underscores (_).

https://twitter.com/briandvaughn/status/901488766581227520
question or discussion

Most helpful comment

Okay, I did a little more digging. This behaviour is documented in remark as pedantic mode (https://github.com/remarkjs/remark/blob/master/packages/remark-parse/readme.md#optionspedantic)

From the README linked above

Emphasis (_alpha_) and importance (__bravo__) with underscores in words

gatsby-transformer-remark sets pedantic to true by default. Setting it to false in options should get rid of this behaviour (screenshot below).

{
  resolve: `gatsby-transformer-remark`,
  options: {
    pedantic: false,
  },
},

Screenshot 2019-06-18 03 48 19

Closing this for now but feel free to reopen if there's anything else here that we can help with

All 4 comments

While I _can_ reproduce this, I'm not sure I would call this a bug. Looks like this is by design!

An easy work around would be to escape the underscore like https://twitter.com/brian\_d\_vaughn/status/901488766581227520

Okay, I did a little more digging. This behaviour is documented in remark as pedantic mode (https://github.com/remarkjs/remark/blob/master/packages/remark-parse/readme.md#optionspedantic)

From the README linked above

Emphasis (_alpha_) and importance (__bravo__) with underscores in words

gatsby-transformer-remark sets pedantic to true by default. Setting it to false in options should get rid of this behaviour (screenshot below).

{
  resolve: `gatsby-transformer-remark`,
  options: {
    pedantic: false,
  },
},

Screenshot 2019-06-18 03 48 19

Closing this for now but feel free to reopen if there's anything else here that we can help with

@sidharthachatterjee Like you can see in @kentcdodds' comment (https://github.com/kentcdodds/kentcdodds.com/issues/191#issuecomment-499179350), this doesn't happen when using the RAW Markdown and passing it to the MDXRenderer.

Awesome you've looked deeper into this one @sidharthachatterjee! 馃憡

This looks likes it indeed fixes my problem, thanks! 馃檪

Was this page helpful?
0 / 5 - 0 ratings

Related issues

theduke picture theduke  路  3Comments

magicly picture magicly  路  3Comments

3CordGuy picture 3CordGuy  路  3Comments

ferMartz picture ferMartz  路  3Comments

rossPatton picture rossPatton  路  3Comments