-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[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
Draft
LeaVerou
wants to merge
110
commits into
v2
Choose a base branch
from
simplify
base: v2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
[WIP] Simplify core #3905
Changes from all commits
Commits
Show all changes
110 commits
Select commit
Hold shift + click to select a range
3beff85
[WIP] Simplify core
LeaVerou 46806b6
highlightAll
LeaVerou e4f6634
Just use properties on env, not a separate `state` property
LeaVerou 183817c
Move singleton, eliminate state further
LeaVerou d1097d8
Finish removing HookState
LeaVerou e3e5db2
Update prism-class.ts
LeaVerou c866261
Delete hook-state.ts
LeaVerou 8ce6c69
Move more functions out of prism-class
LeaVerou 1a2c60b
Merge branch 'v2' into simplify
LeaVerou 52fca5d
Move tokenize
LeaVerou 1158aa9
Update src/core.ts
LeaVerou 9acac36
Update src/types.d.ts
LeaVerou 8a8bc18
Update src/global.ts
LeaVerou e0ca584
Update hooks.ts
LeaVerou 2727307
Update hooks.ts
LeaVerou 96e93ea
Update src/core/prism-class.ts
LeaVerou dbbb0dd
Update src/global.ts
LeaVerou 4dfff4c
Update registry.ts
LeaVerou a2a5d23
Update eslint.config.mjs
LeaVerou 1e31274
Remove known plugins
LeaVerou ca6df67
Update prism.ts
LeaVerou 051e0e6
Update src/core/highlight.ts
LeaVerou 2147cae
Update src/core/highlight.ts
LeaVerou aac6bf7
Merge branch 'v2' into simplify
LeaVerou 6513275
Merge branch 'simplify' of https://github.com/PrismJS/prism into simp…
LeaVerou de0b0bd
Update src/plugins/keep-markup/prism-keep-markup.ts
LeaVerou 83fad95
[build] Delete `known-plugins.d.ts`
DmitrySharabin b4366b2
[WIP] Make language definitions more declarative, simplify registry, …
LeaVerou 73ef579
Merge branch 'simplify' of https://github.com/PrismJS/prism into simp…
LeaVerou 0762142
Fixes (#3915)
LeaVerou 60cadeb
`extends` -> `base` and a few other things
LeaVerou c7ce545
Fix `c`
LeaVerou abf6b71
Concept for language extensions
LeaVerou 52fe2ae
Move $insertBefore and $delete to extend()
LeaVerou e12f6df
Separate language patches from other eval, attempt to move types to m…
LeaVerou 42312a5
Update actionscript.ts
LeaVerou 4d8b9ea
Update bison.ts
LeaVerou f997850
Type wrangling
LeaVerou 5bf9582
Merge branch 'v2' into simplify
LeaVerou 93bbe20
Some suggestions (#3919)
DmitrySharabin 0e674d2
Add proper typing for the `Grammar` type (#3918)
DmitrySharabin 107632e
Preserve context
DmitrySharabin bf68a19
Merge branch 'simplify' of https://github.com/PrismJS/prism into simp…
LeaVerou b7623b6
Move iterable helpers to separate file
LeaVerou b850074
TS
LeaVerou bc5144f
Merge branch 'v2' into simplify
LeaVerou 1deb867
Update eslint.config.mjs
LeaVerou 257e650
WIP, improve API around languages
LeaVerou 552c9e6
First pass on transforming `php` and `php-extras` (#3922)
DmitrySharabin 1c3531c
First pass on transforming ASP.NET (C#) (#3920)
DmitrySharabin 269f5d4
First pass (#3921)
DmitrySharabin 9a70161
Move grammar back into types
LeaVerou 9ffbe35
Languages
LeaVerou 6a14538
Drop tokenize and rest symbols in favor of $tokenize and $rest proper…
LeaVerou 0ea3547
Update tokenize.ts
LeaVerou 586bd55
Sample rewrite to show what group matching + $language can do
LeaVerou 69f8bf3
Remove effect from languages
LeaVerou 097f21a
Suggestions to the `simplify` branch (#3925)
DmitrySharabin 6fb945c
Allow implicit any
LeaVerou f7c21f6
Move language utils to `util/` and separate them out
LeaVerou 1baaebf
Add aliases to C++, C#, F# so markdown doesn't need to handle them sp…
LeaVerou b5d562e
Drop xml-doc
LeaVerou ff26b79
Drop shared file, not worth it
LeaVerou 42ebc79
Some more work on dynamic langs (still very WIP)
LeaVerou 9fb2ed1
`resolveGrammar` -> `grammarPatch`
LeaVerou 3d760a5
insertAfter, deep keys
LeaVerou 9dc1677
Make php-extras just a part of PHP
LeaVerou ba3a8b4
Add media types and extensions
LeaVerou dcf018c
Fix typo
DmitrySharabin 577eb31
Some more suggestions to the `simplify` branch (#3926)
DmitrySharabin 6661905
Preserve accessors when extending/copying objects
LeaVerou b76f673
Suggestions (next iteration) (#3928)
DmitrySharabin a08fd18
Simplify hooks, add type safety
LeaVerou e2d15e9
Update util.ts
LeaVerou dedc06d
WIP
LeaVerou abc87fd
Update src/core/classes/language-registry.ts
LeaVerou 1b7e413
Update highlight.ts
LeaVerou c08e814
Merge branch 'simplify' of https://github.com/PrismJS/prism into simp…
LeaVerou 5f1da53
Update src/core/classes/hooks.ts
LeaVerou 97a28fd
Drop `$language`
LeaVerou 0d0ea00
Break down `tokenize.ts` into separate modules
LeaVerou ff0a08b
Prettier
LeaVerou 4a631e9
Registry -> ComponentRegistry
LeaVerou 4e3f178
async util
LeaVerou c03ab64
Update eslint.config.mjs
LeaVerou 7c8205a
Update async.ts
LeaVerou 4a71b8d
Update async.ts
LeaVerou 3e1e9c7
Update language.ts
LeaVerou 2f5c194
Update language.ts
LeaVerou eb5e425
Update types.d.ts
LeaVerou f069a78
tokenize
LeaVerou 1888f4a
Move Token class to classes
LeaVerou 3a25f8e
First stab at functional $inside/$rest
LeaVerou 630b6d4
Some suggestions to the `simplify` branch (#3939)
DmitrySharabin 7a7979c
Update the `Language` class (#3941)
DmitrySharabin a1112bc
Some fixes to `tokenize` (#3942)
DmitrySharabin bc34dde
Partially fix tests (in the `simplify` branch) (#3940)
DmitrySharabin e07c8b7
Another attempt to avoid the “too deep” structure error and not fall…
DmitrySharabin ca7fc26
Update Prettier plugins (#3945)
DmitrySharabin ccbc10b
Bug fixes (the `simplify` branch) (#3943)
DmitrySharabin 3935b1a
Correctly parse CLI arguments (#3949)
DmitrySharabin 0725758
Make `nextTick()` work in environments other than browsers (#3952)
DmitrySharabin b86c4e0
Resolve the language if its definition is already loaded, and it is n…
DmitrySharabin 830fdff
Fix the Markdown language (#3950)
DmitrySharabin 5660d05
Transform languages (#3948)
DmitrySharabin 37bdeeb
Fix the gradle language (#3955)
DmitrySharabin 7c7c598
In addition to waiting for all promises to settle, handle post-hoc ad…
DmitrySharabin d8246d5
Integrate changes from the `v2` branch (#3982)
DmitrySharabin 54a2dfa
Merge branch 'v2' into simplify
DmitrySharabin d110fa7
Fix issues after resolving conflicts
DmitrySharabin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| /src/plugins | ||
| tsconfig.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| const hasDOM = typeof document !== 'undefined' && typeof window !== 'undefined'; | ||
| const scriptElement: HTMLOrSVGScriptElement | null = hasDOM ? document.currentScript : null; | ||
| const globalConfig: Record<string, PrismConfig[keyof PrismConfig] | null> = | ||
| // @ts-ignore | ||
|
Check warning on line 4 in src/config.ts
|
||
| globalThis.Prism?.constructor?.name === 'Object' ? globalThis.Prism : {}; | ||
|
|
||
| function getGlobalSetting (name: string) { | ||
| // eslint-disable-next-line regexp/no-unused-capturing-group | ||
| const camelCaseName = name.replace(/-([a-z])/g, g => g[1].toUpperCase()); | ||
| let camelCaseName = name.replace(/-([a-z])/g, g => g[1].toUpperCase()); | ||
DmitrySharabin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if (camelCaseName in globalConfig) { | ||
| return globalConfig[camelCaseName]; | ||
|
|
@@ -32,12 +32,38 @@ | |
| return !(value === false || value === 'false'); | ||
| } | ||
|
|
||
| function getGlobalArraySetting (name: string): string[] { | ||
| const value = getGlobalSetting(name); | ||
| if (value === null || value === undefined || value === false || value === 'false') { | ||
| return []; | ||
| } | ||
| else if (typeof value === 'string') { | ||
| return value.split(',').map(s => s.trim()); | ||
| } | ||
| else if (Array.isArray(value)) { | ||
| return value; | ||
| } | ||
|
|
||
| return []; | ||
| } | ||
|
|
||
| export interface PrismConfig { | ||
| manual?: boolean; | ||
DmitrySharabin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| silent?: boolean; | ||
| errorHandler?: (reason: any) => PromiseLike<never>; | ||
| plugins?: string[]; | ||
| languages?: string[]; | ||
| pluginPath?: string; | ||
| languagePath?: string; | ||
| } | ||
|
|
||
| export const globalDefaults: PrismConfig = { | ||
| manual: getGlobalBooleanSetting('manual', !hasDOM), | ||
DmitrySharabin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| silent: getGlobalBooleanSetting('silent', false), | ||
| languages: getGlobalArraySetting('languages'), | ||
| plugins: getGlobalArraySetting('plugins'), | ||
| languagePath: (getGlobalSetting('language-path') ?? './languages/') as string, | ||
| pluginPath: (getGlobalSetting('plugin-path') ?? './plugins/') as string, | ||
| }; | ||
|
|
||
| export default globalDefaults; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| export { Prism } from './core/prism'; | ||
| export { default as Prism } from './core/classes/prism'; | ||
| export { Token } from './core/classes/token'; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.