Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax highlight custom definitions #5

Open
Brayden opened this issue Feb 14, 2024 · 0 comments
Open

Syntax highlight custom definitions #5

Brayden opened this issue Feb 14, 2024 · 0 comments

Comments

@Brayden
Copy link
Member

Brayden commented Feb 14, 2024

Removing this from the code since it was commented out and unused at the moment, but would be great to add back in shortly. Whenever we want to add custom syntax token styles we can use regex to identify and add it to the Prism rules. Placing code here for reference.

// Add Prism JS
        const script = document.createElement('script');
        script.src = "./universe-editor/prism-lite/prism.js";
        script.onload = () => {
            setTimeout(() => {
                this.redrawSyntaxHighlighting();
                this.updateLineNumbers();
            }, 0);

            // if (typeof Prism !== 'undefined') {
            //     console.log("Prism is loaded: ", Prism.languages);
            //     // Ensure Prism and its languages are loaded
            //     // if (Prism.languages.javascript && Prism.languages.sql) {
            //         console.log("Prism languages are loaded");
            //         // Define a new token for highlighting "user_profile"
            //         const schemaPattern = {
            //             'db-schema': { // This is the token name
            //                 pattern: /\buser_profile\b/, // Matches "user_profile" as a whole word
            //                 // alias: 'special-class' // Use 'alias' to apply a special CSS class
            //             }
            //         };
        
            //         // Insert the new token in JavaScript and SQL languages before 'keyword', or another suitable token
            //         Prism.languages.insertBefore('javascript', 'keyword', schemaPattern);
            //         Prism.languages.insertBefore('sql', 'keyword', schemaPattern);
            //     // }
        
            //     Prism.highlightAllUnder(this.shadow);
            // }
        };
        this.shadow.appendChild(script);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant