File tree Expand file tree Collapse file tree 3 files changed +11
-7
lines changed
Expand file tree Collapse file tree 3 files changed +11
-7
lines changed Original file line number Diff line number Diff line change 2222 "type" : " addon"
2323 },
2424 "scripts" : {
25- "lint:fix" : " pnpm -w exec lint fix" ,
25+ "lint" : " concurrently \" pnpm:lint:*(!fix)\" --names \" lint:\" --prefixColors auto" ,
26+ "lint:fix" : " concurrently \" pnpm:lint:*:fix\" --names \" fix:\" --prefixColors auto && pnpm run format" ,
2627 "example" : " cd example && vite" ,
2728 "lint:package" : " pnpm publint" ,
2829 "lint:js" : " pnpm -w exec lint js" ,
2930 "lint:types" : " tsc --noEmit" ,
3031 "lint:js:fix" : " pnpm -w exec lint js:fix" ,
31- "lint:prettier:fix " : " pnpm -w exec lint prettier:fix" ,
32+ "format " : " pnpm -w exec lint prettier:fix" ,
3233 "lint:prettier" : " pnpm -w exec lint prettier" ,
3334 "test:node" : " vitest"
3435 },
Original file line number Diff line number Diff line change @@ -65,12 +65,15 @@ function unescapeComponentsOutsideCode(html) {
6565 // Only touch content outside <pre>
6666 if ( i % 2 === 0 ) {
6767 // Split by <code>…</code> so we skip inline code too
68- const codeParts = parts [ i ] . split ( / ( < c o d e [ ^ > ] * > [ \s \S ] * ?< \/ c o d e > ) / gi) ;
68+ const part = parts [ i ] ?? '' ;
69+ const codeParts = part . split ( / ( < c o d e [ ^ > ] * > [ \s \S ] * ?< \/ c o d e > ) / gi) ;
6970
7071 for ( let j = 0 ; j < codeParts . length ; j ++ ) {
72+ const segment = codeParts [ j ] ;
73+
7174 // Even indices are outside <code> – unescape PascalCase there
72- if ( j % 2 === 0 ) {
73- codeParts [ j ] = codeParts [ j ]
75+ if ( j % 2 === 0 && segment ) {
76+ codeParts [ j ] = segment
7477 . replace ( / & # x 3 C ; ( [ A - Z ] [ a - z A - Z 0 - 9 ] * \s [ ^ < ] * ?) > / g, ( _m , content ) =>
7578 content . includes ( '@' ) ? `<${ content } >` : _m
7679 )
Original file line number Diff line number Diff line change @@ -11,10 +11,9 @@ export const REPL_LT = '__REPL_LT__';
1111/**
1212 * Remark plugin: escape PascalCase component tags in `inlineCode` and
1313 * non-live `code` (code fence) nodes by replacing `<` with a placeholder.
14- *
15- * @returns {import('unified').Plugin }
1614 */
1715function remarkEscapeComponents ( ) {
16+ /** @param {import('mdast').Root } tree */
1817 return ( tree ) => {
1918 visit ( tree , ( node ) => {
2019 // Inline code (backticks)
@@ -23,6 +22,7 @@ function remarkEscapeComponents() {
2322 . replace ( / < ( [ A - Z ] [ a - z A - Z 0 - 9 ] * (?: \s [ ^ < ] * ) ? ) > / g, REPL_LT + '$1>' )
2423 . replace ( / < \/ ( [ A - Z ] [ a - z A - Z 0 - 9 ] * ) > / g, REPL_LT + '/$1>' ) ;
2524 }
25+
2626 // Code fences (``` blocks)
2727 if ( node . type === 'code' ) {
2828 // Only escape if not live
You can’t perform that action at this time.
0 commit comments