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(
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 ) === ''' ) {
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 ) {
You can’t perform that action at this time.
0 commit comments