-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[WIP] Simplify core #3905
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
base: v2
Are you sure you want to change the base?
[WIP] Simplify core #3905
Conversation
✅ Deploy Preview for dev-prismjs-com ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
I can't comment on the corresponding line since it's not in the PR, but I can't understand why we need a add<Name extends string> (name: Name, callback: HookCallback<Name>): () => void {
let hooks = this._all.get(name);
if (hooks === undefined) {
hooks = [];
this._all.set(name, hooks);
}
const list = hooks;
list.push(callback as never);
return () => {
const index = list.indexOf(callback as never);
if (index !== -1) {
list.splice(index, 1);
}
};
} |
Co-authored-by: Dmitry Sharabin <dmitrysharabin@gmail.com>
src/core/prism-class.ts
Outdated
* See {@link highlight} | ||
*/ | ||
highlight (text: string, language: string, options?: HighlightOptions): string { | ||
return highlight.call(this, text, language, options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this suggestion is on the wrong line
Co-authored-by: Dmitry Sharabin <dmitrysharabin@gmail.com>
src/global.ts
Outdated
const globalPrism = (namespace[globalSymbol] ??= new Prism()); | ||
declare global { | ||
var Prism: Prism | undefined | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, that's just what the code example I found for extending global
was using 😛 But this suggestion is also on the wrong line.
Co-authored-by: Dmitry Sharabin <dmitrysharabin@gmail.com>
*/ | ||
private loadingList: Promise<T>[] = []; | ||
|
||
ready: Promise<T[]>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't ready
be a getter to become reactive? We change dynamically loadingList
(ready
depends on it). However, we set the value of ready
once when creating an instance of a registry and never update it. As a result, we have ready
that is always fulfilled, even though there might be promises that are not fulfilled in the loadingList
array.
Or should we update ready
every time we update loadingList
? Or is there another option I'm not seeing?
Things to implement before merging:
Something else? |
For
|
Yup, this is related to something we've already started to discuss. |
We had an [issue](ony3000/prettier-plugin-merge#36) formatting complex files with many regexes, which is now fixed.
That does not address why it stopped working. This was even working in v1. And the code to make it work is still there I believe (in tokenize) |
* [C] Fix transformation bug: `macro` should be inserted before `string` * [F#] Specify the base language * [extend] Deeply nested objects can be `undefined` * [C#] Specify the base language + remove unused imports * [PHP] Add missed tokens * [VB.NET] Fix language definition * [MD] Correctly capture the language code
…ot yet resolved (#3951)
- Add the missing inside token and fix the existing one - Fix the regex that is too greedy now: if we have more than one code block next to each other, all of them starting from the second one will be interpreted as a code block of the first one - Ignore spaces before the language code
* Vala * Firestore security rules * Xeora * Flow * Wiki * V * Velocity * glsl * gml * Go * gradle * groovy * haxe * kotlin * javadoc * squirrel * hlsl * idris * json5 * jsonp * less * n4js * objectivec * opencl * sqf * sparql * solidity * scala * reason * racket * qore * purescript * purebasic * protobuf * processing * plsql * phpdoc * mongodb * jolie * latte * parser * textile * qsharp * ruby * sass * scss * xquery * http * haml * rescript
…ditions/removals (#3961) Credit: https://github.com/mavoweb/mavo/blob/78efe2b9cadd09c1d131b8afd5fe2f38d5cfa8c7/src/mavo.js#L845 Partially addresses #3960
* Place plugin docs along with their source code (#3930) * [autoloader] Fix script name in the docs * [normalize-whitespace] Don't consider demo as a plugin * Generate `file-sizes.json` during the build (#3946) * Exclude plugins' `demo.js` files from type checking * Fix path to the core entry point in `components.json` * Move and rename themes (#3947) - Move themes to the `src` folder and remove the `prism-` prefix - Adjust the build process accordingly - Adjust themes' metadata: - Remove broken links - Add/update authors' full names - Update GitHub handles - Use Markdown-style links - In `components.json`, fix theme ids and add Lea Verou as the owner to the prism, dark, and funky themes * Update themes' docs (#3958) So that they follow the structure (we can parse and use on the website): ``` /** * <title> * * <description> * * @author <name> (<GitHub_username>) */ ``` Between the data chunks, there should be at least one empty line. * Move `combineCallbacks` to its own module (#3963) * Move the `Token` class under the `classes` folder * Move all utils for working with iterables to a separate module Remove unused utils * Simplify hooks * Move the `Prism` class, add Prism singleton * Simplify the `Prism` class Move to separate modules: - `highlightAll()` - `highlightElement()` - `highlight()` - `stringify()` * Correctly parse CLI arguments (#3972) Was fixed in #3949 (in the `simplify` branch). Move it here to make testing easier. * Simplify the `Prism` class even more - Move `tokenize()`, `_matchGrammar()` (and related code), and `resolve()` to separate modules. - Ditch the `tokenize` symbol in favor of the `$tokenize` special property. Since symbols are excluded from the `for…in` loop, and `$tokenize` is not a symbol, to preserve the previous behavior, we need to handle it in `_matchGrammar` explicitly. - Switch from `[tokenize]` to `$tokenize` in languages. --- Co-authored-by: Dmitry Sharabin <dmitrysharabin@gmail.com> * Ditch the `rest` symbol in favor of the `$rest` special property * Move language utils to `util/` and separate them out * Remove known plugins + type safety * Move `documentReady` to async utils * Make the global bundle of Prism v2 work the same way as Prism v1 does Now, the user can include Prism the way they used to (except v2 now uses the Autoloader plugin under the hood, so more languages can be highlighted right out of the box): ```html <link rel="stylesheet" href="themes/prism.css" /> <script src="prism.js"></script> ``` Besides, they have access to the Prism instance via `globalThis`. * Move Prism config to a separate file and fix the build options of the global bundle Co-Authored-By: Dmitry Sharabin <dmitrysharabin@gmail.com> * Fix some code after merging --------- Co-authored-by: Lea Verou <lea@verou.me>
No description provided.