Skip to content

fix: rewrite smart quotes logic #1325

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

Ocean-OS
Copy link
Member

@Ocean-OS Ocean-OS commented Apr 28, 2025

Closes #781. I'm not entirely sure on what first does, or if I'm using it correctly in the logic, but everything else should be good.

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time.
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.

Copy link

vercel bot commented Apr 28, 2025

@Ocean-OS is attempting to deploy a commit to the Svelte Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Apr 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
svelte-dev ❌ Failed (Inspect) Aug 4, 2025 3:55am

@eltigerchino
Copy link
Member

I'm not entirely sure on what first does

I think first is used to tell if we're in a complete sentence or substring. It's only being used when we're processing the shiki tokens token by token so that a substring such as example" that's part of a bigger string "an example" will get the right quotation direction.

Copy link
Member

@eltigerchino eltigerchino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new approach seems to error in cases where a title has a single quote character such as https://svelte.dev/docs/kit/images#Vite's-built-in-handling . It changes the single quote to a left single quote when it should be a right single quote as it is currently.

Possible edge cases we should account for:
a) Vite's built-in handling (right single quote)
b) "Vite's built-in handling" (smart double quotes with right single quote)
c) <script lang="ts"> (smart double quotes but in a single word)

I wonder if it's worth adding a unit test for this but I can see we don't have Vitest set up despite having a test command in the root package.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

more smart quote woes
2 participants