You are here

README.txt in Syntax Highlighter 8

Same filename and directory in other branches
  1. 6.2 README.txt
  2. 6 README.txt
  3. 7.2 README.txt
  4. 7 README.txt
INSTALLATION
------------

Step 1) Download the latest SyntaxHighlighter Javascript library from
http://alexgorbatchev.com/SyntaxHighlighter/, extract the contents, rename the
directory to "syntaxhighlighter" and place the entire directory in any of the
locations supported by the libraries module, relative to the web site root,
e.g.:

  -  libraries
       Recommended. This is Drupal 8 standard location for third party
       libraries.

  -  sites/[sitename]/libraries
       Recommended if this library is to be site specific.

  -  profiles/[profilename]/libraries
       Recommended if this library is to be profile specific.

  -  Inside the syntaxhighlighter module directory
       This is not recommended. It's only for backward compatibility.


After the installation, there should be something like this:

  libraries/syntaxhighlighter/...

so that shCore.js is located at:

  libraries/syntaxhighlighter/scripts/shCore.js

Note: To use the toolbar with options to view source and the flash-based copy
to clipboard, the older 2.x version needs to be used

See http://alexgorbatchev.com/SyntaxHighlighter/ for details.

WARNING! The library location is determined by file scan. This scan is
performed only once and the location is cached. If the library location is
changed for any reason (such as after upgrading the js lib) the cache must be
invalidated in some way (drush, drupal-console, etc.).


AUTOMATIC INSTALLATION
----------------------

The SyntaxHighlighter Javascript library can be installed automatically with
composer by setting up a repository for it in the main composer.json of the
web project.

Here follows an example of usage with drupal-composer/drupal-project: the
"syntaxhighlighter/syntaxhighlighter" repository would go in the main
composer.json, where also the "drupal/syntaxhighlighter" dependency will be
specified, like this:

diff --git a/composer.json b/composer.json
index 28023b4..3a6bab2 100644
--- a/composer.json
+++ b/composer.json
@@ -13,6 +13,25 @@
         {
             "type": "composer",
             "url": "https://packages.drupal.org/8"
+        },
+        {
+            "type": "package",
+            "package": {
+                "name": "syntaxhighlighter/syntaxhighlighter",
+                "description": "...",
+                "type": "drupal-library",
...
+            }
         }
     ],
     "require": {
@@ -21,6 +40,7 @@
         "drupal-composer/drupal-scaffold": "^2.2",
         "drupal/console": "~1.0",
         "drupal/core": "~8.0",
+        "drupal/syntaxhighlighter": "*",
         "drush/drush": "~8.0",
         "webflo/drupal-finder": "^0.3.0",
         "webmozart/path-util": "^2.3"


Setting "type": "drupal-library" for the "syntaxhighlighter/syntaxhighlighter"
project makes sure that the latter is installed in the global libraries path,
i.e. the one specified in "installer-paths" when using "composer/installers".

See the composer.json file in the syntaxhighlighter module directory for the
full code for the repository.


SETUP
-----

Enable the syntaxhighlighter module.

Then enable the Syntax Highlighter filter in the text formats where
highlighting code using the syntaxhighlighter library is allowed.

It is not necessary to enable the Syntax Highlighter filter in any text format
that does not do HTML filtering (e.g. Full HTML).

IMPORTANT! If some HTML filtering is performed, like in the "Restricted HTML"
text format, place the filters in the following relative ordering positions:

+ Limit allowed HTML tags (or whatever HTML filter is used)
+ Syntax Highlighter
+ Convert line breaks into HTML (i.e. <br> and <p>)
+ ...


CONFIGURATION
-------------

Go to admin/config/content/syntaxhighlighter to configure the module settings.


USAGE
-----

Mark up code with as specified in http://alexgorbatchev.com/SyntaxHighlighter/

NOTE: make sure the markup is proper HTML. This means that if the code
contains any HTML tags or entities, they need to be escaped; some examples:
  - change the '<' character to '&lt;' (e.g. <script> to &lt;script>);
  - convert '&' in any HTML entity to '&amp;' (e.g. &gt; to &amp;gt;).


About AJAX Usage
----------------

On Ajax update, call Drupal.attachBehaviors(context) where context
is the element that has been updated.

Known problem:

Autoloader and Ajax will not work if the brush is not already used on the page
when the page is first loaded. For example: if on the page, there is no 'cpp'
code block, and there is an Ajax update on some 'cpp' code block, then
a "brush not found" error will be returned.

When Ajax is needed, it's probably better not to use the autoloader.

File

README.txt
View source
  1. INSTALLATION
  2. ------------
  3. Step 1) Download the latest SyntaxHighlighter Javascript library from
  4. http://alexgorbatchev.com/SyntaxHighlighter/, extract the contents, rename the
  5. directory to "syntaxhighlighter" and place the entire directory in any of the
  6. locations supported by the libraries module, relative to the web site root,
  7. e.g.:
  8. - libraries
  9. Recommended. This is Drupal 8 standard location for third party
  10. libraries.
  11. - sites/[sitename]/libraries
  12. Recommended if this library is to be site specific.
  13. - profiles/[profilename]/libraries
  14. Recommended if this library is to be profile specific.
  15. - Inside the syntaxhighlighter module directory
  16. This is not recommended. It's only for backward compatibility.
  17. After the installation, there should be something like this:
  18. libraries/syntaxhighlighter/...
  19. so that shCore.js is located at:
  20. libraries/syntaxhighlighter/scripts/shCore.js
  21. Note: To use the toolbar with options to view source and the flash-based copy
  22. to clipboard, the older 2.x version needs to be used
  23. See http://alexgorbatchev.com/SyntaxHighlighter/ for details.
  24. WARNING! The library location is determined by file scan. This scan is
  25. performed only once and the location is cached. If the library location is
  26. changed for any reason (such as after upgrading the js lib) the cache must be
  27. invalidated in some way (drush, drupal-console, etc.).
  28. AUTOMATIC INSTALLATION
  29. ----------------------
  30. The SyntaxHighlighter Javascript library can be installed automatically with
  31. composer by setting up a repository for it in the main composer.json of the
  32. web project.
  33. Here follows an example of usage with drupal-composer/drupal-project: the
  34. "syntaxhighlighter/syntaxhighlighter" repository would go in the main
  35. composer.json, where also the "drupal/syntaxhighlighter" dependency will be
  36. specified, like this:
  37. diff --git a/composer.json b/composer.json
  38. index 28023b4..3a6bab2 100644
  39. --- a/composer.json
  40. +++ b/composer.json
  41. @@ -13,6 +13,25 @@
  42. {
  43. "type": "composer",
  44. "url": "https://packages.drupal.org/8"
  45. + },
  46. + {
  47. + "type": "package",
  48. + "package": {
  49. + "name": "syntaxhighlighter/syntaxhighlighter",
  50. + "description": "...",
  51. + "type": "drupal-library",
  52. ...
  53. + }
  54. }
  55. ],
  56. "require": {
  57. @@ -21,6 +40,7 @@
  58. "drupal-composer/drupal-scaffold": "^2.2",
  59. "drupal/console": "~1.0",
  60. "drupal/core": "~8.0",
  61. + "drupal/syntaxhighlighter": "*",
  62. "drush/drush": "~8.0",
  63. "webflo/drupal-finder": "^0.3.0",
  64. "webmozart/path-util": "^2.3"
  65. Setting "type": "drupal-library" for the "syntaxhighlighter/syntaxhighlighter"
  66. project makes sure that the latter is installed in the global libraries path,
  67. i.e. the one specified in "installer-paths" when using "composer/installers".
  68. See the composer.json file in the syntaxhighlighter module directory for the
  69. full code for the repository.
  70. SETUP
  71. -----
  72. Enable the syntaxhighlighter module.
  73. Then enable the Syntax Highlighter filter in the text formats where
  74. highlighting code using the syntaxhighlighter library is allowed.
  75. It is not necessary to enable the Syntax Highlighter filter in any text format
  76. that does not do HTML filtering (e.g. Full HTML).
  77. IMPORTANT! If some HTML filtering is performed, like in the "Restricted HTML"
  78. text format, place the filters in the following relative ordering positions:
  79. + Limit allowed HTML tags (or whatever HTML filter is used)
  80. + Syntax Highlighter
  81. + Convert line breaks into HTML (i.e.
    and

    )

  82. + ...
  83. CONFIGURATION
  84. -------------
  85. Go to admin/config/content/syntaxhighlighter to configure the module settings.
  86. USAGE
  87. -----
  88. Mark up code with as specified in http://alexgorbatchev.com/SyntaxHighlighter/
  89. NOTE: make sure the markup is proper HTML. This means that if the code
  90. contains any HTML tags or entities, they need to be escaped; some examples:
  91. - change the '<' character to '<' (e.g.