Skip to content

Commit 84004e2

Browse files
committed
simplify
1 parent b02cea6 commit 84004e2

File tree

1 file changed

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

1 file changed

+6
-10
lines changed

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ export function smart_quotes(
7070
if (html && char === '&') {
7171
if (str.slice(index, index + 5) === ''') {
7272
const left: boolean =
73-
((first && before === '') || stack.at(-1) !== "'" || (index > 1 && before === '=')) &&
74-
!opening_squo_chars.test(before);
73+
stack.at(-1) !== "'" && (opening_squo_chars.test(before) || (first && before === ''));
7574
res += `&${left ? 'l' : 'r'}squo;`;
7675
index += 4;
7776
if (!left) {
@@ -80,10 +79,7 @@ export function smart_quotes(
8079
stack.push("'");
8180
}
8281
} else if (str.slice(index, index + 6) === '"') {
83-
const left: boolean =
84-
(first && before === '') ||
85-
stack.at(-1) !== '"' ||
86-
(index > 1 && str.charAt(index - 1) === '=');
82+
const left: boolean = stack.at(-1) !== '"';
8783
res += `&${left ? 'l' : 'r'}dquo`;
8884
index += 5;
8985
if (!left) {
@@ -95,10 +91,10 @@ export function smart_quotes(
9591
res += '&';
9692
}
9793
} else if (!html && (char === '"' || char === "'")) {
98-
let left: boolean =
99-
((first && before === '') || stack.at(-1) !== char || (index > 1 && before === '=')) &&
100-
!(char === "'" && !opening_squo_chars.test(before));
101-
let double = char === '"';
94+
const left: boolean =
95+
stack.at(-1) !== char &&
96+
(opening_squo_chars.test(char) || (first && before === '') || char === '"');
97+
const double = char === '"';
10298
res += double ? (left ? '“' : '”') : left ? '‘' : '’';
10399
if (!left) {
104100
stack.pop();

0 commit comments

Comments
 (0)