From 439ea1ee9abdb63fb90a1cb61bea5860488f80ae Mon Sep 17 00:00:00 2001 From: Michael Schmidt Date: Mon, 11 Mar 2019 00:32:45 +0100 Subject: [PATCH] Added scripts directory (#1781) This adds a new `scripts` directory for all scripts used exclusively by the prismjs.com website. --- download.html | 10 +++--- examples.html | 10 +++--- extending.html | 6 ++-- faq.html | 36 +++++++++---------- index.html | 6 ++-- plugins/autolinker/index.html | 8 ++--- plugins/autoloader/index.html | 6 ++-- plugins/command-line/index.html | 8 ++--- plugins/copy-to-clipboard/index.html | 8 ++--- plugins/custom-class/index.html | 8 ++--- plugins/data-uri-highlight/index.html | 10 +++--- plugins/file-highlight/index.html | 18 +++++----- plugins/highlight-keywords/index.html | 6 ++-- plugins/index.html | 8 ++--- plugins/jsonp-highlight/index.html | 8 ++--- plugins/keep-markup/index.html | 8 ++--- plugins/line-highlight/index.html | 36 +++++++++---------- plugins/line-numbers/index.html | 8 ++--- plugins/normalize-whitespace/index.html | 6 ++-- plugins/previewers/index.html | 8 ++--- plugins/remove-initial-line-feed/index.html | 8 ++--- plugins/show-invisibles/index.html | 12 +++---- plugins/show-language/index.html | 8 ++--- plugins/toolbar/index.html | 6 ++-- plugins/unescaped-markup/index.html | 18 +++++----- plugins/wpd/index.html | 8 ++--- code.js => scripts/code.js | 0 download.js => scripts/download.js | 0 examples.js => scripts/examples.js | 0 .../prefixfree.min.js | 0 utopia.js => scripts/utopia.js | 0 {vendor => scripts/vendor}/FileSaver.min.js | 0 {vendor => scripts/vendor}/jszip.min.js | 0 {vendor => scripts/vendor}/promise.js | 0 test-suite.html | 6 ++-- test.html | 8 ++--- 36 files changed, 148 insertions(+), 148 deletions(-) rename code.js => scripts/code.js (100%) rename download.js => scripts/download.js (100%) rename examples.js => scripts/examples.js (100%) rename prefixfree.min.js => scripts/prefixfree.min.js (100%) rename utopia.js => scripts/utopia.js (100%) rename {vendor => scripts/vendor}/FileSaver.min.js (100%) rename {vendor => scripts/vendor}/jszip.min.js (100%) rename {vendor => scripts/vendor}/promise.js (100%) diff --git a/download.html b/download.html index 3c55072b1c..9b802edd7c 100644 --- a/download.html +++ b/download.html @@ -121,7 +121,7 @@ border-bottom-left-radius: 0; } - + @@ -169,12 +169,12 @@

Customize your download

+ - - - - + + + diff --git a/examples.html b/examples.html index b7dce551ce..e60984c4d7 100644 --- a/examples.html +++ b/examples.html @@ -43,7 +43,7 @@ padding-left: 40px; } - + @@ -99,12 +99,12 @@

Per language examples

+ - - - - + + + diff --git a/extending.html b/extending.html index 6abebd39bc..7b12a07b82 100644 --- a/extending.html +++ b/extending.html @@ -7,7 +7,7 @@ Extending Prism ▲ Prism - + @@ -240,10 +240,10 @@

Returns

+ - - + diff --git a/faq.html b/faq.html index 8d5da68472..1e8d0f513e 100644 --- a/faq.html +++ b/faq.html @@ -16,7 +16,7 @@ color: black; } - + @@ -25,33 +25,33 @@
- +

FAQ

Frequently Asked Questions, with a few Questions I want people to Frequently Ask.

This page doesn’t work in Opera!

- +

Prism works fine in Opera. However, this page might sometimes appear to not be working in Opera, due to the theme switcher triggering an Opera bug. This will be fixed soon.

Isn’t it bad to do syntax highlighting with regular expressions?

- -

It is true that to correctly handle every possible case of syntax found in the wild, one would need to write a full-blown parser. + +

It is true that to correctly handle every possible case of syntax found in the wild, one would need to write a full-blown parser. However, in most web applications and websites a small error margin is usually acceptable and a rare highlighting failure is not the end of the world. A syntax highlighter based on regular expressions might only be accurate 99% of the time (the actual percentage is just a guess), but in exchange for the small error margin, it offers some very important benefits: - +

- +

For this reason, most syntax highlighters on the web and on desktop, are powered by regular expressions. This includes the internal syntax highlighters used by popular native applications like Espresso and Sublime Text, at the time of writing. Of course, not every regex-powered syntax highlighter is created equal. The number and type of failures can be vastly different, depending on @@ -60,12 +60,12 @@

Isn’t it bad to do syntax highlighting with regular expressions?

Why is asynchronous highlighting disabled by default?

- +

Web Workers are good for preventing syntax highlighting of really large code blocks from blocking the main UI thread. In most cases, you will want to highlight reasonably sized chunks of code, and this will not be needed. Furthermore, using Web Workers is actually slower than synchronously highlighting, due to the overhead of creating and terminating the Worker. It just appears faster in these cases because it doesn’t block the main thread. - In addition, since Web Workers operate on files instead of objects, plugins that hook on core parts of Prism (e.g. modify language definitions) + In addition, since Web Workers operate on files instead of objects, plugins that hook on core parts of Prism (e.g. modify language definitions) will not work unless included in the same file (using the builder in the Download page will protect you from this pitfall). Lastly, Web Workers cannot interact with the DOM and most other APIs (e.g. the console), so they are notoriously hard to debug.

@@ -73,14 +73,14 @@

Why is asynchronous highlighting disabled by default?

Why is pre-existing HTML stripped off?

- -

Because it would complicate the code a lot, although it’s not a crucial feature for most people. + +

Because it would complicate the code a lot, although it’s not a crucial feature for most people. If it’s very important to you, you can use the Keep Markup plugin.

If pre-existing HTML is stripped off, how can I highlight certain parts of the code?

- +

There is a number of ways around it. You can always break the block of code into multiple parts, and wrap the HTML around it (or just use a .highlight class). You can see an example of this in action at the “Basic usage” section of the homepage.

Another way around the limitation is to use the Line Highlght plugin, to highlight and link to specific lines and/or line ranges. @@ -88,7 +88,7 @@

If pre-existing HTML is stripped off, how can I highlight certain parts of t

How do I know which tokens I can style for every language?

- +

Every token that is highlighted gets two classes: token and a class with the token type (e.g. comment). You can find the different types of tokens either by looking at the keys of the object defining the language or by running this snippet in the console:

function printTokens(o, prefix) { for (var i in o) { console.log((prefix? prefix + ' > ' : '') + i); if (o[i].inside) printTokens(o[i].inside, (prefix? prefix + ' > ' : '') + i); } };
@@ -135,7 +135,7 @@

How do I know which tokens I can style for every language?

How can I use different highlighting for tokens with the same name in different languages?

-

Just use a descendant selector, that includes the language class. The default prism.css does this, to have different colors for +

Just use a descendant selector, that includes the language class. The default prism.css does this, to have different colors for JavaScript strings (which are very common) and CSS strings (which are relatively rare). Here’s that code, simplified to illustrate the technique:


 .token.string {
@@ -159,8 +159,9 @@ 

How can I use different highlighting for tokens with the same name in differ
+ - + - - + diff --git a/index.html b/index.html index c65de9d9bf..10f9fb7430 100644 --- a/index.html +++ b/index.html @@ -11,7 +11,7 @@ Prism - + @@ -261,10 +261,10 @@

Credits

+ - - + + @@ -61,10 +61,10 @@

HTML

- + - + - \ No newline at end of file + diff --git a/plugins/autoloader/index.html b/plugins/autoloader/index.html index 3e5357e06b..dd7a55429f 100644 --- a/plugins/autoloader/index.html +++ b/plugins/autoloader/index.html @@ -22,7 +22,7 @@ content: ' [Generating... ' attr(data-progress) '%]'; } - + @@ -121,9 +121,9 @@

Examples

- + - + diff --git a/plugins/command-line/index.html b/plugins/command-line/index.html index 109138b671..9ab9dfb47e 100644 --- a/plugins/command-line/index.html +++ b/plugins/command-line/index.html @@ -9,7 +9,7 @@ - + @@ -101,11 +101,11 @@

Windows PowerShell With Output

- + - + - \ No newline at end of file + diff --git a/plugins/copy-to-clipboard/index.html b/plugins/copy-to-clipboard/index.html index c42a52620c..32056a0086 100644 --- a/plugins/copy-to-clipboard/index.html +++ b/plugins/copy-to-clipboard/index.html @@ -9,7 +9,7 @@ - + @@ -40,9 +40,9 @@

How to use

- + - + - \ No newline at end of file + diff --git a/plugins/custom-class/index.html b/plugins/custom-class/index.html index ee4fade718..1d5de4fa5d 100644 --- a/plugins/custom-class/index.html +++ b/plugins/custom-class/index.html @@ -8,7 +8,7 @@ - + @@ -18,7 +18,7 @@

Custom Class

-

This plugin allows you to prefix Prism default classes (.comment will become .namespace--comment) or replace them with your defined ones (like .editor__comment or .comment_7sh3a).

+

This plugin allows you to prefix Prism default classes (.comment will become .namespace--comment) or replace them with your defined ones (like .editor__comment or .comment_7sh3a).

@@ -125,9 +125,9 @@

Todo

- + - + diff --git a/plugins/data-uri-highlight/index.html b/plugins/data-uri-highlight/index.html index 380be2d67e..4b37d91a6c 100644 --- a/plugins/data-uri-highlight/index.html +++ b/plugins/data-uri-highlight/index.html @@ -9,7 +9,7 @@ - + @@ -31,7 +31,7 @@

How to use

Example

- +
div {
     border: 40px solid transparent;
     border-image: 33.334% url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="30" height="30"> \
@@ -51,10 +51,10 @@ 

Example

- + - + - \ No newline at end of file + diff --git a/plugins/file-highlight/index.html b/plugins/file-highlight/index.html index e66b9897ee..f1a8b7fb0a 100644 --- a/plugins/file-highlight/index.html +++ b/plugins/file-highlight/index.html @@ -9,7 +9,7 @@ - + @@ -25,14 +25,14 @@

File Highlight

How to use

- +

Use the data-src attribute on empty <pre> elements, like so:

- +
<pre data-src="myfile.js"></pre>
- +

You don’t need to specify the language, it’s automatically determined by the file extension. If, however, the language cannot be determined from the file extension or the file extension is incorrect, you may specify a language as well (with the usual class name way).

- +

Please note that the files are fetched with XMLHttpRequest. This means that if the file is on a different origin, fetching it will fail, unless CORS is enabled on that website.

@@ -48,7 +48,7 @@

Examples

The plugin’s JS code:


-	
+
 	

This page:


 
@@ -66,10 +66,10 @@ 

Examples

- + - + - \ No newline at end of file + diff --git a/plugins/highlight-keywords/index.html b/plugins/highlight-keywords/index.html index 466587346b..c18e319545 100644 --- a/plugins/highlight-keywords/index.html +++ b/plugins/highlight-keywords/index.html @@ -8,7 +8,7 @@ - + - + @@ -72,9 +72,9 @@

Examples

- + - + - \ No newline at end of file + diff --git a/plugins/line-highlight/index.html b/plugins/line-highlight/index.html index f3b58b4b41..4fc59d93f1 100644 --- a/plugins/line-highlight/index.html +++ b/plugins/line-highlight/index.html @@ -9,7 +9,7 @@ - + @@ -25,9 +25,9 @@

Line highlight

How to use

- +

Obviously, this only works on code blocks (<pre><code>) and not for inline code. - +

You specify the lines to be highlighted through the data-line attribute on the <pre> element, in the following simple format:

  • A single number refers to the line with that number
  • @@ -35,44 +35,44 @@

    How to use

  • Multiple line numbers or ranges are separated by commas.
  • Whitespace is allowed anywhere and will be stripped off.
- +

Examples:

5
The 5th line
- +
1-5
Lines 1 through 5
- +
1,4
Line 1 and line 4
- +
1-2, 5, 9-20
Lines 1 through 2, line 5, lines 9 through 20
- +

In case you want the line numbering to be offset by a certain number (for example, you want the 1st line to be number 41 instead of 1, which is an offset of 40), you can additionally use the data-line-offset attribute. - -

You can also link to specific lines on any code snippet, by using the following as a url hash: #{element-id}.{lines} where + +

You can also link to specific lines on any code snippet, by using the following as a url hash: #{element-id}.{lines} where {element-id} is the id of the <pre> element and {lines} is one or more lines or line ranges that follow the format outlined above. For example, if there is an element with id="play" on the page, you can link to lines 5-6 by linking to #play.5-6

Examples

- +

Line 2


-	
+
 	

Lines 15-25


-	
+
 	

Line 1 and lines 3-4 and line 42


-	
+
 	

Line 43, starting from line 41


-	
+
 	

Linking example

@@ -80,9 +80,9 @@

Line 43, starting from line 41

- + - + - \ No newline at end of file + diff --git a/plugins/line-numbers/index.html b/plugins/line-numbers/index.html index ac00d3c2d4..9091fa21f4 100644 --- a/plugins/line-numbers/index.html +++ b/plugins/line-numbers/index.html @@ -9,7 +9,7 @@ - + @@ -62,10 +62,10 @@

Soft wrap support

- + - + - \ No newline at end of file + diff --git a/plugins/normalize-whitespace/index.html b/plugins/normalize-whitespace/index.html index e1469de650..6cfa276aea 100644 --- a/plugins/normalize-whitespace/index.html +++ b/plugins/normalize-whitespace/index.html @@ -21,7 +21,7 @@ } - + @@ -172,9 +172,9 @@

Examples

- + - + diff --git a/plugins/previewers/index.html b/plugins/previewers/index.html index 55370a3314..d817d689c0 100644 --- a/plugins/previewers/index.html +++ b/plugins/previewers/index.html @@ -9,7 +9,7 @@ - + @@ -224,10 +224,10 @@

new Prism.plugins.Previewer(type, updater, - + - + - \ No newline at end of file + diff --git a/plugins/remove-initial-line-feed/index.html b/plugins/remove-initial-line-feed/index.html index 8eb942fa67..c914a67768 100644 --- a/plugins/remove-initial-line-feed/index.html +++ b/plugins/remove-initial-line-feed/index.html @@ -8,7 +8,7 @@ - + @@ -50,10 +50,10 @@

With the class added

- + - + - \ No newline at end of file + diff --git a/plugins/show-invisibles/index.html b/plugins/show-invisibles/index.html index cb0ad436a4..2079998cd6 100644 --- a/plugins/show-invisibles/index.html +++ b/plugins/show-invisibles/index.html @@ -9,7 +9,7 @@ - + @@ -25,11 +25,11 @@

Show Invisibles

Examples

- +

-	
+
 	

-	
+
 	

 
@@ -37,9 +37,9 @@

Examples

- + - + diff --git a/plugins/show-language/index.html b/plugins/show-language/index.html index e79b1ccf9f..5118501946 100644 --- a/plugins/show-language/index.html +++ b/plugins/show-language/index.html @@ -9,7 +9,7 @@ - + @@ -45,10 +45,10 @@

SVG

- + - + - \ No newline at end of file + diff --git a/plugins/toolbar/index.html b/plugins/toolbar/index.html index 5d8d63a1e7..fd908038cc 100644 --- a/plugins/toolbar/index.html +++ b/plugins/toolbar/index.html @@ -9,7 +9,7 @@ - + @@ -95,7 +95,7 @@

How to use

- + - + diff --git a/plugins/unescaped-markup/index.html b/plugins/unescaped-markup/index.html index 442ef2aa9f..3568e1c049 100644 --- a/plugins/unescaped-markup/index.html +++ b/plugins/unescaped-markup/index.html @@ -10,7 +10,7 @@ - + @@ -57,7 +57,7 @@

Examples

- @@ -119,7 +119,7 @@

FAQ

- + @@ -161,9 +161,9 @@

FAQ

- + - + -->

@@ -187,9 +187,9 @@

FAQ

- + - + diff --git a/plugins/wpd/index.html b/plugins/wpd/index.html index 9157a483f0..b0d4621dab 100644 --- a/plugins/wpd/index.html +++ b/plugins/wpd/index.html @@ -9,7 +9,7 @@ - + @@ -60,9 +60,9 @@

SVG

- + - + - \ No newline at end of file + diff --git a/code.js b/scripts/code.js similarity index 100% rename from code.js rename to scripts/code.js diff --git a/download.js b/scripts/download.js similarity index 100% rename from download.js rename to scripts/download.js diff --git a/examples.js b/scripts/examples.js similarity index 100% rename from examples.js rename to scripts/examples.js diff --git a/prefixfree.min.js b/scripts/prefixfree.min.js similarity index 100% rename from prefixfree.min.js rename to scripts/prefixfree.min.js diff --git a/utopia.js b/scripts/utopia.js similarity index 100% rename from utopia.js rename to scripts/utopia.js diff --git a/vendor/FileSaver.min.js b/scripts/vendor/FileSaver.min.js similarity index 100% rename from vendor/FileSaver.min.js rename to scripts/vendor/FileSaver.min.js diff --git a/vendor/jszip.min.js b/scripts/vendor/jszip.min.js similarity index 100% rename from vendor/jszip.min.js rename to scripts/vendor/jszip.min.js diff --git a/vendor/promise.js b/scripts/vendor/promise.js similarity index 100% rename from vendor/promise.js rename to scripts/vendor/promise.js diff --git a/test-suite.html b/test-suite.html index 936ed1aa68..97dd15e497 100644 --- a/test-suite.html +++ b/test-suite.html @@ -7,7 +7,7 @@ Running the test suite ▲ Prism - + @@ -159,11 +159,11 @@

Internal structure

+ - - + diff --git a/test.html b/test.html index 063a8ea172..55afc53878 100644 --- a/test.html +++ b/test.html @@ -92,7 +92,7 @@ } - + @@ -126,11 +126,11 @@

Test drive

+ - - - + +