Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SmartyPants Shouldn't Do Typographic Substitutions In <code> Blocks #1334

Closed
richdouglasevans opened this issue Sep 12, 2018 · 2 comments
Closed
Labels
category: code blocks help wanted L2 - annoying Similar to L1 - broken but there is a known workaround available for the issue

Comments

@richdouglasevans
Copy link
Contributor

When SmartyPants is enabled, Marked is replacing -- with an en-dash inside <code> blocks.

Per the following comment on the SmartyPants website, I don't think it should.

SmartyPants does not modify characters within <pre>, <code>, <kbd>, or <script> tag blocks.

To Reproduce

git clone https://github.com/richdouglasevans/marked-code-issue.git
cd marked-code-issue
npm i
npm test

I am happy to dig into the code and sort this myself; I'm raising an issue so that I can first confirm with you the expected behaviour.

Issue was noticed here: cypress-io/cypress-documentation#923

@styfle styfle added the L2 - annoying Similar to L1 - broken but there is a known workaround available for the issue label Sep 12, 2018
@styfle
Copy link
Member

styfle commented Sep 12, 2018

Hi @richdouglasevans thanks for the bug report.

It took me as second to realize that you are using the html <code></code> instead of the backticks.

marked('--foo <code>--bar</code>', {smartypants: true});
// <p>–foo <code>–bar</code></p>

It looks like a workaround is to use backticks instead like so:

marked('--foo `--bar`', {smartypants: true});
// <p>–foo <code>--bar</code></p>

@richdouglasevans
Copy link
Contributor Author

Aye, cheers Steven 👍

Yep, that works... the <code> blocks are being inserted by a component in my toolchain so I either need to rethink the way my toolchain works or solve this issue at source here.

I'll dig in and see if I can sort it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: code blocks help wanted L2 - annoying Similar to L1 - broken but there is a known workaround available for the issue
Projects
None yet
Development

No branches or pull requests

2 participants