|
984e5d2e
|
2020-01-31T22:50:59
|
|
Core: Fixed scope problem in script mode (#2184)
A function in Core was defined inside an `if` which isn't allowed in JS strict mode.
|
|
a7f70090
|
2019-12-02T14:10:53
|
|
Added new Filter highlightAll plugin (#2074)
This adds a new plugin to Prism which allows users to filter which elements will be highlighted by the `highlightAll` and `highlightAllUnder` methods.
|
|
0fd062d5
|
2019-11-01T22:31:17
|
|
Core: Fixed null reference (#2106)
The new defer logic in Prism Core did not handle that the script element might be null.
|
|
2108c60f
|
2019-10-25T17:34:50
|
|
Core: IE11 workaround for currentScript (#2104)
This adds a new function `Prism.util.currentScript` which is a functionally equalent to `document.currentScript` but includes support for IE11.
|
|
a3785ec9
|
2019-10-25T17:05:23
|
|
Core: Fixed race condition caused by deferring the script (#2103)
This fixes a race condition that can occur when deferring Prism components.
For more details see #2102.
|
|
d49f0f26
|
2019-09-03T16:40:02
|
|
Doubly check the `manual` flag (#1957)
This fixes the behavior of manual highlighting where it would highlight everything even with `manual: true`.
This also adds doc as to how manual highlighting works.
|
|
2d858e0a
|
2019-08-31T15:43:28
|
|
Core: Minor improvements (#1973)
This makes some minor improvements to Prism Core like refactoring and style clean up.
|
|
174ed103
|
2019-08-29T23:38:59
|
|
Core: Fixed greedy partial lookbehinds not working (#2030)
This fixes the bug that greedy patterns with a lookbehind group did not support other top-level alternatives (e.g. `/foo|(lookbehind)bar/`) causing an error when used.
|
|
e864d518
|
2019-08-29T23:24:17
|
|
Core: Fixed greedy targeting bug (#1932)
The `target` parameter defines the token which causes rematching. Rematching is done by recursively calling `matchGrammar` where `target` will be the current token name. The rematching is done if either a match was found or we reached the target token, whatever comes first.
The bug is that a token is identified by its name. But the name alone doesn't uniquely identify a token in a grammar because many tokens can have the same name (array).
This fixes this bug.
|
|
9d9e2ca4
|
2019-07-11T16:28:49
|
|
Removed env.elements in 'before-highlightall' hook (#1968)
This removes the `env.elements` property from the environment of the `before-highlightall` hook.
**Why?**
- There is no plugin that is using it.
- It is inherently incompatible with `env.selector`. Even if a plugin using `elements` wanted to respect `selector` it would not be able to because 1) there might be plugins after it (in `before-highlightall`) extending the selector and 2) the plugin has no access to the current `container`.
**Isn't this a breaking change?**
Yes, but I don't think that this will have any impact for the above reasons and because from a user perspective, it's hard to use than just iteration over your elements and calling `Prism.highlightElement` yourself.
|
|
fd691c52
|
2019-04-23T00:33:15
|
|
Core: Made `language-none` the default language (#1858)
This makes `language-none` the default language of a highlighted element in the case that no `language-xxxx` class is provided or inherited.
|
|
65a4e894
|
2019-03-28T23:47:49
|
|
Removed `parent` from the `wrap` hook's environment (#1837)
This removes the `parent` property of the `wrap` hook and the parameter from `Token.stringify`.
|
|
11d0f75e
|
2019-03-14T13:17:45
|
|
Applied Array.isArray (#1804)
This replaces all occurrences of `Prism.util.type(variable) {!==, ===} 'Array'` with an equivalent `Array.isArray` expression.
|
|
3e00bb9c
|
2019-03-07T15:22:30
|
|
Rebuilt Prism (#1794)
This is a rebuilt of Prism to update minified files.
|
|
bac09f0a
|
2019-03-02T17:27:19
|
|
Made prism-core a little more editor friendly (#1776)
This makes the structure of prism-core easier to understand for editors.
|
|
b06f532f
|
2019-03-01T01:19:29
|
|
Core: Avoid redeclaring variables in util.clone (#1778)
This changes util.clone to be more readable and to avoid redeclaring the `clone` and `id` variables.
|
|
152a68ef
|
2019-02-28T21:36:57
|
|
Improved languages.DFS and util.clone (#1506)
Minor improvements for the two functions.
|
|
393ab164
|
2019-01-22T13:36:32
|
|
Call `insert-before` hook properly (#1709)
Fixes #1706 (also includes a demo).
The problem was that the `insert-before` hook was not called if `grammar` is undefined.
This also fixes that `callback` was not called in that case and that `env` of the `complete` hook did not have a `highlightedCode` property.
All other hooks are unchanged. The `insert-before` hook is only used by the Command line plugin, so there should be no other side effects.
|
|
d33d259c
|
2018-12-02T00:02:57
|
|
Ignore duplicates in insertBefore (#1628)
Fix #1525 and implement option number 2.
|
|
39686e12
|
2018-12-01T19:51:08
|
|
Remove unused `insertBefore` overload (#1631)
Mentioned in #1505.
|
|
2864fe24
|
2018-11-28T14:54:29
|
|
Improve `Prism.util.type` performance (#1545)
Drop the regex in favor of a faster `slice` call.
|
|
bfbe4464
|
2018-10-24T04:08:51
|
|
Invoke `callback` after `after-highlight` hook (#1588)
Previously, `callback`, as passed to `Prism.highlightElement`, would get called before
all of the hooks had been run. This moves it after all the hooks, so it can truly be considered
a "complete" callback.
This could be a breaking change for any userland modifications that were expecting `callback`
to fire before plugins, but we expect this change to mostly conform with user expectations and
consider this a bugfix..
|
|
9dfec340
|
2018-08-18T22:04:51
|
|
`insertBefore` now correctly updates references (#1531)
Removes some workarounds for misplacing the reference when using `insertBefore`.
|
|
659ea314
|
2018-04-07T10:41:08
|
|
Core: Fix support for language alias containing dash `-`
|
|
294efaae
|
2018-03-26T20:48:26
|
|
Core: Greedy patterns should always be matched against the full string. Fix #1355
|
|
5f9c078a
|
2018-03-25T13:46:42
|
|
Make ERB, Handlebars, PHP and Smarty highlight properly in NodeJS (#1367)
|
|
2b8321d3
|
2018-03-20T08:37:58
|
|
JSX: Add support for plain text inside tags (#1357)
* JSX: Add support for plain text inside tags
* JSX: Use a "plain-text" token to identify plain text
* TSX: Add support for plain text
* Fix test after merge
|
|
f90d5559
|
2018-03-13T08:11:25
|
|
Core: Allow cloning of circular structures. (#1345)
|
|
e0cd47f8
|
2018-03-03T20:13:59
|
|
Core: Don't thow an error if lookbehing is used without anything matching.
|
|
69f2e2cb
|
2017-12-06T04:10:50
|
|
Allow any element being root instead of document. (#1230)
(better compatibility than #397)
|
|
d09982d8
|
2017-11-05T14:24:19
|
|
Core: Provide a way to load Prism from inside a Worker without listening to messages. (#1188)
Using disableWorkerMessageHandler config.
|
|
c33be19a
|
2017-11-05T13:32:00
|
|
Core: Prevent error from throwing when element does not have a parentNode in highlightElement. Fix #1203
|
|
de996d7d
|
2017-10-21T10:17:56
|
|
Merge branch 'remove_spellcheck_attribute' of https://github.com/emmanuelgautier/prism into emmanuelgautier-remove_spellcheck_attribute
# Conflicts:
# components/prism-core.min.js
|
|
25788eb5
|
2017-09-09T12:05:55
|
|
Merge branch 'RemoveIE8' of https://github.com/zeitgeist87/prism into zeitgeist87-RemoveIE8
# Conflicts:
# components/prism-core.js
# components/prism-core.min.js
# plugins/line-highlight/prism-line-highlight.js
# plugins/line-highlight/prism-line-highlight.min.js
# prism.js
|
|
e13fdfa4
|
2017-02-08T17:19:22
|
|
Add minor optimizations for the greedy flag
|
|
1736f4aa
|
2017-02-08T01:36:27
|
|
Fix corner cases for the greedy flag
By refactoring the tokenize() method into two separate methods, it is
possible to recursively clean up any broken tokens left by the greedy
feature.
This should fix the issue 1075.
|
|
70cb4729
|
2017-05-08T11:44:21
|
|
Run before-highlight and after-highlight hooks even when no grammar is found. Fix #1134
|
|
01e74afa
|
2017-02-28T12:42:27
|
|
remove comments spellcheck for amp validation
|
|
7192ffef
|
2017-01-28T09:57:30
|
|
Run gulp
|
|
b8ce1e7c
|
2016-12-03T11:52:48
|
|
Merge branch 'gh-pages' of https://github.com/PrismJS/prism into gh-pages
# Conflicts:
# components/prism-core.min.js
|
|
83bafbd4
|
2016-12-03T11:46:26
|
|
env.code can be modified by before-sanity-check hook even when using language-none. Fix #1066
|
|
17e33bc0
|
2016-11-20T12:52:54
|
|
Reduce risk of XSS (#1051)
* Skip non-own properties of env.attributes
Use `Object.keys` instead of a for-in loop to find optional attributes.
The former only grabs keys that are own properties, the latter also
includes inherit properties from `Object.prototype`.
This reduces the risk of XSS if an attacker somehow manages to
manipulate the prototype chain of the Object prototype.
* Fix root cause of XSS in autolinker plugin #1054
* command-line plugin: Safely encode attributes
If an attacker has control over the values of the attributes
"data-prompt", "data-user", or "data-host", then XSS was possible.
This fixes the issue, by encoding quotes as the `"` entity.
* show-language plugin: innerHTML -> textContent
There is no need for `innerHTML` here. At best nothing happens,
at worst XSS is possible (though the odds are negligible since
the attacker would have to control the detected language).
* toolbar plugin: innerHTML -> textContent
|
|
32cd99ff
|
2016-10-24T21:21:37
|
|
Fix greedy-flag bug
This bug occurs in the relatively rare case of a pattern matching the
empty string. It was reported in issue #1039. If for example a HTML
page contains an empty script tag `<script></script>` then the script
pattern will match anything inside, which is the empty string.
This empty string is then passed to the constructor of the Token class.
Since `""` is falsy in Javascript the property `matchedStr` is set to
`null`.
But the property `matchedStr` is needed to calculate the current
position for the greedy feature. A `null` value in `matchedStr` results
in a `pos` that is `NaN`. This causes the bug described in issue #1039.
Since the property `matchedStr` is only ever needed to calculate the
length of the Token, it is more efficient to store the length directly
instead of the string. As a side effect this also fixes issue #1039.
|
|
3dc8c9e1
|
2016-07-11T20:36:16
|
|
Don't insert space before ">" when there is no attributes
|
|
3780571b
|
2016-07-03T11:59:59
|
|
Remove IE8 plugin
|
|
c9bdcd35
|
2016-07-03T02:37:29
|
|
Manual merge of #988. Closes #988, fixes #987.
|
|
9893489c
|
2016-06-18T14:18:27
|
|
Replace flags property of RegExp with a more compatible alternative
|
|
d80900cc
|
2016-06-04T19:52:38
|
|
Improvement to greedy-flag
This patch expands the idea of the greedy flag and significantly
improves it, by matching against the whole text instead of just
the next couple of tokens. This does not only improve the
results, but it should also slightly improve performance.
|
|
f130680c
|
2016-05-29T11:15:59
|
|
Use requestAnimationFrame instead of setTimeout
|
|
4eb7ee45
|
2016-05-26T11:27:03
|
|
Allow for asynchronous loading of prism.js
|
|
acd9508f
|
2016-05-17T14:23:02
|
|
Use toLowerCase on language names
|
|
21dd0d14
|
2016-02-15T23:08:24
|
|
Use a HTML-comment to escape code
|
|
49cf8991
|
2016-03-08T15:03:59
|
|
Fix minor bug with new greedy-feature
This fixes a minor bug that causes invalid highlighting in some
edge cases, where two greedy patterns overlap each other.
|
|
c88036ca
|
2016-02-19T22:27:22
|
|
Add tests for new greedy-pattern feature and fix bug in Kotlin
This patch adds tests for the new greedy-pattern feature and fixes
a small bug in the Kotlin language, that resulted from that.
It also cleans up some of the comments and refactors a few lines
in the tokenloop.
|
|
2705c509
|
2015-09-24T19:36:10
|
|
Partial solution for the "Comment-like substrings"-problem
This patch introduces a new attribute called `greedy`. The
attribute is a simple boolean flag. If there is no match
for a greedy pattern it can concatenate the next two tokens
into a single string and try to match on this string again.
If a match is found on the second attempt, then the old tokens are
deleted and replaced by the new match.
This solves the "Comment-like substrings"-problem for exactly one
comment at very little cost. With this patch the following code is
highlighted correctly:
"foo /* bar */ baz"; "foo // bar";
/lala"test"sdf/;
This approach fails if there are more than one comments inside the
string:
"foo /* bar */ baz /* bar */ baz";
Signed-off-by: Andreas Rohner <andreas.rohner@gmx.net>
|
|
af8da8ec
|
2016-02-14T21:08:14
|
|
Implemented @zeitgeist87’s suggestion in #890 re: env.elements
|
|
b86c727a
|
2016-02-03T15:25:26
|
|
Fix DFS bug
The DFS function uses an object as a key into another object. This
doesn't work, because the key gets stringified to "[object
Object]" and is therefore useless.
|
|
0e87ff0a
|
2016-01-27T11:55:16
|
|
Add solarized light theme to the list of themes and update
auto-generated files generated by gulp.
|
|
7fab7a2d
|
2016-01-26T23:16:06
|
|
Reverse merge of last PR and remove the 'data-selector' attribute.
|
|
77c6ea17
|
2016-01-26T02:33:20
|
|
Allow users to use their own element selector
Add the parameter 'data-selector' to the script tag, to
allow users to set the selector used to query for code elements.
|
|
1eb9a5fb
|
2016-01-17T13:56:32
|
|
Update auto-generated files
|
|
97d0f49a
|
2015-12-26T09:50:23
|
|
Update auto-generated files
|
|
09be99e7
|
2015-09-23T20:34:29
|
|
Improve performance by doing more work in the worker
Currently the worker tokenizes the code and then turns it into a
JSON string. This JSON string is sent back to the main thread as a
message and parsed. Then it is turned into a HTML string and
stored in the attribute env.highlightedCode.
These conversions into JSON are unnecessary, because we can create
the HTML string directly in the worker and send it as a message to
the main thread.
Signed-off-by: Andreas Rohner <andreas.rohner@gmx.net>
|
|
b2f14d96
|
2015-09-04T08:19:21
|
|
Merge branch 'plugin-jsonp' of https://github.com/nauzilus/prism into gh-pages
Conflicts:
components/prism-core.min.js
|
|
e42a2289
|
2015-09-03T22:47:50
|
|
Explicitly make the Worker close itself after highlighting, so that users have control on this behaviour when directly using Prism inside a Worker. Fix #492
|
|
0356c58c
|
2015-09-03T19:09:48
|
|
Apply changes from #754 to all plugins so that none of them throw errors in node.
Autolinker, Show invisibles and WPD can now be used with node.
Removed unused minified CSS file.
Also added missing space between attributes during wrapping.
|
|
c8f83b20
|
2015-09-03T18:43:33
|
|
Run gulp task
|
|
ed9f2b21
|
2015-08-17T08:47:32
|
|
Move removal of initial line feed to a plugin
|
|
fd549959
|
2015-08-13T08:33:48
|
|
Fix complete hook behaviour + run gulp task
|
|
5f133c80
|
2015-07-16T21:09:40
|
|
Fixed prism-core and prism-file-highlight to prevent errors in IE8.
Used local variable _self instead of overwriting self.
Closes #468.
|
|
8030db91
|
2015-06-25T08:00:14
|
|
File Highlight: allow to specify the language (takes precedence over extension guess) + Set language on parent even if unknown. Fix #607
|
|
1eb49594
|
2015-02-18T21:52:53
|
|
Make use of method `_.util.type`.
|
|
c711660a
|
2015-01-15T09:00:47
|
|
Deep clone arrays
|
|
703d47e6
|
2015-01-11T23:18:41
|
|
Simplified regexp for trailing line feeds
|
|
36999ddf
|
2015-01-08T19:51:55
|
|
Handle trailing \r\n and \r
|
|
2d5089ed
|
2015-01-08T08:55:24
|
|
Remove leading line break
Fixes #455
|
|
86b4d4df
|
2014-12-20T14:21:28
|
|
Run gulp tasks
|
|
17d9aa8a
|
2014-11-14T20:30:10
|
|
insertBefore() with only two arguments appends (similar to how DOM insertBefore() behaves)
|
|
436a7bd6
|
2014-11-14T19:43:50
|
|
Make insertBefore() update pointers to the object from other language definitions.
Use case/Example: In dabblet, code-highlight.js adds some extra tokens to CSS. But CSS also extends markup to highlight CSS in style elements/attributes and that happens *before* the extra CSS tokens were added. However, because references were not updated, CSS highlighted in markup was using the original CSS definition, without the added tokens. I’m surprised we haven’t caught this earlier, I’d expect it to affect many advanced uses of Prism.
|
|
4b9e11c6
|
2014-11-14T19:19:31
|
|
CSS highlighting in HTML style attribute
|
|
08037e5b
|
2014-09-05T11:01:02
|
|
Fix for DFS bug with new pattern array feature
This patch implements support for the new pattern array feature in the
Prism.languages.DFS function and fixes a bug in the autolinker plugin.
It adds an optional parameter to the callback of Prism.languages.DFS,
which contains the type of the current object as oposed to the key in
the parent. In most cases both key and type are exactly the same. Only
if the parent is an array the key will contain the index number and the
type will contain the attribute name of the array in the parent object.
The key can be used to replace the object in the parent and the type can
be used to provide the necessary context.
|
|
3309890f
|
2014-08-12T13:48:47
|
|
Add option to define aliases for tokens
This patch adds an option called `alias`, which allows the
definition of additional CSS classes for token names. This can be
useful, to combine the styling of a well known token, which is already
supported by most of the themes, with a semantically correct token name.
The option can be set to a string literal or an array of string
literals. In the following example the token name `latex-equation` is
not supported by any theme, but it will be highlighted the same as a
string.
'latex-equation': {
pattern: /\$(\\?.)*?\$/g,
alias: 'string'
}
|
|
b1cc49d8
|
2014-08-23T20:02:02
|
|
Update minified and auto generated files
|
|
89bddb84
|
2014-08-12T11:27:26
|
|
Add automatically generated files
|
|
fef8cd49
|
2014-08-10T08:24:02
|
|
Allow multiple tokens to be mapped to the same CSS class
In most languages there are different ways of declaring the same
constructs, but with the current implementation of Prism it is only
possible to define one pattern for a particular token type. This is not
a problem, as long as it is possible to match everything with one regex.
But sometimes it isn't easily possible to do that, especially if things
like `lookbehind` or `inside` are needed for one part but not for the
other. This patch splits the token type into two parts, whereby the
second part is optional: {token type}#{description}
For example there is a minor bug in the current definition of the
`clike` language, that could be solved with this patch:
The character immediately in front of a single line comment is
highlighted as a comment as well.
something// something
This is because both definitions for single and multiline comments have
to be matched with a single regex and the `lookbehind` parameter can
only be applied to the first captured string.
With this patch one could split the two definitions up and use
`lookbehind` for both, thereby eliminating the bug.
'comment': {
pattern: /(^|[^\\])\/\*[\w\W]*?\*\//g,
lookbehind: true
},
'comment#single-line': {
pattern: /(^|[^\\:])\/\/.*?(\r?\n|$)/g,
lookbehind: true
},
|
|
4247baec
|
2014-07-28T16:54:50
|
|
Fix conflicts.
|
|
502ed6c1
|
2014-07-23T10:49:30
|
|
Don't set the `self` variable with `var`
Firefox directly shadows the global variable `self` if it is present (= in a worker). So we need to set `self` without `var self` but directly.
|
|
eb1cd1c9
|
2014-07-23T09:49:34
|
|
Fix workers
The issue is that in workers `window` is undefined.
Therefore, in the first line, `self` will be set to `{}`.
This will destroy the check for workers later on:
```js
if (!self.document) {
if (!self.addEventListener) {
// in Node.js
return self.Prism;
}
// In worker
// ...
}
```
because `self.addEventListener` will then be undefined (due to `self = {}`).
The fix is to make the check for the environment more clever:
1. check for the browser: `(typeof window !== 'undefined')`
2. check for a worker: `(typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)` (from http://stackoverflow.com/questions/7931182/reliably-detect-if-the-script-is-executing-in-a-web-worker)
3. assume we are in node
|
|
7cfd29a9
|
2014-05-26T11:20:55
|
|
Rebuild minified files.
|
|
4a472307
|
2014-05-24T16:14:20
|
|
Minified files
|
|
603a8a02
|
2014-05-24T15:26:54
|
|
Added twitter link to footer, minified some files
|
|
eb65c68b
|
2014-05-24T14:13:36
|
|
Generated minified versions & prism.js after merging #258
|
|
62561684
|
2014-05-22T17:36:51
|
|
Reversed change in Core
|
|
0bf2a8e5
|
2014-05-22T17:28:57
|
|
Updated minified files
|
|
8344fd5c
|
2014-04-21T13:37:18
|
|
Updated minified files
|
|
1d899d7d
|
2013-06-14T11:46:34
|
|
Fixed parsing for entities and <> chars
|
|
29b28801
|
2013-05-21T16:01:30
|
|
Added 'before-insert' hook. After when code is highlighted and before being inserted to document.
|
|
c82d6df0
|
2013-05-18T17:31:20
|
|
Added min files
|
|
801aab58
|
2013-05-11T04:37:44
|
|
Added parent access to wrap hook
|
|
c3a69913
|
2013-05-09T21:01:17
|
|
Added language id to wrap hook
|