File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
packages/site-kit/src/lib/markdown Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -63,12 +63,15 @@ export function smart_quotes(
63
63
const stack : Array < "'" | '"' > = [ ] ;
64
64
let res = '' ;
65
65
const len = str . length ;
66
+ const opening_squo_chars = / [ \s \n \( ] / ;
66
67
for ( let index = 0 ; index < len ; index ++ ) {
67
68
const char = str . charAt ( index ) ;
69
+ const before = str . charAt ( index - 1 ) ;
68
70
if ( html && char === '&' ) {
69
71
if ( str . slice ( index , index + 5 ) === ''' ) {
70
72
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 ) ;
72
75
res += `&${ left ? 'l' : 'r' } squo;` ;
73
76
index += 4 ;
74
77
if ( ! left ) {
@@ -91,7 +94,8 @@ export function smart_quotes(
91
94
}
92
95
} else if ( ! html && ( char === '"' || char === "'" ) ) {
93
96
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 ) ) ) ;
95
99
let double = char === '"' ;
96
100
res += double ? ( left ? '“' : '”' ) : left ? '‘' : '’' ;
97
101
if ( ! left ) {
You can’t perform that action at this time.
0 commit comments