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

Unencoded header links didn't work. #1749

Closed
3 tasks done
garmede opened this issue Jan 2, 2023 · 4 comments
Closed
3 tasks done

Unencoded header links didn't work. #1749

garmede opened this issue Jan 2, 2023 · 4 comments
Labels
build Related to the build system

Comments

@garmede
Copy link

garmede commented Jan 2, 2023

Describe the bug

Unencoded header links (with CJK characters) do not work.

I remember it worked fine in VuePress, but it doesn't work in VitePress.

Reproduction

# Header

This link [한글](#한글-한글) is not work!

This link [한글](#%E1%84%92%E1%85%A1%E1%86%AB%E1%84%80%E1%85%B3%E1%86%AF-%E1%84%92%E1%85%A1%E1%86%AB%E1%84%80%E1%85%B3%E1%86%AF)  is work.

...

## 한글 한글

...

Expected behavior

Creating links with native headers should also work.

System Info

System:
  OS: Windows 10 10.0.22621
  CPU: (12) x64 AMD Ryzen 5 3600X 6-Core Processor
  Memory: 46.05 GB / 63.92 GB
Binaries:
  Node: 19.3.0 - C:\Program Files\nodejs\node.EXE
  npm: 9.2.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
  Edge: Spartan (44.22621.963.0), Chromium (108.0.1462.54)
  Internet Explorer: 11.0.22621.1
npmPackages:
  vitepress: 1.0.0-alpha.34 => 1.0.0-alpha.34

Additional context

No response

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
@garmede garmede added the bug: pending triage Maybe a bug, waiting for confirmation label Jan 2, 2023
@brc-dd
Copy link
Member

brc-dd commented Jan 2, 2023

Probably has something to do with your browser. We don't manually handle the URL fragments. For me, both are working fine on Chrome 108: https://stackblitz.com/edit/vite-kdiy46?file=docs%2Fexample.md

407cb01215.mp4

@brc-dd brc-dd added need more info Further information is requested and removed bug: pending triage Maybe a bug, waiting for confirmation labels Jan 2, 2023
@garmede
Copy link
Author

garmede commented Jan 2, 2023

In the html source I built, the address is encoded differently as follows.

<!-- [한글](#한글-한글) to -->
<a href="#%ED%95%9C%EA%B8%80-%ED%95%9C%EA%B8%80">한글</a>

<!-- [한글](#%E1%84%92%E1%85%A1%E1%86%AB%E1%84%80%E1%85%B3%E1%86%AF-%E1%84%92%E1%85%A1%E1%86%AB%E1%84%80%E1%85%B3%E1%86%AF) to -->
<!-- This address was encoded by copy pasting from the browser address bar. -->
<a href="#%E1%84%92%E1%85%A1%E1%86%AB%E1%84%80%E1%85%B3%E1%86%AF-%E1%84%92%E1%85%A1%E1%86%AB%E1%84%80%E1%85%B3%E1%86%AF">한글</a>

@brc-dd
Copy link
Member

brc-dd commented Jan 2, 2023

I'm not completely sure, but there is an issue with the text in your first link. Copy paste this: #한글-한글 there (or from my stackblitz link). Both are looking same to me after decoding, but JS tells there is a difference. I don't speak Korean, so not sure what's that:

image

PS: it looks like second one is using multiple characters to represent a single letter. (VitePress is generating ids having those, even if the source has unicode stuff).

The string normalization is causing this: https://github.com/mdit-vue/mdit-vue/blob/main/packages/shared/src/slugify.ts#L11

@brc-dd brc-dd added bug build Related to the build system and removed need more info Further information is requested labels Jan 2, 2023
@garmede
Copy link
Author

garmede commented Jan 2, 2023

Exactly! Both are exactly the same Hangul, but their Unicode is different. Shorter is better.
Unfortunately, VitePress handles Korean characters on the long side.

image

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
build Related to the build system
Projects
None yet
Development

No branches or pull requests

2 participants