Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.

Commit 776a3c0

Browse files
committed
Updating to v0.6.0 🎉
- Updating highlight-php - Adding `hljs` class to `pre` container by default (configurable) - Removing `kirby-pep` from README.md
1 parent 65e28b6 commit 776a3c0

File tree

443 files changed

+5379
-791
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

443 files changed

+5379
-791
lines changed

README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Activate the plugin with the following line in your `config.php`:
4343

4444
```text
4545
c::set('plugin.kirby-highlight', true);
46-
```
46+
```
4747

4848
Now proper classes are added to your code snippets, making them 'themeable'. In order to do so, head over to the [styling](#styling) section. If you want to activate `kirby-highlight` only on specific domains, read about [multi-environment setups](https://getkirby.com/docs/developer-guide/configuration/options).
4949

@@ -52,6 +52,7 @@ Change `kirby-highlight` options to suit your needs:
5252

5353
| Option | Type | Default | Description |
5454
| --- | --- | --- | --- |
55+
| `plugin.kirby-highlight.class` | String | `'hljs'` | Sets class of surrounding `pre` container. |
5556
| `plugin.kirby-highlight.languages` | Array | `['html', 'php']` | Defines languages to be auto-detected (currently 176 languages are supported). |
5657
| `plugin.kirby-highlight.escaping` | Boolean | `false` | Enables character escaping (converting `<` to `&lt;`, `>` to `&gt;`, ..), see `htmlspecialchars()` [docs](http://php.net/manual/en/function.htmlspecialchars.php). |
5758

@@ -62,13 +63,6 @@ All `highlight.js` styles are fully compatible with `kirby-highlight`. Just incl
6263
<?php echo css('assets/plugins/kirby-highlight/css/zenburn.css') ?>
6364
```
6465

65-
**Note: For most themes to work, the class `.hljs` needs to be added to the code's container!**
66-
67-
To resolve this, any of the following will do:
68-
- Simply use the [Kirby PEP](https://github.com/S1SYPHOS/kirby-pep) plugin and add the following line to your `config.php`: `c::set('plugin.kirby-pep.code_class', 'language-%s hljs');`
69-
- Replace `.hljs` with `[class^="language-"]` in the included stylesheet
70-
- Copy it to your `assets/css` directory and modify it
71-
- Include the styles in your own workflow
7266

7367
## Troubleshooting
7468
If in doubt, check the [correct spelling](https://github.com/S1SYPHOS/kirby-highlight/tree/master/vendor/scrivo/highlight.php/Highlight/languages) of the language in question - doing otherwise breaks `kirbytext()` (see [#2](https://github.com/S1SYPHOS/kirby-highlight/issues/2)).

core/syntax_highlight.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,33 @@
77
use c;
88

99
kirbytext::$post[] = function ($kirbytext, $value) {
10+
/*
11+
* I. Adding `hljs` class to all `pre` elements
12+
*/
13+
14+
// Converting kirbytext to an HTML document
15+
// See https://secure.php.net/manual/en/class.domdocument.php
16+
$html = new DOMDocument();
17+
$html->loadHTML($text, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
18+
19+
// Retrieving all `pre` elements inside our newly created HTML document
20+
// See https://secure.php.net/manual/en/class.domxpath.php & https://en.wikipedia.org/wiki/XPath
21+
$query = new DOMXPath($html);
22+
$elements = $query->evaluate('//pre');
23+
24+
// Looping through all `pre` elements, adding the class name
25+
foreach ($elements as $element) {
26+
$element->setAttribute('class', c::get('plugin.kirby-highlight.class', 'hljs'));
27+
}
28+
29+
// Saving all changes
30+
$text = $html->saveHTML();
31+
32+
33+
/*
34+
* II. Highlighting everything between <code> and </code>
35+
*/
36+
1037
// Pattern to be matched when parsing kirbytext() (everything between <code> and </code>)
1138
$pattern = '~<code[^>]*>\K.*(?=</code>)~Uis';
1239

kirby-highlight.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @package Kirby CMS
77
* @author S1SYPHOS <hello@twobrain.io>
88
* @link http://twobrain.io
9-
* @version 0.5.0
9+
* @version 0.6.0
1010
* @license MIT
1111
*/
1212

@@ -17,3 +17,4 @@
1717
// Loading settings & core
1818
require_once __DIR__ . DS . 'core' . DS . 'syntax_highlight.php';
1919
}
20+

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "kirby-highlight",
33
"description": "Themeable server-side syntax highlighting for Kirby",
44
"author": "S1SYPHOS <hello@twobrain.io>",
5-
"version": "0.5.0",
5+
"version": "0.6.0",
66
"type": "kirby-plugin",
77
"license": "MIT"
88
}

vendor/composer/ClassLoader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public function isClassMapAuthoritative()
279279
*/
280280
public function setApcuPrefix($apcuPrefix)
281281
{
282-
$this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
282+
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
283283
}
284284

285285
/**
@@ -377,11 +377,11 @@ private function findFileWithExtension($class, $ext)
377377
$subPath = $class;
378378
while (false !== $lastPos = strrpos($subPath, '\\')) {
379379
$subPath = substr($subPath, 0, $lastPos);
380-
$search = $subPath.'\\';
380+
$search = $subPath . '\\';
381381
if (isset($this->prefixDirsPsr4[$search])) {
382+
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
382383
foreach ($this->prefixDirsPsr4[$search] as $dir) {
383-
$length = $this->prefixLengthsPsr4[$first][$search];
384-
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
384+
if (file_exists($file = $dir . $pathEnd)) {
385385
return $file;
386386
}
387387
}

vendor/composer/installed.json

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
[
22
{
33
"name": "scrivo/highlight.php",
4-
"version": "v9.12.0.1",
5-
"version_normalized": "9.12.0.1",
4+
"version": "v9.15.6.0",
5+
"version_normalized": "9.15.6.0",
66
"source": {
77
"type": "git",
88
"url": "https://github.com/scrivo/highlight.php.git",
9-
"reference": "a4930dde24bf6b9064fb52c22d71211144567e7f"
9+
"reference": "5b5fc5eddb43845036f65e47f8d157ce5754511f"
1010
},
1111
"dist": {
1212
"type": "zip",
13-
"url": "https://api.github.com/repos/scrivo/highlight.php/zipball/a4930dde24bf6b9064fb52c22d71211144567e7f",
14-
"reference": "a4930dde24bf6b9064fb52c22d71211144567e7f",
13+
"url": "https://api.github.com/repos/scrivo/highlight.php/zipball/5b5fc5eddb43845036f65e47f8d157ce5754511f",
14+
"reference": "5b5fc5eddb43845036f65e47f8d157ce5754511f",
1515
"shasum": ""
1616
},
17+
"require": {
18+
"ext-json": "*",
19+
"ext-mbstring": "*"
20+
},
1721
"require-dev": {
18-
"phpunit/phpunit": "^4.8",
22+
"phpunit/phpunit": "^4.8|^5.7",
1923
"symfony/finder": "^2.8"
2024
},
21-
"time": "2017-12-24T23:01:41+00:00",
25+
"time": "2019-03-06T07:43:42+00:00",
2226
"type": "library",
2327
"installation-source": "dist",
2428
"autoload": {
@@ -47,7 +51,7 @@
4751
"role": "Contributor"
4852
}
4953
],
50-
"description": "Server side syntax highlighter that supports 176 languages. It's a PHP port of highlight.js",
54+
"description": "Server side syntax highlighter that supports 185 languages. It's a PHP port of highlight.js",
5155
"keywords": [
5256
"code",
5357
"highlight",
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# http://EditorConfig.org
2+
3+
root = true
4+
5+
[*]
6+
end_of_line = lf
7+
charset = utf-8
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
indent_style = space
11+
indent_size = 4
12+
13+
[*.md]
14+
trim_trailing_whitespace = false
15+
16+
[*.crlf.*]
17+
end_of_line = crlf
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
* text=auto
2+
3+
*.crlf.* eol=crlf
4+
5+
styles/* linguist-vendored
6+
test/**/*.txt linguist-vendored

vendor/scrivo/highlight.php/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ lib_highlight/
55
*.tar.gz
66
vendor/
77
composer.lock
8+
test/**/*.js
9+
.php_cs.cache
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in('demo')
5+
->in('Highlight')
6+
->in('test')
7+
;
8+
9+
return PhpCsFixer\Config::create()
10+
->setRules([
11+
'@PSR1' => true,
12+
'@PSR2' => true,
13+
'@Symfony' => true,
14+
'array_syntax' => ['syntax' => 'long'],
15+
'concat_space' => ['spacing' => 'one'],
16+
'no_useless_else' => true,
17+
'no_useless_return' => true,
18+
'phpdoc_align'=> true,
19+
'phpdoc_order' => true,
20+
'phpdoc_trim_consecutive_blank_line_separation' => true,
21+
'single_quote' => false,
22+
'ternary_to_null_coalescing' => true,
23+
'trailing_comma_in_multiline_array' => true,
24+
'yoda_style' => [
25+
'equal' => false,
26+
'identical' => false,
27+
],
28+
])
29+
->setFinder($finder)
30+
;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
language: php
2+
php:
3+
- nightly
4+
- 7.3
5+
- 7.2
6+
- 7.1
7+
- 7.0
8+
- 5.6
9+
- 5.5
10+
- 5.4
11+
12+
matrix:
13+
fast_finish: true
14+
allow_failures:
15+
# Since PHP 8.0.0-dev is the new nightly, some dependencies don't support
16+
# it in their Composer files
17+
- php: nightly
18+
19+
install:
20+
- composer install --no-interaction --no-progress
21+
22+
script:
23+
- composer test
24+
25+
notifications:
26+
email: false
27+
webhooks:
28+
- http://helit.org:8093/+sujevo-dev/showSuccessfulBuildMessages=always
29+
30+
jobs:
31+
include:
32+
- stage: checks
33+
php:
34+
- 7.2
35+
script:
36+
bash .travis/hasGitChanges.sh
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
curl -L https://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -o php-cs-fixer
4+
5+
chmod +x php-cs-fixer
6+
7+
./php-cs-fixer fix
8+
9+
if ! git diff-index --quiet HEAD --; then
10+
git --no-pager diff
11+
exit 1
12+
fi

0 commit comments

Comments
 (0)