docsifyjs / docsify

🃏 A magical documentation site generator.
https://docsify.js.org
MIT License
27.47k stars 5.67k forks source link

English quotes become Chinese quotes #2360

Closed kbmts closed 8 months ago

kbmts commented 8 months ago

There are two bugs

  1. English quotes become Chinese quotes. e.g. grep 'keyword' become grep ‘keyword’
  2. Two horizontal bars become one. e.g. --exclude become –exclude

Tried setting smartypants to false but it doesn't work.

How to fix it or how to change the default markdown parser?

Koooooo-7 commented 8 months ago

Hi @kbmts , could you provide an reproduce? It sounds weird and I can not reproduce it either.

trusktr commented 8 months ago

Markdown does what it does, not sure how to avoid. Do you add plugins? Can't see your issue directly. Can you link to an example?

If you want to show pieces of code, use back ticks. For example,

Provide some `--option` to enable some feature. Internal code receives the string `'foo'`.

The output looks like this:

Provide some --option to enable some feature. Internal code receives the string 'foo'.

kbmts commented 8 months ago

test page @Koooooo-7 @trusktr

Koooooo-7 commented 8 months ago

Hi, it seems the docsify-themeable plugin styling issue.

<script src="https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/js/docsify-themeable.min.js"></script>
trusktr commented 8 months ago

@kbmts There's something in the code (not CSS style) that is generating the character.

Here is the source markdown file:

https://kbmts.github.io/docsify-test/README.md

# Docsify Test

## content1

ps -ef | grep 'web'

## content2

du -h --max-depth

A simple solution to this @kbmts is to wrap the code with backticks symbols (`). Change the markdown content to the following:

# Docsify Test

## content1

`ps -ef | grep 'web'`

## content2

`du -h --max-depth`

Here is a sample output:

Docsify Test

content1

ps -ef | grep 'web'

content2

du -h --max-depth

If you do this, then the normal text will have nicer looking quotes, but the inline code will not be transformed.

Also curious, if you remove docsify-themeable.min.js, does it stop transforming the quotes?

kbmts commented 8 months ago

@trusktr @Koooooo-7 Thank you very much. It's the docsify-themeable js issue!

trusktr commented 8 months ago

@jhildenbiddle does docsify-themeable.js change the quotes? If so, does it have a config option?

re-opening to track the quote issue (but feel free to unsubscribeif needed @kbmts).

jhildenbiddle commented 8 months ago

@trusktr --

I don't believe it does, but I will verify and report back.

jhildenbiddle commented 8 months ago

@kbmts @trusktr --

Bug confirmed and fixed.

From this comment:

It turns out the docsify-themeable JS was setting the markdown processor's smartypants option to true. Enabling this option "turns plain ASCII punctuation characters into "smart" typographic punctuation HTML entities" according to the SmartyPants project description. Mystery solved.

I've made the necessary change on the dev branch. I will publish an updated version when the next version of Docsify is released. That will hopefully happen in the next few weeks. In the meantime, you have two options:

  1. Wrap affected text in backticks (e,.g. ps -ef | grep 'web') as @trusktr recommended here.
  2. Download and locally host the current preview build of docsify-themeable.min.js which contains the fix.

Thanks!

trusktr commented 8 months ago

Nice!