Browse Source

[Beta] Highlight <Foo> and <foo> differently (#5368)

main
dan 2 years ago
committed by GitHub
parent
commit
add83faad2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      beta/patches/@codemirror+lang-javascript+0.19.6.patch
  2. 26
      beta/patches/@codesandbox+sandpack-react+1.15.5.patch
  3. 345
      beta/patches/@lezer+javascript+0.15.2.patch
  4. 7
      beta/src/components/MDX/CodeBlock/CodeBlock.tsx

15
beta/patches/@codemirror+lang-javascript+0.19.6.patch

@ -0,0 +1,15 @@
diff --git a/node_modules/@codemirror/lang-javascript/dist/index.js b/node_modules/@codemirror/lang-javascript/dist/index.js
index d089f6b..db09ea6 100644
--- a/node_modules/@codemirror/lang-javascript/dist/index.js
+++ b/node_modules/@codemirror/lang-javascript/dist/index.js
@@ -131,7 +131,9 @@ const javascriptLanguage = /*@__PURE__*/LRLanguage.define({
JSXText: tags.content,
"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag": tags.angleBracket,
"JSXIdentifier JSXNameSpacedName": tags.tagName,
- "JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName": tags.attributeName
+ "JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName": tags.attributeName,
+ "JSXAttribute/JSXLowerIdentifier JSXAttribute/JSXNameSpacedName": tags.attributeName,
+ "JSXBuiltin/JSXIdentifier": tags.standard(tags.tagName),
})
]
}),

26
beta/patches/@codesandbox+sandpack-react+1.15.5.patch

File diff suppressed because one or more lines are too long

345
beta/patches/@lezer+javascript+0.15.2.patch

File diff suppressed because one or more lines are too long

7
beta/src/components/MDX/CodeBlock/CodeBlock.tsx

@ -3,11 +3,10 @@
*/
import cn from 'classnames';
import {highlightTree} from '@codemirror/highlight';
import {highlightTree, HighlightStyle, tags} from '@codemirror/highlight';
import {javascript} from '@codemirror/lang-javascript';
import {html} from '@codemirror/lang-html';
import {css} from '@codemirror/lang-css';
import {HighlightStyle, tags} from '@codemirror/highlight';
import rangeParser from 'parse-numeric-range';
import {CustomTheme} from '../Sandpack/Themes';
@ -233,7 +232,7 @@ function getSyntaxHighlight(theme: any): HighlightStyle {
class: classNameToken('static'),
},
{
tag: tags.tagName,
tag: tags.standard(tags.tagName),
class: classNameToken('tag'),
},
{tag: tags.variableName, class: classNameToken('plain')},
@ -244,7 +243,7 @@ function getSyntaxHighlight(theme: any): HighlightStyle {
},
{
// Highlight function definition differently (eg: functional component def in React)
tag: tags.definition(tags.function(tags.variableName)),
tag: [tags.definition(tags.function(tags.variableName)), tags.tagName],
class: classNameToken('definition'),
},
{

Loading…
Cancel
Save