Skip to content

Commit 1e234d3

Browse files
committed
more
1 parent 7e81f5b commit 1e234d3

File tree

1 file changed

+6
-2
lines changed
  • packages/site-kit/src/lib/markdown

1 file changed

+6
-2
lines changed

packages/site-kit/src/lib/markdown/utils.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,15 @@ export function smart_quotes(
6363
const stack: Array<"'" | '"'> = [];
6464
let res = '';
6565
const len = str.length;
66+
const opening_squo_chars = /[\s\n\(]/;
6667
for (let index = 0; index < len; index++) {
6768
const char = str.charAt(index);
69+
const before = str.charAt(index - 1);
6870
if (html && char === '&') {
6971
if (str.slice(index, index + 5) === '&#39;') {
7072
const left: boolean =
71-
(first && stack.at(-1) !== "'") || (index > 1 && str.charAt(index - 1) === '=');
73+
((first && stack.at(-1) !== "'") || (index > 1 && before === '=')) &&
74+
!opening_squo_chars.test(before);
7275
res += `&${left ? 'l' : 'r'}squo;`;
7376
index += 4;
7477
if (!left) {
@@ -91,7 +94,8 @@ export function smart_quotes(
9194
}
9295
} else if (!html && (char === '"' || char === "'")) {
9396
let left: boolean =
94-
(first && stack.at(-1) !== char) || (index > 1 && str.charAt(index - 1) === '=');
97+
(first && stack.at(-1) !== char) ||
98+
(index > 1 && before === '=' && !(char === "'" && opening_squo_chars.test(before)));
9599
let double = char === '"';
96100
res += double ? (left ? '“' : '”') : left ? '‘' : '’';
97101
if (!left) {

0 commit comments

Comments
 (0)