├── .distignore ├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .github ├── dependabot.yml ├── release.yml └── workflows │ └── ci.yaml ├── .gitignore ├── .husky └── pre-commit ├── .lintstagedrc.js ├── .nvmrc ├── .phpcs.xml.dist ├── .prettierrc ├── .wordpress-org ├── banner-1544x500.png ├── banner-772x250.png ├── icon-128x128.png ├── icon-256x256.png ├── icon.svg ├── screenshot-1.png └── screenshot-2.png ├── .wp-env.json ├── Gruntfile.js ├── LICENSE ├── README.md ├── bin ├── build-dist.sh ├── generate-language-names.php ├── phpcbf.sh ├── symlink-wp-env-install-paths.sh ├── transform-readme.php ├── update-highlight-libs.sh └── verify-version-consistency.php ├── block-library.md5 ├── composer.json ├── composer.lock ├── editor-styles.css ├── inc └── functions.php ├── language-names.php ├── package-lock.json ├── package.json ├── phpstan.neon.dist ├── src ├── customize-controls.js ├── edit.js └── index.js ├── style.css ├── syntax-highlighting-code-block.php ├── tests └── phpstan │ └── HighlightAutoloader.stub └── uninstall.php /.distignore: -------------------------------------------------------------------------------- 1 | .distignore 2 | .editorconfig 3 | .eslintignore 4 | .eslintrc.js 5 | .github 6 | .gitignore 7 | .husky 8 | .lintstagedrc.js 9 | .nvmrc 10 | .phpcs.xml.dist 11 | .prettierrc 12 | .wordpress-org 13 | .wp-env.json 14 | Gruntfile.js 15 | README.md 16 | bin 17 | block-library.md5 18 | composer.json 19 | composer.lock 20 | node_modules 21 | package-lock.json 22 | package.json 23 | phpstan.neon.dist 24 | src 25 | tests 26 | *.zip 27 | vendor/scrivo/highlight-php/.php-cs-fixer.dist.php 28 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # WordPress Coding Standards 2 | # https://make.wordpress.org/core/handbook/coding-standards/ 3 | 4 | root = true 5 | 6 | [*] 7 | charset = utf-8 8 | end_of_line = lf 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | indent_style = tab 12 | tab_width = 4 13 | 14 | [{.babelrc,.eslintrc,.rtlcssrc,*.json,*.yml,*.yaml}] 15 | indent_style = space 16 | indent_size = 2 17 | 18 | [*.md] 19 | trim_trailing_whitespace = false 20 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | */* 2 | !src/* 3 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: ['plugin:@wordpress/eslint-plugin/recommended'], 4 | settings: { 5 | react: { 6 | pragma: 'wp', 7 | version: 'detect', 8 | }, 9 | }, 10 | env: { 11 | browser: true, 12 | }, 13 | rules: { 14 | '@wordpress/i18n-text-domain': [ 15 | 'error', 16 | { 17 | allowedTextDomain: [ 18 | 'syntax-highlighting-code-block', 19 | 'default', 20 | ], 21 | }, 22 | ], 23 | '@wordpress/i18n-hyphenated-range': ['off'], 24 | }, 25 | }; 26 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: weekly 7 | time: "12:00" 8 | timezone: America/Los_Angeles 9 | open-pull-requests-limit: 10 10 | groups: 11 | wordpress-packages: 12 | patterns: 13 | - "@wordpress/*" 14 | 15 | - package-ecosystem: composer 16 | directory: "/" 17 | schedule: 18 | interval: weekly 19 | time: "12:00" 20 | timezone: America/Los_Angeles 21 | open-pull-requests-limit: 10 22 | 23 | - package-ecosystem: github-actions 24 | directory: "/" 25 | schedule: 26 | interval: weekly 27 | time: "12:00" 28 | timezone: America/Los_Angeles 29 | open-pull-requests-limit: 10 30 | -------------------------------------------------------------------------------- /.github/release.yml: -------------------------------------------------------------------------------- 1 | changelog: 2 | exclude: 3 | authors: 4 | - dependabot 5 | - dependabot-preview 6 | -------------------------------------------------------------------------------- /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | name: Continuous Integration 2 | on: 3 | pull_request: 4 | push: 5 | branches: 6 | - develop 7 | - "*.*" 8 | 9 | # Cancel previous workflow run groups that have not completed. 10 | concurrency: 11 | # Group workflow runs by workflow name, along with the head branch ref of the pull request 12 | # or otherwise the branch or tag ref. 13 | group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }} 14 | cancel-in-progress: true 15 | 16 | jobs: 17 | 18 | lint-css: 19 | name: 'Lint and Analyze' 20 | runs-on: ubuntu-latest 21 | steps: 22 | - name: Checkout 23 | uses: actions/checkout@v4 24 | 25 | - name: Setup Node 26 | uses: actions/setup-node@v4.4.0 27 | with: 28 | node-version-file: '.nvmrc' 29 | cache: npm 30 | 31 | - name: Install Node dependencies 32 | run: npm ci 33 | env: 34 | CI: true 35 | 36 | - name: Validate package.json 37 | run: npm run lint:pkg-json 38 | 39 | - name: Check @wordpress/block-library checksum 40 | run: npm run md5sum:check 41 | 42 | - name: Detect coding standard violations (stylelint) 43 | run: npm run lint:css 44 | 45 | - name: Detect ESLint coding standard violations 46 | if: > 47 | github.event.pull_request.head.repo.fork == true || 48 | github.event.pull_request.user.login == 'dependabot[bot]' 49 | run: npm run lint:js 50 | 51 | - name: Generate ESLint coding standard violations report 52 | # Prevent generating the ESLint report if PR is from a fork or authored by Dependabot. 53 | if: > 54 | ! ( github.event.pull_request.head.repo.fork == true || 55 | github.event.pull_request.user.login == 'dependabot[bot]' ) 56 | run: npm run lint:js:report 57 | continue-on-error: true 58 | 59 | - name: Annotate code linting results 60 | # The action cannot annotate the PR when run from a PR fork or was authored by Dependabot. 61 | if: > 62 | ! ( github.event.pull_request.head.repo.fork == true || 63 | github.event.pull_request.user.login == 'dependabot[bot]' ) 64 | uses: ataylorme/eslint-annotate-action@3.0.0 65 | with: 66 | repo-token: '${{ secrets.GITHUB_TOKEN }}' 67 | report-json: 'lint-js-report.json' 68 | 69 | - name: Setup PHP 70 | uses: shivammathur/setup-php@v2 71 | with: 72 | php-version: '8.1' 73 | extensions: dom, iconv, json, libxml, zip 74 | coverage: none 75 | tools: phpstan, cs2pr 76 | 77 | - name: Get Composer Cache Directory 78 | id: composer-cache 79 | run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT 80 | 81 | - name: Configure Composer cache 82 | uses: actions/cache@v4.2.3 83 | with: 84 | path: ${{ steps.composer-cache.outputs.dir }} 85 | key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} 86 | restore-keys: | 87 | ${{ runner.os }}-composer- 88 | - name: Install Composer dependencies 89 | run: composer install --prefer-dist --optimize-autoloader --no-progress --no-interaction 90 | 91 | - name: Validate composer.json 92 | run: composer --no-interaction validate --no-check-all 93 | 94 | - name: Detect coding standard violations (PHPCS) 95 | run: vendor/bin/phpcs -q --report=checkstyle --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 | cs2pr --graceful-warnings 96 | 97 | - name: Normalize composer.json 98 | run: composer --no-interaction normalize --dry-run 99 | 100 | - name: Static Analysis (PHPStan) 101 | run: | 102 | phpstan --version 103 | phpstan analyse 104 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.log 3 | *.zip 4 | /build 5 | /vendor 6 | /node_modules 7 | 8 | # Directories used in the dist/deploy process. 9 | /dist 10 | /syntax-highlighting-code-block 11 | 12 | # Generated via bin/transform-readme.php 13 | /readme.txt 14 | 15 | # In case the GitHub Wiki repo is cloned. 16 | /wiki 17 | 18 | # IDE files 19 | .idea 20 | .vscode 21 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | npx lint-staged 2 | -------------------------------------------------------------------------------- /.lintstagedrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "composer.*": [ 3 | () => "composer --no-interaction validate --no-check-all", 4 | () => "npm run lint:composer" 5 | ], 6 | "package.json": [ 7 | "npm run lint:pkg-json" 8 | ], 9 | "**/*.js": [ 10 | "npm run lint:js" 11 | ], 12 | "**/*.php": [ 13 | "npm run lint:php", 14 | () => 'npm run lint:phpstan' 15 | ] 16 | }; 17 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 20 2 | -------------------------------------------------------------------------------- /.phpcs.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | syntax-highlighting-code-block.php 33 | uninstall.php 34 | inc/ 35 | 36 | */node_modules/* 37 | */vendor/* 38 | */dist/* 39 | */bin/* 40 | phpstan-baseline.php 41 | 42 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | "@wordpress/prettier-config" -------------------------------------------------------------------------------- /.wordpress-org/banner-1544x500.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/westonruter/syntax-highlighting-code-block/2cdcde9db616816fd4a949b7566d1c689581b6c6/.wordpress-org/banner-1544x500.png -------------------------------------------------------------------------------- /.wordpress-org/banner-772x250.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/westonruter/syntax-highlighting-code-block/2cdcde9db616816fd4a949b7566d1c689581b6c6/.wordpress-org/banner-772x250.png -------------------------------------------------------------------------------- /.wordpress-org/icon-128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/westonruter/syntax-highlighting-code-block/2cdcde9db616816fd4a949b7566d1c689581b6c6/.wordpress-org/icon-128x128.png -------------------------------------------------------------------------------- /.wordpress-org/icon-256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/westonruter/syntax-highlighting-code-block/2cdcde9db616816fd4a949b7566d1c689581b6c6/.wordpress-org/icon-256x256.png -------------------------------------------------------------------------------- /.wordpress-org/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.wordpress-org/screenshot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/westonruter/syntax-highlighting-code-block/2cdcde9db616816fd4a949b7566d1c689581b6c6/.wordpress-org/screenshot-1.png -------------------------------------------------------------------------------- /.wordpress-org/screenshot-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/westonruter/syntax-highlighting-code-block/2cdcde9db616816fd4a949b7566d1c689581b6c6/.wordpress-org/screenshot-2.png -------------------------------------------------------------------------------- /.wp-env.json: -------------------------------------------------------------------------------- 1 | { 2 | "core": null, 3 | "plugins": [ 4 | ".", 5 | "https://downloads.wordpress.org/plugin/gutenberg.zip" 6 | ], 7 | "config": { 8 | "WP_DEBUG_LOG": true 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | /* eslint-disable camelcase, no-console, no-param-reassign */ 3 | 4 | module.exports = function (grunt) { 5 | 'use strict'; 6 | 7 | grunt.initConfig({ 8 | pkg: grunt.file.readJSON('package.json'), 9 | 10 | // Deploys a git Repo to the WordPress SVN repo. 11 | wp_deploy: { 12 | deploy: { 13 | options: { 14 | plugin_slug: 'syntax-highlighting-code-block', 15 | build_dir: 'syntax-highlighting-code-block', 16 | assets_dir: '.wordpress-org', 17 | }, 18 | }, 19 | }, 20 | }); 21 | 22 | // Load tasks. 23 | grunt.loadNpmTasks('grunt-wp-deploy'); 24 | 25 | // Register tasks. 26 | grunt.registerTask('default', ['wp_deploy']); 27 | }; 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | 341 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Syntax-highlighting Code Block (with Server-side Rendering) 2 | 3 | ![Banner](.wordpress-org/banner-1544x500.png) 4 | 5 | Extending the Code block with syntax highlighting rendered on the server, thus being AMP-compatible and having faster frontend performance. 6 | 7 | **Contributors:** [westonruter](https://profiles.wordpress.org/westonruter), [allejo](https://profiles.wordpress.org/allejo) 8 | **Tags:** [block](https://wordpress.org/plugins/tags/block), [code](https://wordpress.org/plugins/tags/code), [code syntax](https://wordpress.org/plugins/tags/code-syntax), [syntax highlight](https://wordpress.org/plugins/tags/syntax-highlight), [code highlighting](https://wordpress.org/plugins/tags/code-highlighting) 9 | **Tested up to:** 6.7 10 | **Stable tag:** 1.5.1 11 | **License:** [GPLv2 or later](http://www.gnu.org/licenses/gpl-2.0.html) 12 | 13 | [![Continuous Integration](https://github.com/westonruter/syntax-highlighting-code-block/actions/workflows/ci.yaml/badge.svg)](https://github.com/westonruter/syntax-highlighting-code-block/actions/workflows/ci.yaml) 14 | [![Built with Grunt](https://gruntjs.com/cdn/builtwith.svg)](http://gruntjs.com) 15 | 16 | ## Description 17 | 18 | This plugin extends the Code block in WordPress core to add syntax highlighting which is rendered on the server. Pre-existing Code blocks on a site are automatically extended to include syntax highlighting. Doing server-side syntax highlighting eliminates the need to enqueue any JavaScript on the frontend (e.g. Highlight.js or Prism.js) and this ensures there is no flash of unhighlighted code (FOUC?). Reducing script on the frontend improves frontend performance, and it also allows for the syntax highlighted code to appear properly in AMP pages as rendered by the [official AMP plugin](https://amp-wp.org) (see also [ampproject/amp-wp#972](https://github.com/ampproject/amp-wp/issues/972)) or when JavaScript is turned off in the browser. 19 | 20 | This extended Code block uses language auto-detection to add syntax highlighting, but you can override the language in the block's settings sidebar. (There is currently no syntax highlighting of the Code block in the editor, but see [#8](https://github.com/westonruter/syntax-highlighting-code-block/issues/8).) The plugin supports all [programming languages](https://highlightjs.org/static/demo/) that [highlight.php](https://github.com/scrivo/highlight.php) supports (being a port of [highlight.js](https://highlightjs.org/)). The Code block also is extended to support specifying lines to highlight which get marked up with `mark` elements (including in RSS feeds). There is also a checkbox for whether to show line numbers on the frontend (with the numbers being non-selectable). Lastly, given inconsistencies across themes regarding whether lines in a Code block should be wrapped, this plugin adds styling to force them to no-wrap by default, with a checkbox to opt in to wrapping when desired. 21 | 22 | For advanced usage, please see the [plugin wiki](https://github.com/westonruter/syntax-highlighting-code-block/wiki). 23 | 24 | This plugin is [developed on GitHub](https://github.com/westonruter/syntax-highlighting-code-block). See [list of current issues](https://github.com/westonruter/syntax-highlighting-code-block/issues) with the plugin. Please feel free to file any additional issues or requests that you may come across. [Pull requests](https://github.com/westonruter/syntax-highlighting-code-block/pulls) are welcome. See [contributing information](https://github.com/westonruter/syntax-highlighting-code-block/wiki/Contributing). 25 | 26 | ### Credits 27 | 28 | This is a fork of [Code Syntax Block](https://github.com/mkaz/code-syntax-block) by [Marcus Kazmierczak](https://mkaz.blog/) (mkaz), which is also [available on WordPress.org](https://wordpress.org/plugins/code-syntax-block/). Copyright (c) 2018 Marcus Kazmierczak. Licensed under GPL 2.0 or later. 29 | 30 | [highlight.php](https://github.com/scrivo/highlight.php) is released under the BSD 3-Clause License. Copyright © 2006-2013, Ivan Sagalaev (maniac@softwaremaniacs.org), highlight.js (original author). Copyright © 2013, Geert Bergman (geert@scrivo.nl), highlight.php 31 | 32 | ## Screenshots 33 | 34 | ### Code blocks can be added as normal, optionally overriding the auto-detected language. Also specify any lines to be highlighted, whether to show line numbers, and if the lines should wrap. 35 | 36 | ![Code blocks can be added as normal, optionally overriding the auto-detected language. Also specify any lines to be highlighted, whether to show line numbers, and if the lines should wrap.](.wordpress-org/screenshot-1.png) 37 | 38 | ### The Code block renders with syntax highlighting on the frontend without any JavaScript enqueued. Stylesheets are added only when block is on the page. 39 | 40 | ![The Code block renders with syntax highlighting on the frontend without any JavaScript enqueued. Stylesheets are added only when block is on the page.](.wordpress-org/screenshot-2.png) 41 | 42 | ## Changelog 43 | 44 | For the plugin’s changelog, please see [the Releases page on GitHub](https://github.com/westonruter/syntax-highlighting-code-block/releases). 45 | 46 | -------------------------------------------------------------------------------- /bin/build-dist.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | cd $(dirname $0)/.. 5 | 6 | if [ ! -e dist ]; then 7 | mkdir dist 8 | fi 9 | 10 | echo "Exporting repo to dist directory" 11 | git archive --format=tar HEAD | (cd dist/ && tar xf -) 12 | 13 | cd dist 14 | 15 | # Symlink node_modules rather than installing anew if possible. 16 | if [ -e ../node_modules ]; then 17 | ln -s ../node_modules node_modules 18 | else 19 | npm install 20 | fi 21 | 22 | # Install composer dependencies with optimized autoloader and excluding dev-dependencies. 23 | composer install --no-dev --classmap-authoritative --optimize-autoloader 24 | 25 | # Since the "highlight.php" directory name can trip up some systems, rename to "highlight-php". 26 | mv vendor/scrivo/highlight{.php,-php} 27 | find vendor/autoload.php vendor/composer -type f -print0 | xargs -0 sed -i "s:/highlight\.php/:/highlight-php/:g" 28 | sed -i "s/const DEVELOPMENT_MODE = true;.*/const DEVELOPMENT_MODE = false;/g" syntax-highlighting-code-block.php 29 | 30 | # Build the JS. 31 | npm run build:js 32 | 33 | # Convert markdown README. 34 | npm run build:transform-readme 35 | 36 | # Grab amend the version with the commit hash. 37 | VERSION=$(grep 'PLUGIN_VERSION' syntax-highlighting-code-block.php | cut -d\' -f2) 38 | if [[ $VERSION == *-* ]]; then 39 | NEW_VERSION="$VERSION-$(date -u +%Y%m%dT%H%M%SZ)-$(git --no-pager log -1 --format=%h --date=short)" 40 | VERSION_ESCAPED="${VERSION//./\\.}" 41 | sed -i "s/$VERSION_ESCAPED/$NEW_VERSION/g" syntax-highlighting-code-block.php 42 | echo "Detected non-stable version: $VERSION" 43 | echo "Creating build for version: $NEW_VERSION" 44 | fi 45 | -------------------------------------------------------------------------------- /bin/generate-language-names.php: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | $name ) { 32 | $php .= sprintf( 33 | "\t%s => __( %s, 'syntax-highlighting-code-block' ),\n", 34 | var_export( $slug, true ), 35 | var_export( $name, true ) 36 | ); 37 | } 38 | $php .= "];\n"; 39 | 40 | if ( ! file_put_contents( $output_file_php, $php ) ) { 41 | echo "Unable to write to $output_file_php\n"; 42 | exit( 1 ); 43 | } 44 | 45 | echo "Done. Wrote to $output_file_php.\n"; 46 | -------------------------------------------------------------------------------- /bin/phpcbf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Wrap phpcbf to turn 1 success exit code into 0 code. 3 | # See https://github.com/squizlabs/PHP_CodeSniffer/issues/1818#issuecomment-354420927 4 | 5 | composer exec phpcbf $@ 6 | exit=$? 7 | 8 | # Exit code 1 is used to indicate that all fixable errors were fixed correctly. 9 | if [[ $exit == 1 ]]; then 10 | exit=0 11 | fi 12 | 13 | exit $exit 14 | -------------------------------------------------------------------------------- /bin/symlink-wp-env-install-paths.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | install_path=$( npm run wp-env install-path 2>/dev/null | tail -n1) 4 | if [[ -z "$install_path" ]]; then 5 | echo "Error: Unable to get install-path. Make sure you first did npm run wp-env start." 6 | exit 1 7 | fi 8 | 9 | mkdir -p vendor/wp-env 10 | 11 | core_dir="vendor/wp-env/wp-core" 12 | if [[ -e "$core_dir" ]]; then 13 | rm "$core_dir" 14 | fi 15 | ln -s "$install_path/WordPress" "$core_dir" 16 | echo "Created $core_dir symlink" 17 | 18 | tests_dir="vendor/wp-env/wp-tests-phpunit" 19 | if [[ -e "$tests_dir" ]]; then 20 | rm "$tests_dir" 21 | fi 22 | ln -s "$install_path/WordPress-PHPUnit/tests/phpunit" "$tests_dir" 23 | echo "Created $tests_dir symlink" 24 | -------------------------------------------------------------------------------- /bin/transform-readme.php: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | 150 ) { 37 | fwrite( STDERR, "The short description is too long: $description\n" ); 38 | exit( __LINE__ ); 39 | } 40 | 41 | $metadata = []; 42 | foreach ( explode( "\n", $parts[2] ) as $meta ) { 43 | $meta = trim( $meta ); 44 | if ( ! preg_match( '/^\*\*(?P.+?):\*\* (?P.+)/', $meta, $matches ) ) { 45 | fwrite( STDERR, "Parse error for meta line: $meta.\n" ); 46 | exit( __LINE__ ); 47 | } 48 | 49 | $unlinked_value = preg_replace( '/\[(.+?)]\(.+?\)/', '$1', $matches['value'] ); 50 | 51 | $metadata[ $matches['key'] ] = $unlinked_value; 52 | 53 | // Extract License URI from link. 54 | if ( 'License' === $matches['key'] ) { 55 | $license_uri = preg_replace( '/\[.+?]\((.+?)\)/', '$1', $matches['value'] ); 56 | 57 | if ( 0 !== strpos( $license_uri, 'http' ) ) { 58 | fwrite( STDERR, "Unable to extract License URI from: $meta.\n" ); 59 | exit( __LINE__ ); 60 | } 61 | 62 | $metadata['License URI'] = $license_uri; 63 | } 64 | } 65 | 66 | $expected_metadata = [ 67 | 'Contributors', 68 | 'Tags', 69 | 'Tested up to', 70 | 'Stable tag', 71 | 'License', 72 | 'License URI', 73 | ]; 74 | foreach ( $expected_metadata as $key ) { 75 | if ( empty( $metadata[ $key ] ) ) { 76 | fwrite( STDERR, "Failed to parse metadata. Missing: $key\n" ); 77 | exit( __LINE__ ); 78 | } 79 | } 80 | 81 | $replaced = "$header\n"; 82 | foreach ( $metadata as $key => $value ) { 83 | $replaced .= "$key: $value\n"; 84 | } 85 | $replaced .= "\n$description\n\n"; 86 | 87 | return $replaced; 88 | }, 89 | $readme_txt 90 | ); 91 | 92 | // Replace image-linked YouTube videos with bare URLs. 93 | $readme_txt = preg_replace( 94 | '#\[!\[.+?]\(.+?\)]\((https://www\.youtube\.com/.+?)\)#', 95 | '$1', 96 | $readme_txt 97 | ); 98 | 99 | // Fix up the screenshots. 100 | $screenshots_captioned = 0; 101 | $readme_txt = preg_replace_callback( 102 | '/(?<=## Screenshots\n\n)(.+?)(?=## Changelog)/s', 103 | static function ( $matches ) use ( &$screenshots_captioned ) { 104 | if ( ! preg_match_all( '/### (.+)/', $matches[0], $screenshot_matches ) ) { 105 | fwrite( STDERR, "Unable to parse screenshot headings.\n" ); 106 | exit( __LINE__ ); 107 | } 108 | 109 | $screenshot_txt = ''; 110 | foreach ( $screenshot_matches[1] as $i => $screenshot_caption ) { 111 | $screenshot_txt .= sprintf( "%d. %s\n", $i + 1, $screenshot_caption ); 112 | $screenshots_captioned++; 113 | } 114 | $screenshot_txt .= "\n"; 115 | 116 | return $screenshot_txt; 117 | }, 118 | $readme_txt, 119 | 1, 120 | $replace_count 121 | ); 122 | if ( 0 === $replace_count ) { 123 | fwrite( STDERR, "Unable to transform screenshots.\n" ); 124 | exit( __LINE__ ); 125 | } 126 | 127 | $screenshot_files = glob( __DIR__ . '/../.wordpress-org/screenshot-*' ); 128 | if ( count( $screenshot_files ) !== $screenshots_captioned ) { 129 | fwrite( STDERR, "Number of screenshot files does not match number of screenshot captions.\n" ); 130 | exit( __LINE__ ); 131 | } 132 | foreach ( $screenshot_files as $i => $screenshot_file ) { 133 | if ( 0 !== strpos( basename( $screenshot_file ), sprintf( 'screenshot-%d.', $i + 1 ) ) ) { 134 | fwrite( STDERR, "Screenshot filename is not sequential: $screenshot_file.\n" ); 135 | exit( __LINE__ ); 136 | } 137 | } 138 | 139 | // Convert markdown headings into WP readme headings for good measure. 140 | $readme_txt = preg_replace_callback( 141 | '/^(#+)\s(.+)/m', 142 | static function ( $matches ) { 143 | $md_heading_level = strlen( $matches[1] ); 144 | $heading_text = $matches[2]; 145 | 146 | // #: === 147 | // ##: == 148 | // ###: = 149 | $txt_heading_level = 4 - $md_heading_level; 150 | if ( $txt_heading_level <= 0 ) { 151 | fwrite( STDERR, "Heading too small to transform: {$matches[0]}.\n" ); 152 | exit( __LINE__ ); 153 | } 154 | 155 | return sprintf( 156 | '%1$s %2$s %1$s', 157 | str_repeat( '=', $txt_heading_level ), 158 | $heading_text 159 | ); 160 | }, 161 | $readme_txt, 162 | -1, 163 | $replace_count 164 | ); 165 | if ( 0 === $replace_count ) { 166 | fwrite( STDERR, "Unable to transform headings.\n" ); 167 | exit( __LINE__ ); 168 | } 169 | 170 | if ( ! file_put_contents( __DIR__ . '/../readme.txt', $readme_txt ) ) { 171 | fwrite( STDERR, "Failed to write readme.txt.\n" ); 172 | exit( __LINE__ ); 173 | } 174 | 175 | fwrite( STDOUT, "Validated README.md and generated readme.txt\n" ); 176 | -------------------------------------------------------------------------------- /bin/update-highlight-libs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | cd "$(dirname "$0")/.." 5 | 6 | current_highlight_php_version=$(curl -sq https://api.github.com/repos/scrivo/highlight.php/releases | grep -oE '"tag_name":\s*"[^"]*' | head -n1 | sed 's/.*"v//') 7 | if [[ -z $current_highlight_php_version ]]; then 8 | echo "Unable to get version" 9 | exit 1 10 | fi 11 | 12 | current_highlight_js_version=$( sed "s/\.[[:digit:]]*$//" <<< "$current_highlight_php_version" ) 13 | 14 | echo "Current highlight.php version: $current_highlight_php_version" 15 | echo "Current highlight.js version: $current_highlight_js_version" 16 | 17 | set -x 18 | 19 | composer require "scrivo/highlight.php:v$current_highlight_php_version" 20 | 21 | npm install --save-dev "highlightjs/highlight.js#$current_highlight_js_version" 22 | 23 | php bin/generate-language-names.php 24 | 25 | git add composer.json composer.lock package-lock.json package.json language-names.php 26 | 27 | git status 28 | 29 | echo "Do: git commit -m 'Update highlight.php to $current_highlight_php_version'" 30 | -------------------------------------------------------------------------------- /bin/verify-version-consistency.php: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | \S+)/i', $readme_md, $matches ) ) { 19 | echo "Could not find stable tag in readme\n"; 20 | exit( 1 ); 21 | } 22 | $versions['README.md#stable-tag'] = $matches['version']; 23 | 24 | $plugin_file = file_get_contents( dirname( __FILE__ ) . '/../syntax-highlighting-code-block.php' ); 25 | if ( ! preg_match( '/\*\s*Version:\s*(?P\d+\.\d+(?:.\d+)?(-\w+)?)/', $plugin_file, $matches ) ) { 26 | echo "Could not find version in readme metadata\n"; 27 | exit( 1 ); 28 | } 29 | $versions['syntax-highlighting-code-block.php#metadata'] = $matches['version']; 30 | 31 | if ( ! preg_match( '/const PLUGIN_VERSION = \'(?P[^\\\']+)\'/', $plugin_file, $matches ) ) { 32 | echo "Could not find version in PLUGIN_VERSION constant\n"; 33 | exit( 1 ); 34 | } 35 | $versions['PLUGIN_VERSION'] = $matches['version']; 36 | 37 | fwrite( STDERR, "Version references:\n" ); 38 | 39 | echo json_encode( $versions, JSON_PRETTY_PRINT ) . "\n"; 40 | 41 | if ( 1 !== count( array_unique( $versions ) ) ) { 42 | fwrite( STDERR, "Error: Not all version references have been updated.\n" ); 43 | exit( 1 ); 44 | } 45 | 46 | if ( false === strpos( $versions['syntax-highlighting-code-block.php#metadata'], '-' ) && ! preg_match( '/^\d+\.\d+\.\d+$/', $versions['syntax-highlighting-code-block.php#metadata'] ) ) { 47 | fwrite( STDERR, sprintf( "Error: Release version (%s) lacks patch number. For new point releases, supply patch number of 0, such as 0.9.0 instead of 0.9.\n", $versions['syntax-highlighting-code-block.php#metadata'] ) ); 48 | exit( 1 ); 49 | } 50 | -------------------------------------------------------------------------------- /block-library.md5: -------------------------------------------------------------------------------- 1 | 8d5405f9c190cb3c26853a4954685925 node_modules/@wordpress/block-library/src/code/edit.js 2 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "westonruter/syntax-highlighting-code-block", 3 | "description": "A WordPress plugin which extends Gutenberg adding server-rendered color syntax highlighting to the code block.", 4 | "license": "GPL-2.0-or-later", 5 | "type": "wordpress-plugin", 6 | "require": { 7 | "scrivo/highlight.php": "9.18.1.10" 8 | }, 9 | "require-dev": { 10 | "ergebnis/composer-normalize": "2.47.0", 11 | "phpcompatibility/php-compatibility": "9.3.5", 12 | "phpstan/phpstan": "1.12.7", 13 | "szepeviktor/phpstan-wordpress": "1.3.5", 14 | "wp-cli/dist-archive-command": "dev-main", 15 | "wp-coding-standards/wpcs": "3.1.0" 16 | }, 17 | "config": { 18 | "allow-plugins": { 19 | "dealerdirect/phpcodesniffer-composer-installer": true, 20 | "ergebnis/composer-normalize": true 21 | }, 22 | "platform": { 23 | "php": "7.4" 24 | }, 25 | "sort-packages": true 26 | }, 27 | "scripts": { 28 | "analyze": "if [ -z $TEST_SKIP_PHPSTAN ]; then phpstan --version; phpstan analyze --ansi; fi", 29 | "phpcbf": "bin/phpcbf.sh", 30 | "phpcs": "phpcs" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "e89e3979336330d660570cd119bd2e80", 8 | "packages": [ 9 | { 10 | "name": "scrivo/highlight.php", 11 | "version": "v9.18.1.10", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/scrivo/highlight.php.git", 15 | "reference": "850f4b44697a2552e892ffe71490ba2733c2fc6e" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/scrivo/highlight.php/zipball/850f4b44697a2552e892ffe71490ba2733c2fc6e", 20 | "reference": "850f4b44697a2552e892ffe71490ba2733c2fc6e", 21 | "shasum": "" 22 | }, 23 | "require": { 24 | "ext-json": "*", 25 | "php": ">=5.4" 26 | }, 27 | "require-dev": { 28 | "phpunit/phpunit": "^4.8|^5.7", 29 | "sabberworm/php-css-parser": "^8.3", 30 | "symfony/finder": "^2.8|^3.4|^5.4", 31 | "symfony/var-dumper": "^2.8|^3.4|^5.4" 32 | }, 33 | "suggest": { 34 | "ext-mbstring": "Allows highlighting code with unicode characters and supports language with unicode keywords" 35 | }, 36 | "type": "library", 37 | "autoload": { 38 | "files": [ 39 | "HighlightUtilities/functions.php" 40 | ], 41 | "psr-0": { 42 | "Highlight\\": "", 43 | "HighlightUtilities\\": "" 44 | } 45 | }, 46 | "notification-url": "https://packagist.org/downloads/", 47 | "license": [ 48 | "BSD-3-Clause" 49 | ], 50 | "authors": [ 51 | { 52 | "name": "Geert Bergman", 53 | "homepage": "http://www.scrivo.org/", 54 | "role": "Project Author" 55 | }, 56 | { 57 | "name": "Vladimir Jimenez", 58 | "homepage": "https://allejo.io", 59 | "role": "Maintainer" 60 | }, 61 | { 62 | "name": "Martin Folkers", 63 | "homepage": "https://twobrain.io", 64 | "role": "Contributor" 65 | } 66 | ], 67 | "description": "Server side syntax highlighter that supports 185 languages. It's a PHP port of highlight.js", 68 | "keywords": [ 69 | "code", 70 | "highlight", 71 | "highlight.js", 72 | "highlight.php", 73 | "syntax" 74 | ], 75 | "support": { 76 | "issues": "https://github.com/scrivo/highlight.php/issues", 77 | "source": "https://github.com/scrivo/highlight.php" 78 | }, 79 | "funding": [ 80 | { 81 | "url": "https://github.com/allejo", 82 | "type": "github" 83 | } 84 | ], 85 | "time": "2022-12-17T21:53:22+00:00" 86 | } 87 | ], 88 | "packages-dev": [ 89 | { 90 | "name": "dealerdirect/phpcodesniffer-composer-installer", 91 | "version": "v1.0.0", 92 | "source": { 93 | "type": "git", 94 | "url": "https://github.com/PHPCSStandards/composer-installer.git", 95 | "reference": "4be43904336affa5c2f70744a348312336afd0da" 96 | }, 97 | "dist": { 98 | "type": "zip", 99 | "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/4be43904336affa5c2f70744a348312336afd0da", 100 | "reference": "4be43904336affa5c2f70744a348312336afd0da", 101 | "shasum": "" 102 | }, 103 | "require": { 104 | "composer-plugin-api": "^1.0 || ^2.0", 105 | "php": ">=5.4", 106 | "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" 107 | }, 108 | "require-dev": { 109 | "composer/composer": "*", 110 | "ext-json": "*", 111 | "ext-zip": "*", 112 | "php-parallel-lint/php-parallel-lint": "^1.3.1", 113 | "phpcompatibility/php-compatibility": "^9.0", 114 | "yoast/phpunit-polyfills": "^1.0" 115 | }, 116 | "type": "composer-plugin", 117 | "extra": { 118 | "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" 119 | }, 120 | "autoload": { 121 | "psr-4": { 122 | "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" 123 | } 124 | }, 125 | "notification-url": "https://packagist.org/downloads/", 126 | "license": [ 127 | "MIT" 128 | ], 129 | "authors": [ 130 | { 131 | "name": "Franck Nijhof", 132 | "email": "franck.nijhof@dealerdirect.com", 133 | "homepage": "http://www.frenck.nl", 134 | "role": "Developer / IT Manager" 135 | }, 136 | { 137 | "name": "Contributors", 138 | "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors" 139 | } 140 | ], 141 | "description": "PHP_CodeSniffer Standards Composer Installer Plugin", 142 | "homepage": "http://www.dealerdirect.com", 143 | "keywords": [ 144 | "PHPCodeSniffer", 145 | "PHP_CodeSniffer", 146 | "code quality", 147 | "codesniffer", 148 | "composer", 149 | "installer", 150 | "phpcbf", 151 | "phpcs", 152 | "plugin", 153 | "qa", 154 | "quality", 155 | "standard", 156 | "standards", 157 | "style guide", 158 | "stylecheck", 159 | "tests" 160 | ], 161 | "support": { 162 | "issues": "https://github.com/PHPCSStandards/composer-installer/issues", 163 | "source": "https://github.com/PHPCSStandards/composer-installer" 164 | }, 165 | "time": "2023-01-05T11:28:13+00:00" 166 | }, 167 | { 168 | "name": "ergebnis/composer-normalize", 169 | "version": "2.47.0", 170 | "source": { 171 | "type": "git", 172 | "url": "https://github.com/ergebnis/composer-normalize.git", 173 | "reference": "ed24b9f8901f8fbafeca98f662eaca39427f0544" 174 | }, 175 | "dist": { 176 | "type": "zip", 177 | "url": "https://api.github.com/repos/ergebnis/composer-normalize/zipball/ed24b9f8901f8fbafeca98f662eaca39427f0544", 178 | "reference": "ed24b9f8901f8fbafeca98f662eaca39427f0544", 179 | "shasum": "" 180 | }, 181 | "require": { 182 | "composer-plugin-api": "^2.0.0", 183 | "ergebnis/json": "^1.4.0", 184 | "ergebnis/json-normalizer": "^4.9.0", 185 | "ergebnis/json-printer": "^3.7.0", 186 | "ext-json": "*", 187 | "justinrainbow/json-schema": "^5.2.12 || ^6.0.0", 188 | "localheinz/diff": "^1.2.0", 189 | "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0" 190 | }, 191 | "require-dev": { 192 | "composer/composer": "^2.8.3", 193 | "ergebnis/license": "^2.6.0", 194 | "ergebnis/php-cs-fixer-config": "^6.46.0", 195 | "ergebnis/phpunit-slow-test-detector": "^2.19.1", 196 | "fakerphp/faker": "^1.24.1", 197 | "infection/infection": "~0.26.6", 198 | "phpstan/extension-installer": "^1.4.3", 199 | "phpstan/phpstan": "^2.1.11", 200 | "phpstan/phpstan-deprecation-rules": "^2.0.1", 201 | "phpstan/phpstan-phpunit": "^2.0.6", 202 | "phpstan/phpstan-strict-rules": "^2.0.4", 203 | "phpunit/phpunit": "^9.6.20", 204 | "rector/rector": "^2.0.11", 205 | "symfony/filesystem": "^5.4.41" 206 | }, 207 | "type": "composer-plugin", 208 | "extra": { 209 | "class": "Ergebnis\\Composer\\Normalize\\NormalizePlugin", 210 | "branch-alias": { 211 | "dev-main": "2.44-dev" 212 | }, 213 | "plugin-optional": true, 214 | "composer-normalize": { 215 | "indent-size": 2, 216 | "indent-style": "space" 217 | } 218 | }, 219 | "autoload": { 220 | "psr-4": { 221 | "Ergebnis\\Composer\\Normalize\\": "src/" 222 | } 223 | }, 224 | "notification-url": "https://packagist.org/downloads/", 225 | "license": [ 226 | "MIT" 227 | ], 228 | "authors": [ 229 | { 230 | "name": "Andreas Möller", 231 | "email": "am@localheinz.com", 232 | "homepage": "https://localheinz.com" 233 | } 234 | ], 235 | "description": "Provides a composer plugin for normalizing composer.json.", 236 | "homepage": "https://github.com/ergebnis/composer-normalize", 237 | "keywords": [ 238 | "composer", 239 | "normalize", 240 | "normalizer", 241 | "plugin" 242 | ], 243 | "support": { 244 | "issues": "https://github.com/ergebnis/composer-normalize/issues", 245 | "security": "https://github.com/ergebnis/composer-normalize/blob/main/.github/SECURITY.md", 246 | "source": "https://github.com/ergebnis/composer-normalize" 247 | }, 248 | "time": "2025-04-15T11:09:27+00:00" 249 | }, 250 | { 251 | "name": "ergebnis/json", 252 | "version": "1.4.0", 253 | "source": { 254 | "type": "git", 255 | "url": "https://github.com/ergebnis/json.git", 256 | "reference": "7656ac2aa6c2ca4408f96f599e9a17a22c464f69" 257 | }, 258 | "dist": { 259 | "type": "zip", 260 | "url": "https://api.github.com/repos/ergebnis/json/zipball/7656ac2aa6c2ca4408f96f599e9a17a22c464f69", 261 | "reference": "7656ac2aa6c2ca4408f96f599e9a17a22c464f69", 262 | "shasum": "" 263 | }, 264 | "require": { 265 | "ext-json": "*", 266 | "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0" 267 | }, 268 | "require-dev": { 269 | "ergebnis/data-provider": "^3.3.0", 270 | "ergebnis/license": "^2.5.0", 271 | "ergebnis/php-cs-fixer-config": "^6.37.0", 272 | "ergebnis/phpunit-slow-test-detector": "^2.16.1", 273 | "fakerphp/faker": "^1.24.0", 274 | "infection/infection": "~0.26.6", 275 | "phpstan/extension-installer": "^1.4.3", 276 | "phpstan/phpstan": "^1.12.10", 277 | "phpstan/phpstan-deprecation-rules": "^1.2.1", 278 | "phpstan/phpstan-phpunit": "^1.4.0", 279 | "phpstan/phpstan-strict-rules": "^1.6.1", 280 | "phpunit/phpunit": "^9.6.18", 281 | "rector/rector": "^1.2.10" 282 | }, 283 | "type": "library", 284 | "extra": { 285 | "composer-normalize": { 286 | "indent-size": 2, 287 | "indent-style": "space" 288 | } 289 | }, 290 | "autoload": { 291 | "psr-4": { 292 | "Ergebnis\\Json\\": "src/" 293 | } 294 | }, 295 | "notification-url": "https://packagist.org/downloads/", 296 | "license": [ 297 | "MIT" 298 | ], 299 | "authors": [ 300 | { 301 | "name": "Andreas Möller", 302 | "email": "am@localheinz.com", 303 | "homepage": "https://localheinz.com" 304 | } 305 | ], 306 | "description": "Provides a Json value object for representing a valid JSON string.", 307 | "homepage": "https://github.com/ergebnis/json", 308 | "keywords": [ 309 | "json" 310 | ], 311 | "support": { 312 | "issues": "https://github.com/ergebnis/json/issues", 313 | "security": "https://github.com/ergebnis/json/blob/main/.github/SECURITY.md", 314 | "source": "https://github.com/ergebnis/json" 315 | }, 316 | "time": "2024-11-17T11:51:22+00:00" 317 | }, 318 | { 319 | "name": "ergebnis/json-normalizer", 320 | "version": "4.9.0", 321 | "source": { 322 | "type": "git", 323 | "url": "https://github.com/ergebnis/json-normalizer.git", 324 | "reference": "cc4dcf3890448572a2d9bea97133c4d860e59fb1" 325 | }, 326 | "dist": { 327 | "type": "zip", 328 | "url": "https://api.github.com/repos/ergebnis/json-normalizer/zipball/cc4dcf3890448572a2d9bea97133c4d860e59fb1", 329 | "reference": "cc4dcf3890448572a2d9bea97133c4d860e59fb1", 330 | "shasum": "" 331 | }, 332 | "require": { 333 | "ergebnis/json": "^1.2.0", 334 | "ergebnis/json-pointer": "^3.4.0", 335 | "ergebnis/json-printer": "^3.5.0", 336 | "ergebnis/json-schema-validator": "^4.2.0", 337 | "ext-json": "*", 338 | "justinrainbow/json-schema": "^5.2.12 || ^6.0.0", 339 | "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0" 340 | }, 341 | "require-dev": { 342 | "composer/semver": "^3.4.3", 343 | "ergebnis/composer-normalize": "^2.44.0", 344 | "ergebnis/data-provider": "^3.3.0", 345 | "ergebnis/license": "^2.5.0", 346 | "ergebnis/php-cs-fixer-config": "^6.37.0", 347 | "ergebnis/phpunit-slow-test-detector": "^2.16.1", 348 | "fakerphp/faker": "^1.24.0", 349 | "infection/infection": "~0.26.6", 350 | "phpstan/extension-installer": "^1.4.3", 351 | "phpstan/phpstan": "^1.12.10", 352 | "phpstan/phpstan-deprecation-rules": "^1.2.1", 353 | "phpstan/phpstan-phpunit": "^1.4.0", 354 | "phpstan/phpstan-strict-rules": "^1.6.1", 355 | "phpunit/phpunit": "^9.6.19", 356 | "rector/rector": "^1.2.10" 357 | }, 358 | "suggest": { 359 | "composer/semver": "If you want to use ComposerJsonNormalizer or VersionConstraintNormalizer" 360 | }, 361 | "type": "library", 362 | "extra": { 363 | "branch-alias": { 364 | "dev-main": "4.8-dev" 365 | }, 366 | "composer-normalize": { 367 | "indent-size": 2, 368 | "indent-style": "space" 369 | } 370 | }, 371 | "autoload": { 372 | "psr-4": { 373 | "Ergebnis\\Json\\Normalizer\\": "src/" 374 | } 375 | }, 376 | "notification-url": "https://packagist.org/downloads/", 377 | "license": [ 378 | "MIT" 379 | ], 380 | "authors": [ 381 | { 382 | "name": "Andreas Möller", 383 | "email": "am@localheinz.com", 384 | "homepage": "https://localheinz.com" 385 | } 386 | ], 387 | "description": "Provides generic and vendor-specific normalizers for normalizing JSON documents.", 388 | "homepage": "https://github.com/ergebnis/json-normalizer", 389 | "keywords": [ 390 | "json", 391 | "normalizer" 392 | ], 393 | "support": { 394 | "issues": "https://github.com/ergebnis/json-normalizer/issues", 395 | "security": "https://github.com/ergebnis/json-normalizer/blob/main/.github/SECURITY.md", 396 | "source": "https://github.com/ergebnis/json-normalizer" 397 | }, 398 | "time": "2025-04-10T13:13:04+00:00" 399 | }, 400 | { 401 | "name": "ergebnis/json-pointer", 402 | "version": "3.6.0", 403 | "source": { 404 | "type": "git", 405 | "url": "https://github.com/ergebnis/json-pointer.git", 406 | "reference": "4fc85d8edb74466d282119d8d9541ec7cffc0798" 407 | }, 408 | "dist": { 409 | "type": "zip", 410 | "url": "https://api.github.com/repos/ergebnis/json-pointer/zipball/4fc85d8edb74466d282119d8d9541ec7cffc0798", 411 | "reference": "4fc85d8edb74466d282119d8d9541ec7cffc0798", 412 | "shasum": "" 413 | }, 414 | "require": { 415 | "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0" 416 | }, 417 | "require-dev": { 418 | "ergebnis/composer-normalize": "^2.43.0", 419 | "ergebnis/data-provider": "^3.2.0", 420 | "ergebnis/license": "^2.4.0", 421 | "ergebnis/php-cs-fixer-config": "^6.32.0", 422 | "ergebnis/phpunit-slow-test-detector": "^2.15.0", 423 | "fakerphp/faker": "^1.23.1", 424 | "infection/infection": "~0.26.6", 425 | "phpstan/extension-installer": "^1.4.3", 426 | "phpstan/phpstan": "^1.12.10", 427 | "phpstan/phpstan-deprecation-rules": "^1.2.1", 428 | "phpstan/phpstan-phpunit": "^1.4.0", 429 | "phpstan/phpstan-strict-rules": "^1.6.1", 430 | "phpunit/phpunit": "^9.6.19", 431 | "rector/rector": "^1.2.10" 432 | }, 433 | "type": "library", 434 | "extra": { 435 | "branch-alias": { 436 | "dev-main": "3.6-dev" 437 | }, 438 | "composer-normalize": { 439 | "indent-size": 2, 440 | "indent-style": "space" 441 | } 442 | }, 443 | "autoload": { 444 | "psr-4": { 445 | "Ergebnis\\Json\\Pointer\\": "src/" 446 | } 447 | }, 448 | "notification-url": "https://packagist.org/downloads/", 449 | "license": [ 450 | "MIT" 451 | ], 452 | "authors": [ 453 | { 454 | "name": "Andreas Möller", 455 | "email": "am@localheinz.com", 456 | "homepage": "https://localheinz.com" 457 | } 458 | ], 459 | "description": "Provides an abstraction of a JSON pointer.", 460 | "homepage": "https://github.com/ergebnis/json-pointer", 461 | "keywords": [ 462 | "RFC6901", 463 | "json", 464 | "pointer" 465 | ], 466 | "support": { 467 | "issues": "https://github.com/ergebnis/json-pointer/issues", 468 | "security": "https://github.com/ergebnis/json-pointer/blob/main/.github/SECURITY.md", 469 | "source": "https://github.com/ergebnis/json-pointer" 470 | }, 471 | "time": "2024-11-17T12:37:06+00:00" 472 | }, 473 | { 474 | "name": "ergebnis/json-printer", 475 | "version": "3.7.0", 476 | "source": { 477 | "type": "git", 478 | "url": "https://github.com/ergebnis/json-printer.git", 479 | "reference": "ced41fce7854152f0e8f38793c2ffe59513cdd82" 480 | }, 481 | "dist": { 482 | "type": "zip", 483 | "url": "https://api.github.com/repos/ergebnis/json-printer/zipball/ced41fce7854152f0e8f38793c2ffe59513cdd82", 484 | "reference": "ced41fce7854152f0e8f38793c2ffe59513cdd82", 485 | "shasum": "" 486 | }, 487 | "require": { 488 | "ext-json": "*", 489 | "ext-mbstring": "*", 490 | "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0" 491 | }, 492 | "require-dev": { 493 | "ergebnis/data-provider": "^3.3.0", 494 | "ergebnis/license": "^2.5.0", 495 | "ergebnis/php-cs-fixer-config": "^6.37.0", 496 | "ergebnis/phpunit-slow-test-detector": "^2.16.1", 497 | "fakerphp/faker": "^1.24.0", 498 | "infection/infection": "~0.26.6", 499 | "phpstan/extension-installer": "^1.4.3", 500 | "phpstan/phpstan": "^1.12.10", 501 | "phpstan/phpstan-deprecation-rules": "^1.2.1", 502 | "phpstan/phpstan-phpunit": "^1.4.1", 503 | "phpstan/phpstan-strict-rules": "^1.6.1", 504 | "phpunit/phpunit": "^9.6.21", 505 | "rector/rector": "^1.2.10" 506 | }, 507 | "type": "library", 508 | "autoload": { 509 | "psr-4": { 510 | "Ergebnis\\Json\\Printer\\": "src/" 511 | } 512 | }, 513 | "notification-url": "https://packagist.org/downloads/", 514 | "license": [ 515 | "MIT" 516 | ], 517 | "authors": [ 518 | { 519 | "name": "Andreas Möller", 520 | "email": "am@localheinz.com", 521 | "homepage": "https://localheinz.com" 522 | } 523 | ], 524 | "description": "Provides a JSON printer, allowing for flexible indentation.", 525 | "homepage": "https://github.com/ergebnis/json-printer", 526 | "keywords": [ 527 | "formatter", 528 | "json", 529 | "printer" 530 | ], 531 | "support": { 532 | "issues": "https://github.com/ergebnis/json-printer/issues", 533 | "security": "https://github.com/ergebnis/json-printer/blob/main/.github/SECURITY.md", 534 | "source": "https://github.com/ergebnis/json-printer" 535 | }, 536 | "time": "2024-11-17T11:20:51+00:00" 537 | }, 538 | { 539 | "name": "ergebnis/json-schema-validator", 540 | "version": "4.4.0", 541 | "source": { 542 | "type": "git", 543 | "url": "https://github.com/ergebnis/json-schema-validator.git", 544 | "reference": "85f90c81f718aebba1d738800af83eeb447dc7ec" 545 | }, 546 | "dist": { 547 | "type": "zip", 548 | "url": "https://api.github.com/repos/ergebnis/json-schema-validator/zipball/85f90c81f718aebba1d738800af83eeb447dc7ec", 549 | "reference": "85f90c81f718aebba1d738800af83eeb447dc7ec", 550 | "shasum": "" 551 | }, 552 | "require": { 553 | "ergebnis/json": "^1.2.0", 554 | "ergebnis/json-pointer": "^3.4.0", 555 | "ext-json": "*", 556 | "justinrainbow/json-schema": "^5.2.12 || ^6.0.0", 557 | "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0" 558 | }, 559 | "require-dev": { 560 | "ergebnis/composer-normalize": "^2.44.0", 561 | "ergebnis/data-provider": "^3.3.0", 562 | "ergebnis/license": "^2.5.0", 563 | "ergebnis/php-cs-fixer-config": "^6.37.0", 564 | "ergebnis/phpunit-slow-test-detector": "^2.16.1", 565 | "fakerphp/faker": "^1.24.0", 566 | "infection/infection": "~0.26.6", 567 | "phpstan/extension-installer": "^1.4.3", 568 | "phpstan/phpstan": "^1.12.10", 569 | "phpstan/phpstan-deprecation-rules": "^1.2.1", 570 | "phpstan/phpstan-phpunit": "^1.4.0", 571 | "phpstan/phpstan-strict-rules": "^1.6.1", 572 | "phpunit/phpunit": "^9.6.20", 573 | "rector/rector": "^1.2.10" 574 | }, 575 | "type": "library", 576 | "extra": { 577 | "branch-alias": { 578 | "dev-main": "4.4-dev" 579 | }, 580 | "composer-normalize": { 581 | "indent-size": 2, 582 | "indent-style": "space" 583 | } 584 | }, 585 | "autoload": { 586 | "psr-4": { 587 | "Ergebnis\\Json\\SchemaValidator\\": "src/" 588 | } 589 | }, 590 | "notification-url": "https://packagist.org/downloads/", 591 | "license": [ 592 | "MIT" 593 | ], 594 | "authors": [ 595 | { 596 | "name": "Andreas Möller", 597 | "email": "am@localheinz.com", 598 | "homepage": "https://localheinz.com" 599 | } 600 | ], 601 | "description": "Provides a JSON schema validator, building on top of justinrainbow/json-schema.", 602 | "homepage": "https://github.com/ergebnis/json-schema-validator", 603 | "keywords": [ 604 | "json", 605 | "schema", 606 | "validator" 607 | ], 608 | "support": { 609 | "issues": "https://github.com/ergebnis/json-schema-validator/issues", 610 | "security": "https://github.com/ergebnis/json-schema-validator/blob/main/.github/SECURITY.md", 611 | "source": "https://github.com/ergebnis/json-schema-validator" 612 | }, 613 | "time": "2024-11-18T06:32:28+00:00" 614 | }, 615 | { 616 | "name": "inmarelibero/gitignore-checker", 617 | "version": "1.0.3", 618 | "source": { 619 | "type": "git", 620 | "url": "https://github.com/inmarelibero/gitignore-checker.git", 621 | "reference": "a489e819486216a7f4d55c708a4dd7e797166215" 622 | }, 623 | "dist": { 624 | "type": "zip", 625 | "url": "https://api.github.com/repos/inmarelibero/gitignore-checker/zipball/a489e819486216a7f4d55c708a4dd7e797166215", 626 | "reference": "a489e819486216a7f4d55c708a4dd7e797166215", 627 | "shasum": "" 628 | }, 629 | "require": { 630 | "php": ">=7.1" 631 | }, 632 | "require-dev": { 633 | "phpunit/phpunit": "^9.4" 634 | }, 635 | "type": "library", 636 | "autoload": { 637 | "psr-4": { 638 | "Inmarelibero\\GitIgnoreChecker\\": "src/" 639 | } 640 | }, 641 | "notification-url": "https://packagist.org/downloads/", 642 | "license": [ 643 | "MIT" 644 | ], 645 | "authors": [ 646 | { 647 | "name": "Emanuele Gaspari", 648 | "email": "inmarelibero@gmail.com", 649 | "role": "Developer" 650 | } 651 | ], 652 | "description": "A PHP library to check if a path is ignored by GIT", 653 | "keywords": [ 654 | "git", 655 | "gitignore", 656 | "vcs" 657 | ], 658 | "support": { 659 | "issues": "https://github.com/inmarelibero/gitignore-checker/issues", 660 | "source": "https://github.com/inmarelibero/gitignore-checker/tree/1.0.3" 661 | }, 662 | "time": "2023-09-26T09:20:54+00:00" 663 | }, 664 | { 665 | "name": "justinrainbow/json-schema", 666 | "version": "6.4.1", 667 | "source": { 668 | "type": "git", 669 | "url": "https://github.com/jsonrainbow/json-schema.git", 670 | "reference": "35d262c94959571e8736db1e5c9bc36ab94ae900" 671 | }, 672 | "dist": { 673 | "type": "zip", 674 | "url": "https://api.github.com/repos/jsonrainbow/json-schema/zipball/35d262c94959571e8736db1e5c9bc36ab94ae900", 675 | "reference": "35d262c94959571e8736db1e5c9bc36ab94ae900", 676 | "shasum": "" 677 | }, 678 | "require": { 679 | "ext-json": "*", 680 | "marc-mabe/php-enum": "^4.0", 681 | "php": "^7.2 || ^8.0" 682 | }, 683 | "require-dev": { 684 | "friendsofphp/php-cs-fixer": "3.3.0", 685 | "json-schema/json-schema-test-suite": "1.2.0", 686 | "marc-mabe/php-enum-phpstan": "^2.0", 687 | "phpspec/prophecy": "^1.19", 688 | "phpstan/phpstan": "^1.12", 689 | "phpunit/phpunit": "^8.5" 690 | }, 691 | "bin": [ 692 | "bin/validate-json" 693 | ], 694 | "type": "library", 695 | "extra": { 696 | "branch-alias": { 697 | "dev-master": "6.x-dev" 698 | } 699 | }, 700 | "autoload": { 701 | "psr-4": { 702 | "JsonSchema\\": "src/JsonSchema/" 703 | } 704 | }, 705 | "notification-url": "https://packagist.org/downloads/", 706 | "license": [ 707 | "MIT" 708 | ], 709 | "authors": [ 710 | { 711 | "name": "Bruno Prieto Reis", 712 | "email": "bruno.p.reis@gmail.com" 713 | }, 714 | { 715 | "name": "Justin Rainbow", 716 | "email": "justin.rainbow@gmail.com" 717 | }, 718 | { 719 | "name": "Igor Wiedler", 720 | "email": "igor@wiedler.ch" 721 | }, 722 | { 723 | "name": "Robert Schönthal", 724 | "email": "seroscho@googlemail.com" 725 | } 726 | ], 727 | "description": "A library to validate a json schema.", 728 | "homepage": "https://github.com/jsonrainbow/json-schema", 729 | "keywords": [ 730 | "json", 731 | "schema" 732 | ], 733 | "support": { 734 | "issues": "https://github.com/jsonrainbow/json-schema/issues", 735 | "source": "https://github.com/jsonrainbow/json-schema/tree/6.4.1" 736 | }, 737 | "time": "2025-04-04T13:08:07+00:00" 738 | }, 739 | { 740 | "name": "localheinz/diff", 741 | "version": "1.2.0", 742 | "source": { 743 | "type": "git", 744 | "url": "https://github.com/localheinz/diff.git", 745 | "reference": "ec413943c2b518464865673fd5b38f7df867a010" 746 | }, 747 | "dist": { 748 | "type": "zip", 749 | "url": "https://api.github.com/repos/localheinz/diff/zipball/ec413943c2b518464865673fd5b38f7df867a010", 750 | "reference": "ec413943c2b518464865673fd5b38f7df867a010", 751 | "shasum": "" 752 | }, 753 | "require": { 754 | "php": "~7.1.0 || ~7.2.0 || ~7.3.0 || ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0" 755 | }, 756 | "require-dev": { 757 | "phpunit/phpunit": "^7.5.0 || ^8.5.23", 758 | "symfony/process": "^4.2 || ^5" 759 | }, 760 | "type": "library", 761 | "autoload": { 762 | "classmap": [ 763 | "src/" 764 | ] 765 | }, 766 | "notification-url": "https://packagist.org/downloads/", 767 | "license": [ 768 | "BSD-3-Clause" 769 | ], 770 | "authors": [ 771 | { 772 | "name": "Sebastian Bergmann", 773 | "email": "sebastian@phpunit.de" 774 | }, 775 | { 776 | "name": "Kore Nordmann", 777 | "email": "mail@kore-nordmann.de" 778 | } 779 | ], 780 | "description": "Fork of sebastian/diff for use with ergebnis/composer-normalize", 781 | "homepage": "https://github.com/localheinz/diff", 782 | "keywords": [ 783 | "diff", 784 | "udiff", 785 | "unidiff", 786 | "unified diff" 787 | ], 788 | "support": { 789 | "issues": "https://github.com/localheinz/diff/issues", 790 | "source": "https://github.com/localheinz/diff/tree/1.2.0" 791 | }, 792 | "time": "2024-12-04T14:16:01+00:00" 793 | }, 794 | { 795 | "name": "marc-mabe/php-enum", 796 | "version": "v4.7.1", 797 | "source": { 798 | "type": "git", 799 | "url": "https://github.com/marc-mabe/php-enum.git", 800 | "reference": "7159809e5cfa041dca28e61f7f7ae58063aae8ed" 801 | }, 802 | "dist": { 803 | "type": "zip", 804 | "url": "https://api.github.com/repos/marc-mabe/php-enum/zipball/7159809e5cfa041dca28e61f7f7ae58063aae8ed", 805 | "reference": "7159809e5cfa041dca28e61f7f7ae58063aae8ed", 806 | "shasum": "" 807 | }, 808 | "require": { 809 | "ext-reflection": "*", 810 | "php": "^7.1 | ^8.0" 811 | }, 812 | "require-dev": { 813 | "phpbench/phpbench": "^0.16.10 || ^1.0.4", 814 | "phpstan/phpstan": "^1.3.1", 815 | "phpunit/phpunit": "^7.5.20 | ^8.5.22 | ^9.5.11", 816 | "vimeo/psalm": "^4.17.0 | ^5.26.1" 817 | }, 818 | "type": "library", 819 | "extra": { 820 | "branch-alias": { 821 | "dev-3.x": "3.2-dev", 822 | "dev-master": "4.7-dev" 823 | } 824 | }, 825 | "autoload": { 826 | "psr-4": { 827 | "MabeEnum\\": "src/" 828 | }, 829 | "classmap": [ 830 | "stubs/Stringable.php" 831 | ] 832 | }, 833 | "notification-url": "https://packagist.org/downloads/", 834 | "license": [ 835 | "BSD-3-Clause" 836 | ], 837 | "authors": [ 838 | { 839 | "name": "Marc Bennewitz", 840 | "email": "dev@mabe.berlin", 841 | "homepage": "https://mabe.berlin/", 842 | "role": "Lead" 843 | } 844 | ], 845 | "description": "Simple and fast implementation of enumerations with native PHP", 846 | "homepage": "https://github.com/marc-mabe/php-enum", 847 | "keywords": [ 848 | "enum", 849 | "enum-map", 850 | "enum-set", 851 | "enumeration", 852 | "enumerator", 853 | "enummap", 854 | "enumset", 855 | "map", 856 | "set", 857 | "type", 858 | "type-hint", 859 | "typehint" 860 | ], 861 | "support": { 862 | "issues": "https://github.com/marc-mabe/php-enum/issues", 863 | "source": "https://github.com/marc-mabe/php-enum/tree/v4.7.1" 864 | }, 865 | "time": "2024-11-28T04:54:44+00:00" 866 | }, 867 | { 868 | "name": "mustache/mustache", 869 | "version": "v2.14.2", 870 | "source": { 871 | "type": "git", 872 | "url": "https://github.com/bobthecow/mustache.php.git", 873 | "reference": "e62b7c3849d22ec55f3ec425507bf7968193a6cb" 874 | }, 875 | "dist": { 876 | "type": "zip", 877 | "url": "https://api.github.com/repos/bobthecow/mustache.php/zipball/e62b7c3849d22ec55f3ec425507bf7968193a6cb", 878 | "reference": "e62b7c3849d22ec55f3ec425507bf7968193a6cb", 879 | "shasum": "" 880 | }, 881 | "require": { 882 | "php": ">=5.2.4" 883 | }, 884 | "require-dev": { 885 | "friendsofphp/php-cs-fixer": "~1.11", 886 | "phpunit/phpunit": "~3.7|~4.0|~5.0" 887 | }, 888 | "type": "library", 889 | "autoload": { 890 | "psr-0": { 891 | "Mustache": "src/" 892 | } 893 | }, 894 | "notification-url": "https://packagist.org/downloads/", 895 | "license": [ 896 | "MIT" 897 | ], 898 | "authors": [ 899 | { 900 | "name": "Justin Hileman", 901 | "email": "justin@justinhileman.info", 902 | "homepage": "http://justinhileman.com" 903 | } 904 | ], 905 | "description": "A Mustache implementation in PHP.", 906 | "homepage": "https://github.com/bobthecow/mustache.php", 907 | "keywords": [ 908 | "mustache", 909 | "templating" 910 | ], 911 | "support": { 912 | "issues": "https://github.com/bobthecow/mustache.php/issues", 913 | "source": "https://github.com/bobthecow/mustache.php/tree/v2.14.2" 914 | }, 915 | "time": "2022-08-23T13:07:01+00:00" 916 | }, 917 | { 918 | "name": "php-stubs/wordpress-stubs", 919 | "version": "v6.5.3", 920 | "source": { 921 | "type": "git", 922 | "url": "https://github.com/php-stubs/wordpress-stubs.git", 923 | "reference": "e611a83292d02055a25f83291a98fadd0c21e092" 924 | }, 925 | "dist": { 926 | "type": "zip", 927 | "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/e611a83292d02055a25f83291a98fadd0c21e092", 928 | "reference": "e611a83292d02055a25f83291a98fadd0c21e092", 929 | "shasum": "" 930 | }, 931 | "require-dev": { 932 | "dealerdirect/phpcodesniffer-composer-installer": "^1.0", 933 | "nikic/php-parser": "^4.13", 934 | "php": "^7.4 || ~8.0.0", 935 | "php-stubs/generator": "^0.8.3", 936 | "phpdocumentor/reflection-docblock": "5.3", 937 | "phpstan/phpstan": "^1.10.49", 938 | "phpunit/phpunit": "^9.5", 939 | "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^0.11" 940 | }, 941 | "suggest": { 942 | "paragonie/sodium_compat": "Pure PHP implementation of libsodium", 943 | "symfony/polyfill-php80": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", 944 | "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan" 945 | }, 946 | "type": "library", 947 | "notification-url": "https://packagist.org/downloads/", 948 | "license": [ 949 | "MIT" 950 | ], 951 | "description": "WordPress function and class declaration stubs for static analysis.", 952 | "homepage": "https://github.com/php-stubs/wordpress-stubs", 953 | "keywords": [ 954 | "PHPStan", 955 | "static analysis", 956 | "wordpress" 957 | ], 958 | "support": { 959 | "issues": "https://github.com/php-stubs/wordpress-stubs/issues", 960 | "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.5.3" 961 | }, 962 | "time": "2024-05-08T02:12:31+00:00" 963 | }, 964 | { 965 | "name": "phpcompatibility/php-compatibility", 966 | "version": "9.3.5", 967 | "source": { 968 | "type": "git", 969 | "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", 970 | "reference": "9fb324479acf6f39452e0655d2429cc0d3914243" 971 | }, 972 | "dist": { 973 | "type": "zip", 974 | "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243", 975 | "reference": "9fb324479acf6f39452e0655d2429cc0d3914243", 976 | "shasum": "" 977 | }, 978 | "require": { 979 | "php": ">=5.3", 980 | "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" 981 | }, 982 | "conflict": { 983 | "squizlabs/php_codesniffer": "2.6.2" 984 | }, 985 | "require-dev": { 986 | "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0" 987 | }, 988 | "suggest": { 989 | "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.", 990 | "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." 991 | }, 992 | "type": "phpcodesniffer-standard", 993 | "notification-url": "https://packagist.org/downloads/", 994 | "license": [ 995 | "LGPL-3.0-or-later" 996 | ], 997 | "authors": [ 998 | { 999 | "name": "Wim Godden", 1000 | "homepage": "https://github.com/wimg", 1001 | "role": "lead" 1002 | }, 1003 | { 1004 | "name": "Juliette Reinders Folmer", 1005 | "homepage": "https://github.com/jrfnl", 1006 | "role": "lead" 1007 | }, 1008 | { 1009 | "name": "Contributors", 1010 | "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors" 1011 | } 1012 | ], 1013 | "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", 1014 | "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", 1015 | "keywords": [ 1016 | "compatibility", 1017 | "phpcs", 1018 | "standards" 1019 | ], 1020 | "support": { 1021 | "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues", 1022 | "source": "https://github.com/PHPCompatibility/PHPCompatibility" 1023 | }, 1024 | "time": "2019-12-27T09:44:58+00:00" 1025 | }, 1026 | { 1027 | "name": "phpcsstandards/phpcsextra", 1028 | "version": "1.2.1", 1029 | "source": { 1030 | "type": "git", 1031 | "url": "https://github.com/PHPCSStandards/PHPCSExtra.git", 1032 | "reference": "11d387c6642b6e4acaf0bd9bf5203b8cca1ec489" 1033 | }, 1034 | "dist": { 1035 | "type": "zip", 1036 | "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/11d387c6642b6e4acaf0bd9bf5203b8cca1ec489", 1037 | "reference": "11d387c6642b6e4acaf0bd9bf5203b8cca1ec489", 1038 | "shasum": "" 1039 | }, 1040 | "require": { 1041 | "php": ">=5.4", 1042 | "phpcsstandards/phpcsutils": "^1.0.9", 1043 | "squizlabs/php_codesniffer": "^3.8.0" 1044 | }, 1045 | "require-dev": { 1046 | "php-parallel-lint/php-console-highlighter": "^1.0", 1047 | "php-parallel-lint/php-parallel-lint": "^1.3.2", 1048 | "phpcsstandards/phpcsdevcs": "^1.1.6", 1049 | "phpcsstandards/phpcsdevtools": "^1.2.1", 1050 | "phpunit/phpunit": "^4.5 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" 1051 | }, 1052 | "type": "phpcodesniffer-standard", 1053 | "extra": { 1054 | "branch-alias": { 1055 | "dev-stable": "1.x-dev", 1056 | "dev-develop": "1.x-dev" 1057 | } 1058 | }, 1059 | "notification-url": "https://packagist.org/downloads/", 1060 | "license": [ 1061 | "LGPL-3.0-or-later" 1062 | ], 1063 | "authors": [ 1064 | { 1065 | "name": "Juliette Reinders Folmer", 1066 | "homepage": "https://github.com/jrfnl", 1067 | "role": "lead" 1068 | }, 1069 | { 1070 | "name": "Contributors", 1071 | "homepage": "https://github.com/PHPCSStandards/PHPCSExtra/graphs/contributors" 1072 | } 1073 | ], 1074 | "description": "A collection of sniffs and standards for use with PHP_CodeSniffer.", 1075 | "keywords": [ 1076 | "PHP_CodeSniffer", 1077 | "phpcbf", 1078 | "phpcodesniffer-standard", 1079 | "phpcs", 1080 | "standards", 1081 | "static analysis" 1082 | ], 1083 | "support": { 1084 | "issues": "https://github.com/PHPCSStandards/PHPCSExtra/issues", 1085 | "security": "https://github.com/PHPCSStandards/PHPCSExtra/security/policy", 1086 | "source": "https://github.com/PHPCSStandards/PHPCSExtra" 1087 | }, 1088 | "funding": [ 1089 | { 1090 | "url": "https://github.com/PHPCSStandards", 1091 | "type": "github" 1092 | }, 1093 | { 1094 | "url": "https://github.com/jrfnl", 1095 | "type": "github" 1096 | }, 1097 | { 1098 | "url": "https://opencollective.com/php_codesniffer", 1099 | "type": "open_collective" 1100 | } 1101 | ], 1102 | "time": "2023-12-08T16:49:07+00:00" 1103 | }, 1104 | { 1105 | "name": "phpcsstandards/phpcsutils", 1106 | "version": "1.0.10", 1107 | "source": { 1108 | "type": "git", 1109 | "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", 1110 | "reference": "51609a5b89f928e0c463d6df80eb38eff1eaf544" 1111 | }, 1112 | "dist": { 1113 | "type": "zip", 1114 | "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/51609a5b89f928e0c463d6df80eb38eff1eaf544", 1115 | "reference": "51609a5b89f928e0c463d6df80eb38eff1eaf544", 1116 | "shasum": "" 1117 | }, 1118 | "require": { 1119 | "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", 1120 | "php": ">=5.4", 1121 | "squizlabs/php_codesniffer": "^3.9.0 || 4.0.x-dev@dev" 1122 | }, 1123 | "require-dev": { 1124 | "ext-filter": "*", 1125 | "php-parallel-lint/php-console-highlighter": "^1.0", 1126 | "php-parallel-lint/php-parallel-lint": "^1.3.2", 1127 | "phpcsstandards/phpcsdevcs": "^1.1.6", 1128 | "yoast/phpunit-polyfills": "^1.1.0 || ^2.0.0" 1129 | }, 1130 | "type": "phpcodesniffer-standard", 1131 | "extra": { 1132 | "branch-alias": { 1133 | "dev-stable": "1.x-dev", 1134 | "dev-develop": "1.x-dev" 1135 | } 1136 | }, 1137 | "autoload": { 1138 | "classmap": [ 1139 | "PHPCSUtils/" 1140 | ] 1141 | }, 1142 | "notification-url": "https://packagist.org/downloads/", 1143 | "license": [ 1144 | "LGPL-3.0-or-later" 1145 | ], 1146 | "authors": [ 1147 | { 1148 | "name": "Juliette Reinders Folmer", 1149 | "homepage": "https://github.com/jrfnl", 1150 | "role": "lead" 1151 | }, 1152 | { 1153 | "name": "Contributors", 1154 | "homepage": "https://github.com/PHPCSStandards/PHPCSUtils/graphs/contributors" 1155 | } 1156 | ], 1157 | "description": "A suite of utility functions for use with PHP_CodeSniffer", 1158 | "homepage": "https://phpcsutils.com/", 1159 | "keywords": [ 1160 | "PHP_CodeSniffer", 1161 | "phpcbf", 1162 | "phpcodesniffer-standard", 1163 | "phpcs", 1164 | "phpcs3", 1165 | "standards", 1166 | "static analysis", 1167 | "tokens", 1168 | "utility" 1169 | ], 1170 | "support": { 1171 | "docs": "https://phpcsutils.com/", 1172 | "issues": "https://github.com/PHPCSStandards/PHPCSUtils/issues", 1173 | "security": "https://github.com/PHPCSStandards/PHPCSUtils/security/policy", 1174 | "source": "https://github.com/PHPCSStandards/PHPCSUtils" 1175 | }, 1176 | "funding": [ 1177 | { 1178 | "url": "https://github.com/PHPCSStandards", 1179 | "type": "github" 1180 | }, 1181 | { 1182 | "url": "https://github.com/jrfnl", 1183 | "type": "github" 1184 | }, 1185 | { 1186 | "url": "https://opencollective.com/php_codesniffer", 1187 | "type": "open_collective" 1188 | } 1189 | ], 1190 | "time": "2024-03-17T23:44:50+00:00" 1191 | }, 1192 | { 1193 | "name": "phpstan/phpstan", 1194 | "version": "1.12.7", 1195 | "source": { 1196 | "type": "git", 1197 | "url": "https://github.com/phpstan/phpstan.git", 1198 | "reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0" 1199 | }, 1200 | "dist": { 1201 | "type": "zip", 1202 | "url": "https://api.github.com/repos/phpstan/phpstan/zipball/dc2b9976bd8b0f84ec9b0e50cc35378551de7af0", 1203 | "reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0", 1204 | "shasum": "" 1205 | }, 1206 | "require": { 1207 | "php": "^7.2|^8.0" 1208 | }, 1209 | "conflict": { 1210 | "phpstan/phpstan-shim": "*" 1211 | }, 1212 | "bin": [ 1213 | "phpstan", 1214 | "phpstan.phar" 1215 | ], 1216 | "type": "library", 1217 | "autoload": { 1218 | "files": [ 1219 | "bootstrap.php" 1220 | ] 1221 | }, 1222 | "notification-url": "https://packagist.org/downloads/", 1223 | "license": [ 1224 | "MIT" 1225 | ], 1226 | "description": "PHPStan - PHP Static Analysis Tool", 1227 | "keywords": [ 1228 | "dev", 1229 | "static analysis" 1230 | ], 1231 | "support": { 1232 | "docs": "https://phpstan.org/user-guide/getting-started", 1233 | "forum": "https://github.com/phpstan/phpstan/discussions", 1234 | "issues": "https://github.com/phpstan/phpstan/issues", 1235 | "security": "https://github.com/phpstan/phpstan/security/policy", 1236 | "source": "https://github.com/phpstan/phpstan-src" 1237 | }, 1238 | "funding": [ 1239 | { 1240 | "url": "https://github.com/ondrejmirtes", 1241 | "type": "github" 1242 | }, 1243 | { 1244 | "url": "https://github.com/phpstan", 1245 | "type": "github" 1246 | } 1247 | ], 1248 | "time": "2024-10-18T11:12:07+00:00" 1249 | }, 1250 | { 1251 | "name": "squizlabs/php_codesniffer", 1252 | "version": "3.9.1", 1253 | "source": { 1254 | "type": "git", 1255 | "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", 1256 | "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909" 1257 | }, 1258 | "dist": { 1259 | "type": "zip", 1260 | "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/267a4405fff1d9c847134db3a3c92f1ab7f77909", 1261 | "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909", 1262 | "shasum": "" 1263 | }, 1264 | "require": { 1265 | "ext-simplexml": "*", 1266 | "ext-tokenizer": "*", 1267 | "ext-xmlwriter": "*", 1268 | "php": ">=5.4.0" 1269 | }, 1270 | "require-dev": { 1271 | "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" 1272 | }, 1273 | "bin": [ 1274 | "bin/phpcbf", 1275 | "bin/phpcs" 1276 | ], 1277 | "type": "library", 1278 | "extra": { 1279 | "branch-alias": { 1280 | "dev-master": "3.x-dev" 1281 | } 1282 | }, 1283 | "notification-url": "https://packagist.org/downloads/", 1284 | "license": [ 1285 | "BSD-3-Clause" 1286 | ], 1287 | "authors": [ 1288 | { 1289 | "name": "Greg Sherwood", 1290 | "role": "Former lead" 1291 | }, 1292 | { 1293 | "name": "Juliette Reinders Folmer", 1294 | "role": "Current lead" 1295 | }, 1296 | { 1297 | "name": "Contributors", 1298 | "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" 1299 | } 1300 | ], 1301 | "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", 1302 | "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", 1303 | "keywords": [ 1304 | "phpcs", 1305 | "standards", 1306 | "static analysis" 1307 | ], 1308 | "support": { 1309 | "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", 1310 | "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", 1311 | "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", 1312 | "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" 1313 | }, 1314 | "funding": [ 1315 | { 1316 | "url": "https://github.com/PHPCSStandards", 1317 | "type": "github" 1318 | }, 1319 | { 1320 | "url": "https://github.com/jrfnl", 1321 | "type": "github" 1322 | }, 1323 | { 1324 | "url": "https://opencollective.com/php_codesniffer", 1325 | "type": "open_collective" 1326 | } 1327 | ], 1328 | "time": "2024-03-31T21:03:09+00:00" 1329 | }, 1330 | { 1331 | "name": "symfony/deprecation-contracts", 1332 | "version": "v2.5.3", 1333 | "source": { 1334 | "type": "git", 1335 | "url": "https://github.com/symfony/deprecation-contracts.git", 1336 | "reference": "80d075412b557d41002320b96a096ca65aa2c98d" 1337 | }, 1338 | "dist": { 1339 | "type": "zip", 1340 | "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/80d075412b557d41002320b96a096ca65aa2c98d", 1341 | "reference": "80d075412b557d41002320b96a096ca65aa2c98d", 1342 | "shasum": "" 1343 | }, 1344 | "require": { 1345 | "php": ">=7.1" 1346 | }, 1347 | "type": "library", 1348 | "extra": { 1349 | "branch-alias": { 1350 | "dev-main": "2.5-dev" 1351 | }, 1352 | "thanks": { 1353 | "name": "symfony/contracts", 1354 | "url": "https://github.com/symfony/contracts" 1355 | } 1356 | }, 1357 | "autoload": { 1358 | "files": [ 1359 | "function.php" 1360 | ] 1361 | }, 1362 | "notification-url": "https://packagist.org/downloads/", 1363 | "license": [ 1364 | "MIT" 1365 | ], 1366 | "authors": [ 1367 | { 1368 | "name": "Nicolas Grekas", 1369 | "email": "p@tchwork.com" 1370 | }, 1371 | { 1372 | "name": "Symfony Community", 1373 | "homepage": "https://symfony.com/contributors" 1374 | } 1375 | ], 1376 | "description": "A generic function and convention to trigger deprecation notices", 1377 | "homepage": "https://symfony.com", 1378 | "support": { 1379 | "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.3" 1380 | }, 1381 | "funding": [ 1382 | { 1383 | "url": "https://symfony.com/sponsor", 1384 | "type": "custom" 1385 | }, 1386 | { 1387 | "url": "https://github.com/fabpot", 1388 | "type": "github" 1389 | }, 1390 | { 1391 | "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", 1392 | "type": "tidelift" 1393 | } 1394 | ], 1395 | "time": "2023-01-24T14:02:46+00:00" 1396 | }, 1397 | { 1398 | "name": "symfony/finder", 1399 | "version": "v5.4.35", 1400 | "source": { 1401 | "type": "git", 1402 | "url": "https://github.com/symfony/finder.git", 1403 | "reference": "abe6d6f77d9465fed3cd2d029b29d03b56b56435" 1404 | }, 1405 | "dist": { 1406 | "type": "zip", 1407 | "url": "https://api.github.com/repos/symfony/finder/zipball/abe6d6f77d9465fed3cd2d029b29d03b56b56435", 1408 | "reference": "abe6d6f77d9465fed3cd2d029b29d03b56b56435", 1409 | "shasum": "" 1410 | }, 1411 | "require": { 1412 | "php": ">=7.2.5", 1413 | "symfony/deprecation-contracts": "^2.1|^3", 1414 | "symfony/polyfill-php80": "^1.16" 1415 | }, 1416 | "type": "library", 1417 | "autoload": { 1418 | "psr-4": { 1419 | "Symfony\\Component\\Finder\\": "" 1420 | }, 1421 | "exclude-from-classmap": [ 1422 | "/Tests/" 1423 | ] 1424 | }, 1425 | "notification-url": "https://packagist.org/downloads/", 1426 | "license": [ 1427 | "MIT" 1428 | ], 1429 | "authors": [ 1430 | { 1431 | "name": "Fabien Potencier", 1432 | "email": "fabien@symfony.com" 1433 | }, 1434 | { 1435 | "name": "Symfony Community", 1436 | "homepage": "https://symfony.com/contributors" 1437 | } 1438 | ], 1439 | "description": "Finds files and directories via an intuitive fluent interface", 1440 | "homepage": "https://symfony.com", 1441 | "support": { 1442 | "source": "https://github.com/symfony/finder/tree/v5.4.35" 1443 | }, 1444 | "funding": [ 1445 | { 1446 | "url": "https://symfony.com/sponsor", 1447 | "type": "custom" 1448 | }, 1449 | { 1450 | "url": "https://github.com/fabpot", 1451 | "type": "github" 1452 | }, 1453 | { 1454 | "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", 1455 | "type": "tidelift" 1456 | } 1457 | ], 1458 | "time": "2024-01-23T13:51:25+00:00" 1459 | }, 1460 | { 1461 | "name": "symfony/polyfill-php73", 1462 | "version": "v1.30.0", 1463 | "source": { 1464 | "type": "git", 1465 | "url": "https://github.com/symfony/polyfill-php73.git", 1466 | "reference": "ec444d3f3f6505bb28d11afa41e75faadebc10a1" 1467 | }, 1468 | "dist": { 1469 | "type": "zip", 1470 | "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/ec444d3f3f6505bb28d11afa41e75faadebc10a1", 1471 | "reference": "ec444d3f3f6505bb28d11afa41e75faadebc10a1", 1472 | "shasum": "" 1473 | }, 1474 | "require": { 1475 | "php": ">=7.1" 1476 | }, 1477 | "type": "library", 1478 | "extra": { 1479 | "thanks": { 1480 | "name": "symfony/polyfill", 1481 | "url": "https://github.com/symfony/polyfill" 1482 | } 1483 | }, 1484 | "autoload": { 1485 | "files": [ 1486 | "bootstrap.php" 1487 | ], 1488 | "psr-4": { 1489 | "Symfony\\Polyfill\\Php73\\": "" 1490 | }, 1491 | "classmap": [ 1492 | "Resources/stubs" 1493 | ] 1494 | }, 1495 | "notification-url": "https://packagist.org/downloads/", 1496 | "license": [ 1497 | "MIT" 1498 | ], 1499 | "authors": [ 1500 | { 1501 | "name": "Nicolas Grekas", 1502 | "email": "p@tchwork.com" 1503 | }, 1504 | { 1505 | "name": "Symfony Community", 1506 | "homepage": "https://symfony.com/contributors" 1507 | } 1508 | ], 1509 | "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", 1510 | "homepage": "https://symfony.com", 1511 | "keywords": [ 1512 | "compatibility", 1513 | "polyfill", 1514 | "portable", 1515 | "shim" 1516 | ], 1517 | "support": { 1518 | "source": "https://github.com/symfony/polyfill-php73/tree/v1.30.0" 1519 | }, 1520 | "funding": [ 1521 | { 1522 | "url": "https://symfony.com/sponsor", 1523 | "type": "custom" 1524 | }, 1525 | { 1526 | "url": "https://github.com/fabpot", 1527 | "type": "github" 1528 | }, 1529 | { 1530 | "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", 1531 | "type": "tidelift" 1532 | } 1533 | ], 1534 | "time": "2024-05-31T15:07:36+00:00" 1535 | }, 1536 | { 1537 | "name": "symfony/polyfill-php80", 1538 | "version": "v1.29.0", 1539 | "source": { 1540 | "type": "git", 1541 | "url": "https://github.com/symfony/polyfill-php80.git", 1542 | "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b" 1543 | }, 1544 | "dist": { 1545 | "type": "zip", 1546 | "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", 1547 | "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", 1548 | "shasum": "" 1549 | }, 1550 | "require": { 1551 | "php": ">=7.1" 1552 | }, 1553 | "type": "library", 1554 | "extra": { 1555 | "thanks": { 1556 | "name": "symfony/polyfill", 1557 | "url": "https://github.com/symfony/polyfill" 1558 | } 1559 | }, 1560 | "autoload": { 1561 | "files": [ 1562 | "bootstrap.php" 1563 | ], 1564 | "psr-4": { 1565 | "Symfony\\Polyfill\\Php80\\": "" 1566 | }, 1567 | "classmap": [ 1568 | "Resources/stubs" 1569 | ] 1570 | }, 1571 | "notification-url": "https://packagist.org/downloads/", 1572 | "license": [ 1573 | "MIT" 1574 | ], 1575 | "authors": [ 1576 | { 1577 | "name": "Ion Bazan", 1578 | "email": "ion.bazan@gmail.com" 1579 | }, 1580 | { 1581 | "name": "Nicolas Grekas", 1582 | "email": "p@tchwork.com" 1583 | }, 1584 | { 1585 | "name": "Symfony Community", 1586 | "homepage": "https://symfony.com/contributors" 1587 | } 1588 | ], 1589 | "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", 1590 | "homepage": "https://symfony.com", 1591 | "keywords": [ 1592 | "compatibility", 1593 | "polyfill", 1594 | "portable", 1595 | "shim" 1596 | ], 1597 | "support": { 1598 | "source": "https://github.com/symfony/polyfill-php80/tree/v1.29.0" 1599 | }, 1600 | "funding": [ 1601 | { 1602 | "url": "https://symfony.com/sponsor", 1603 | "type": "custom" 1604 | }, 1605 | { 1606 | "url": "https://github.com/fabpot", 1607 | "type": "github" 1608 | }, 1609 | { 1610 | "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", 1611 | "type": "tidelift" 1612 | } 1613 | ], 1614 | "time": "2024-01-29T20:11:03+00:00" 1615 | }, 1616 | { 1617 | "name": "szepeviktor/phpstan-wordpress", 1618 | "version": "v1.3.5", 1619 | "source": { 1620 | "type": "git", 1621 | "url": "https://github.com/szepeviktor/phpstan-wordpress.git", 1622 | "reference": "7f8cfe992faa96b6a33bbd75c7bace98864161e7" 1623 | }, 1624 | "dist": { 1625 | "type": "zip", 1626 | "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/7f8cfe992faa96b6a33bbd75c7bace98864161e7", 1627 | "reference": "7f8cfe992faa96b6a33bbd75c7bace98864161e7", 1628 | "shasum": "" 1629 | }, 1630 | "require": { 1631 | "php": "^7.2 || ^8.0", 1632 | "php-stubs/wordpress-stubs": "^4.7 || ^5.0 || ^6.0", 1633 | "phpstan/phpstan": "^1.10.31", 1634 | "symfony/polyfill-php73": "^1.12.0" 1635 | }, 1636 | "require-dev": { 1637 | "composer/composer": "^2.1.14", 1638 | "dealerdirect/phpcodesniffer-composer-installer": "^1.0", 1639 | "php-parallel-lint/php-parallel-lint": "^1.1", 1640 | "phpstan/phpstan-strict-rules": "^1.2", 1641 | "phpunit/phpunit": "^8.0 || ^9.0", 1642 | "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^1.0", 1643 | "wp-coding-standards/wpcs": "3.1.0 as 2.3.0" 1644 | }, 1645 | "suggest": { 1646 | "swissspidy/phpstan-no-private": "Detect usage of internal core functions, classes and methods" 1647 | }, 1648 | "type": "phpstan-extension", 1649 | "extra": { 1650 | "phpstan": { 1651 | "includes": [ 1652 | "extension.neon" 1653 | ] 1654 | } 1655 | }, 1656 | "autoload": { 1657 | "psr-4": { 1658 | "SzepeViktor\\PHPStan\\WordPress\\": "src/" 1659 | } 1660 | }, 1661 | "notification-url": "https://packagist.org/downloads/", 1662 | "license": [ 1663 | "MIT" 1664 | ], 1665 | "description": "WordPress extensions for PHPStan", 1666 | "keywords": [ 1667 | "PHPStan", 1668 | "code analyse", 1669 | "code analysis", 1670 | "static analysis", 1671 | "wordpress" 1672 | ], 1673 | "support": { 1674 | "issues": "https://github.com/szepeviktor/phpstan-wordpress/issues", 1675 | "source": "https://github.com/szepeviktor/phpstan-wordpress/tree/v1.3.5" 1676 | }, 1677 | "time": "2024-06-28T22:27:19+00:00" 1678 | }, 1679 | { 1680 | "name": "wp-cli/dist-archive-command", 1681 | "version": "dev-main", 1682 | "source": { 1683 | "type": "git", 1684 | "url": "https://github.com/wp-cli/dist-archive-command.git", 1685 | "reference": "e226f7d4bcd4d7db0462a3644228b77d2ad5a85c" 1686 | }, 1687 | "dist": { 1688 | "type": "zip", 1689 | "url": "https://api.github.com/repos/wp-cli/dist-archive-command/zipball/e226f7d4bcd4d7db0462a3644228b77d2ad5a85c", 1690 | "reference": "e226f7d4bcd4d7db0462a3644228b77d2ad5a85c", 1691 | "shasum": "" 1692 | }, 1693 | "require": { 1694 | "inmarelibero/gitignore-checker": "^1.0.2", 1695 | "php": ">=7.4", 1696 | "wp-cli/wp-cli": "^2" 1697 | }, 1698 | "require-dev": { 1699 | "wp-cli/extension-command": "^2", 1700 | "wp-cli/scaffold-command": "^2", 1701 | "wp-cli/wp-cli-tests": "^4" 1702 | }, 1703 | "default-branch": true, 1704 | "type": "wp-cli-package", 1705 | "extra": { 1706 | "commands": [ 1707 | "dist-archive" 1708 | ], 1709 | "readme": { 1710 | "shields": [ 1711 | "[![Testing](https://github.com/wp-cli/dist-archive-command/actions/workflows/testing.yml/badge.svg)](https://github.com/wp-cli/dist-archive-command/actions/workflows/testing.yml)" 1712 | ] 1713 | } 1714 | }, 1715 | "autoload": { 1716 | "files": [ 1717 | "dist-archive-command.php" 1718 | ], 1719 | "classmap": [ 1720 | "src/" 1721 | ] 1722 | }, 1723 | "notification-url": "https://packagist.org/downloads/", 1724 | "license": [ 1725 | "MIT" 1726 | ], 1727 | "authors": [ 1728 | { 1729 | "name": "Daniel Bachhuber", 1730 | "email": "daniel@runcommand.io", 1731 | "homepage": "https://runcommand.io" 1732 | } 1733 | ], 1734 | "description": "Create a distribution .zip or .tar.gz based on a plugin or theme's .distignore file.", 1735 | "homepage": "https://github.com/wp-cli/dist-archive-command/", 1736 | "support": { 1737 | "issues": "https://github.com/wp-cli/dist-archive-command/issues", 1738 | "source": "https://github.com/wp-cli/dist-archive-command/tree/v3.0.0" 1739 | }, 1740 | "time": "2023-12-18T14:28:49+00:00" 1741 | }, 1742 | { 1743 | "name": "wp-cli/mustangostang-spyc", 1744 | "version": "0.6.3", 1745 | "source": { 1746 | "type": "git", 1747 | "url": "https://github.com/wp-cli/spyc.git", 1748 | "reference": "6aa0b4da69ce9e9a2c8402dab8d43cf32c581cc7" 1749 | }, 1750 | "dist": { 1751 | "type": "zip", 1752 | "url": "https://api.github.com/repos/wp-cli/spyc/zipball/6aa0b4da69ce9e9a2c8402dab8d43cf32c581cc7", 1753 | "reference": "6aa0b4da69ce9e9a2c8402dab8d43cf32c581cc7", 1754 | "shasum": "" 1755 | }, 1756 | "require": { 1757 | "php": ">=5.3.1" 1758 | }, 1759 | "require-dev": { 1760 | "phpunit/phpunit": "4.3.*@dev" 1761 | }, 1762 | "type": "library", 1763 | "extra": { 1764 | "branch-alias": { 1765 | "dev-master": "0.5.x-dev" 1766 | } 1767 | }, 1768 | "autoload": { 1769 | "files": [ 1770 | "includes/functions.php" 1771 | ], 1772 | "psr-4": { 1773 | "Mustangostang\\": "src/" 1774 | } 1775 | }, 1776 | "notification-url": "https://packagist.org/downloads/", 1777 | "license": [ 1778 | "MIT" 1779 | ], 1780 | "authors": [ 1781 | { 1782 | "name": "mustangostang", 1783 | "email": "vlad.andersen@gmail.com" 1784 | } 1785 | ], 1786 | "description": "A simple YAML loader/dumper class for PHP (WP-CLI fork)", 1787 | "homepage": "https://github.com/mustangostang/spyc/", 1788 | "support": { 1789 | "source": "https://github.com/wp-cli/spyc/tree/autoload" 1790 | }, 1791 | "time": "2017-04-25T11:26:20+00:00" 1792 | }, 1793 | { 1794 | "name": "wp-cli/php-cli-tools", 1795 | "version": "v0.11.22", 1796 | "source": { 1797 | "type": "git", 1798 | "url": "https://github.com/wp-cli/php-cli-tools.git", 1799 | "reference": "a6bb94664ca36d0962f9c2ff25591c315a550c51" 1800 | }, 1801 | "dist": { 1802 | "type": "zip", 1803 | "url": "https://api.github.com/repos/wp-cli/php-cli-tools/zipball/a6bb94664ca36d0962f9c2ff25591c315a550c51", 1804 | "reference": "a6bb94664ca36d0962f9c2ff25591c315a550c51", 1805 | "shasum": "" 1806 | }, 1807 | "require": { 1808 | "php": ">= 5.3.0" 1809 | }, 1810 | "require-dev": { 1811 | "roave/security-advisories": "dev-latest", 1812 | "wp-cli/wp-cli-tests": "^4" 1813 | }, 1814 | "type": "library", 1815 | "extra": { 1816 | "branch-alias": { 1817 | "dev-master": "0.11.x-dev" 1818 | } 1819 | }, 1820 | "autoload": { 1821 | "files": [ 1822 | "lib/cli/cli.php" 1823 | ], 1824 | "psr-0": { 1825 | "cli": "lib/" 1826 | } 1827 | }, 1828 | "notification-url": "https://packagist.org/downloads/", 1829 | "license": [ 1830 | "MIT" 1831 | ], 1832 | "authors": [ 1833 | { 1834 | "name": "Daniel Bachhuber", 1835 | "email": "daniel@handbuilt.co", 1836 | "role": "Maintainer" 1837 | }, 1838 | { 1839 | "name": "James Logsdon", 1840 | "email": "jlogsdon@php.net", 1841 | "role": "Developer" 1842 | } 1843 | ], 1844 | "description": "Console utilities for PHP", 1845 | "homepage": "http://github.com/wp-cli/php-cli-tools", 1846 | "keywords": [ 1847 | "cli", 1848 | "console" 1849 | ], 1850 | "support": { 1851 | "issues": "https://github.com/wp-cli/php-cli-tools/issues", 1852 | "source": "https://github.com/wp-cli/php-cli-tools/tree/v0.11.22" 1853 | }, 1854 | "time": "2023-12-03T19:25:05+00:00" 1855 | }, 1856 | { 1857 | "name": "wp-cli/wp-cli", 1858 | "version": "v2.10.0", 1859 | "source": { 1860 | "type": "git", 1861 | "url": "https://github.com/wp-cli/wp-cli.git", 1862 | "reference": "a339dca576df73c31af4b4d8054efc2dab9a0685" 1863 | }, 1864 | "dist": { 1865 | "type": "zip", 1866 | "url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/a339dca576df73c31af4b4d8054efc2dab9a0685", 1867 | "reference": "a339dca576df73c31af4b4d8054efc2dab9a0685", 1868 | "shasum": "" 1869 | }, 1870 | "require": { 1871 | "ext-curl": "*", 1872 | "mustache/mustache": "^2.14.1", 1873 | "php": "^5.6 || ^7.0 || ^8.0", 1874 | "symfony/finder": ">2.7", 1875 | "wp-cli/mustangostang-spyc": "^0.6.3", 1876 | "wp-cli/php-cli-tools": "~0.11.2" 1877 | }, 1878 | "require-dev": { 1879 | "roave/security-advisories": "dev-latest", 1880 | "wp-cli/db-command": "^1.3 || ^2", 1881 | "wp-cli/entity-command": "^1.2 || ^2", 1882 | "wp-cli/extension-command": "^1.1 || ^2", 1883 | "wp-cli/package-command": "^1 || ^2", 1884 | "wp-cli/wp-cli-tests": "^4.0.1" 1885 | }, 1886 | "suggest": { 1887 | "ext-readline": "Include for a better --prompt implementation", 1888 | "ext-zip": "Needed to support extraction of ZIP archives when doing downloads or updates" 1889 | }, 1890 | "bin": [ 1891 | "bin/wp", 1892 | "bin/wp.bat" 1893 | ], 1894 | "type": "library", 1895 | "extra": { 1896 | "branch-alias": { 1897 | "dev-main": "2.10.x-dev" 1898 | } 1899 | }, 1900 | "autoload": { 1901 | "psr-0": { 1902 | "WP_CLI\\": "php/" 1903 | }, 1904 | "classmap": [ 1905 | "php/class-wp-cli.php", 1906 | "php/class-wp-cli-command.php" 1907 | ] 1908 | }, 1909 | "notification-url": "https://packagist.org/downloads/", 1910 | "license": [ 1911 | "MIT" 1912 | ], 1913 | "description": "WP-CLI framework", 1914 | "homepage": "https://wp-cli.org", 1915 | "keywords": [ 1916 | "cli", 1917 | "wordpress" 1918 | ], 1919 | "support": { 1920 | "docs": "https://make.wordpress.org/cli/handbook/", 1921 | "issues": "https://github.com/wp-cli/wp-cli/issues", 1922 | "source": "https://github.com/wp-cli/wp-cli" 1923 | }, 1924 | "time": "2024-02-08T16:52:43+00:00" 1925 | }, 1926 | { 1927 | "name": "wp-coding-standards/wpcs", 1928 | "version": "3.1.0", 1929 | "source": { 1930 | "type": "git", 1931 | "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", 1932 | "reference": "9333efcbff231f10dfd9c56bb7b65818b4733ca7" 1933 | }, 1934 | "dist": { 1935 | "type": "zip", 1936 | "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/9333efcbff231f10dfd9c56bb7b65818b4733ca7", 1937 | "reference": "9333efcbff231f10dfd9c56bb7b65818b4733ca7", 1938 | "shasum": "" 1939 | }, 1940 | "require": { 1941 | "ext-filter": "*", 1942 | "ext-libxml": "*", 1943 | "ext-tokenizer": "*", 1944 | "ext-xmlreader": "*", 1945 | "php": ">=5.4", 1946 | "phpcsstandards/phpcsextra": "^1.2.1", 1947 | "phpcsstandards/phpcsutils": "^1.0.10", 1948 | "squizlabs/php_codesniffer": "^3.9.0" 1949 | }, 1950 | "require-dev": { 1951 | "php-parallel-lint/php-console-highlighter": "^1.0.0", 1952 | "php-parallel-lint/php-parallel-lint": "^1.3.2", 1953 | "phpcompatibility/php-compatibility": "^9.0", 1954 | "phpcsstandards/phpcsdevtools": "^1.2.0", 1955 | "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" 1956 | }, 1957 | "suggest": { 1958 | "ext-iconv": "For improved results", 1959 | "ext-mbstring": "For improved results" 1960 | }, 1961 | "type": "phpcodesniffer-standard", 1962 | "notification-url": "https://packagist.org/downloads/", 1963 | "license": [ 1964 | "MIT" 1965 | ], 1966 | "authors": [ 1967 | { 1968 | "name": "Contributors", 1969 | "homepage": "https://github.com/WordPress/WordPress-Coding-Standards/graphs/contributors" 1970 | } 1971 | ], 1972 | "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions", 1973 | "keywords": [ 1974 | "phpcs", 1975 | "standards", 1976 | "static analysis", 1977 | "wordpress" 1978 | ], 1979 | "support": { 1980 | "issues": "https://github.com/WordPress/WordPress-Coding-Standards/issues", 1981 | "source": "https://github.com/WordPress/WordPress-Coding-Standards", 1982 | "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki" 1983 | }, 1984 | "funding": [ 1985 | { 1986 | "url": "https://opencollective.com/php_codesniffer", 1987 | "type": "custom" 1988 | } 1989 | ], 1990 | "time": "2024-03-25T16:39:00+00:00" 1991 | } 1992 | ], 1993 | "aliases": [], 1994 | "minimum-stability": "stable", 1995 | "stability-flags": { 1996 | "wp-cli/dist-archive-command": 20 1997 | }, 1998 | "prefer-stable": false, 1999 | "prefer-lowest": false, 2000 | "platform": [], 2001 | "platform-dev": [], 2002 | "platform-overrides": { 2003 | "php": "7.4" 2004 | }, 2005 | "plugin-api-version": "2.3.0" 2006 | } 2007 | -------------------------------------------------------------------------------- /editor-styles.css: -------------------------------------------------------------------------------- 1 | .shcb-textedit.shcb-textedit-wrap-lines { 2 | overflow: auto !important; 3 | } 4 | 5 | .shcb-textedit.rich-text { 6 | white-space: pre !important; 7 | overflow-x: auto !important; 8 | } 9 | 10 | .shcb-textedit.rich-text.shcb-textedit-wrap-lines { 11 | white-space: pre-wrap !important; 12 | } 13 | 14 | .code-block-overlay { 15 | box-sizing: border-box; 16 | height: 100%; 17 | left: 0; 18 | padding: inherit; /* To match the padding in the parent since this is positioned absolutely */ 19 | pointer-events: none; 20 | position: absolute; 21 | top: 0; 22 | white-space: pre; 23 | width: 100%; 24 | z-index: 10; 25 | } 26 | 27 | .shcb-textedit-wrap-lines + .code-block-overlay { 28 | white-space: pre-wrap; 29 | } 30 | 31 | .code-block-overlay .loc { 32 | color: transparent; 33 | display: block; 34 | line-height: inherit; 35 | } 36 | 37 | .code-block-overlay .loc.highlighted { 38 | background: rgba(86, 213, 255, 0.2); 39 | } 40 | -------------------------------------------------------------------------------- /inc/functions.php: -------------------------------------------------------------------------------- 1 | $rgb_array['r'] + ( 255 - $rgb_array['r'] ) * $tint, 49 | 'g' => $rgb_array['g'] + ( 255 - $rgb_array['g'] ) * $tint, 50 | 'b' => $rgb_array['b'] + ( 255 - $rgb_array['b'] ) * $tint, 51 | ]; 52 | } 53 | 54 | /** 55 | * Get the relative luminance of a color. 56 | * 57 | * @link https://en.wikipedia.org/wiki/Relative_luminance 58 | * 59 | * @param float[] $rgb_array An array representing an RGB color. 60 | * @return float A value between 0 and 100 representing the luminance of a color. 61 | * The closer to 100, the higher the luminance is; i.e. the lighter it is. 62 | */ 63 | function get_relative_luminance( array $rgb_array ): float { 64 | return 0.2126 * ( $rgb_array['r'] / 255 ) + 65 | 0.7152 * ( $rgb_array['g'] / 255 ) + 66 | 0.0722 * ( $rgb_array['b'] / 255 ); 67 | } 68 | 69 | /** 70 | * Check whether a given RGB array is considered a "dark theme." 71 | * 72 | * @param float[] $rgb_array The RGB array to test. 73 | * @return bool True if the theme's background has a "dark" luminance. 74 | */ 75 | function is_dark_theme( array $rgb_array ): bool { 76 | return get_relative_luminance( $rgb_array ) <= 0.6; 77 | } 78 | 79 | /** 80 | * Convert an RGB array to hexadecimal representation. 81 | * 82 | * @param float[] $rgb_array The RGB array to convert. 83 | * @return string A hexadecimal representation. 84 | */ 85 | function get_hex_from_rgb( array $rgb_array ): string { 86 | return sprintf( 87 | '#%02X%02X%02X', 88 | $rgb_array['r'], 89 | $rgb_array['g'], 90 | $rgb_array['b'] 91 | ); 92 | } 93 | 94 | /** 95 | * Get the default highlighted line background color. 96 | * 97 | * In a dark theme, the background color is decided by adding a 15% tint to the 98 | * color. 99 | * 100 | * In a light theme, a default light blue is used. 101 | * 102 | * @param string $theme_name The theme name to get a color for. 103 | * @return string A hexadecimal value. 104 | */ 105 | function get_default_line_background_color( string $theme_name ): string { 106 | require_highlight_php_functions(); 107 | 108 | $theme_rgb = getThemeBackgroundColor( $theme_name ); 109 | 110 | if ( is_dark_theme( $theme_rgb ) ) { 111 | return get_hex_from_rgb( 112 | add_tint_to_rgb( $theme_rgb, 0.15 ) 113 | ); 114 | } 115 | 116 | return DEFAULT_HIGHLIGHTED_COLOR; 117 | } 118 | 119 | /** 120 | * Get an array of all the options tied to this plugin. 121 | * 122 | * @return array{ 123 | * theme_name: string, 124 | * highlighted_line_background_color: string 125 | * } 126 | */ 127 | function get_plugin_options(): array { 128 | $options = get_option( OPTION_NAME ); 129 | if ( ! is_array( $options ) ) { 130 | $options = []; 131 | } 132 | 133 | if ( isset( $options['theme_name'] ) && is_string( $options['theme_name'] ) ) { 134 | $theme_name = $options['theme_name']; 135 | } else { 136 | $theme_name = DEFAULT_THEME; 137 | } 138 | 139 | if ( isset( $options['highlighted_line_background_color'] ) && is_string( $options['highlighted_line_background_color'] ) ) { 140 | $highlighted_line_background_color = $options['highlighted_line_background_color']; 141 | } else { 142 | $highlighted_line_background_color = get_default_line_background_color( $theme_name ); 143 | } 144 | 145 | return compact( 'theme_name', 'highlighted_line_background_color' ); 146 | } 147 | 148 | /** 149 | * Get the single, specified plugin option. 150 | * 151 | * @param string $option_name The plugin option name. 152 | * @return string|null 153 | */ 154 | function get_plugin_option( string $option_name ): ?string { 155 | $options = get_plugin_options(); 156 | if ( array_key_exists( $option_name, $options ) ) { 157 | return $options[ $option_name ]; 158 | } 159 | return null; 160 | } 161 | 162 | /** 163 | * Require the highlight.php functions file. 164 | */ 165 | function require_highlight_php_functions(): void { 166 | require_once PLUGIN_DIR . '/' . get_highlight_php_vendor_path() . '/HighlightUtilities/functions.php'; 167 | } 168 | 169 | /** 170 | * Initialize plugin. 171 | * 172 | * As of Gutenberg 8.3, this must run after `init` priority 10, because at that point the core blocks are registered 173 | * server-side via `gutenberg_reregister_core_block_types()`. 174 | * 175 | * @see gutenberg_reregister_core_block_types() 176 | * @see https://github.com/WordPress/gutenberg/issues/2751 177 | * @see https://github.com/WordPress/gutenberg/pull/22491 178 | */ 179 | function init(): void { 180 | if ( ! function_exists( 'register_block_type' ) ) { 181 | return; 182 | } 183 | 184 | if ( DEVELOPMENT_MODE && ! file_exists( PLUGIN_DIR . '/build/index.asset.php' ) ) { 185 | add_action( 'admin_notices', __NAMESPACE__ . '\print_build_required_admin_notice' ); 186 | return; 187 | } 188 | 189 | $registry = WP_Block_Type_Registry::get_instance(); 190 | 191 | $block = $registry->get_registered( BLOCK_NAME ); 192 | if ( $block instanceof WP_Block_Type ) { 193 | $block->render_callback = __NAMESPACE__ . '\render_block'; 194 | $block->attributes = array_merge( $block->attributes ?? [], ATTRIBUTE_SCHEMA ); 195 | $block->style_handles = array_merge( $block->style_handles, STYLE_HANDLES ); 196 | } else { 197 | $block = register_block_type( 198 | BLOCK_NAME, 199 | [ 200 | 'render_callback' => __NAMESPACE__ . '\render_block', 201 | 'attributes' => ATTRIBUTE_SCHEMA, 202 | 'style_handles' => STYLE_HANDLES, 203 | ] 204 | ); 205 | } 206 | 207 | if ( $block instanceof WP_Block_Type ) { 208 | register_editor_assets( $block ); 209 | $block->editor_script_handles[] = EDITOR_SCRIPT_HANDLE; 210 | $block->editor_style_handles[] = EDITOR_STYLE_HANDLE; 211 | } 212 | } 213 | 214 | /** 215 | * Print admin notice when plugin installed from source but no build being performed. 216 | * 217 | * @noinspection PhpUnused -- See https://youtrack.jetbrains.com/issue/WI-22217/Extend-possible-linking-between-function-and-callback-using-different-constants-NAMESPACE-CLASS-and-class 218 | */ 219 | function print_build_required_admin_notice(): void { 220 | ?> 221 |
222 |

223 | : 224 | composer install && npm install && npm run build' 230 | ) 231 | ); 232 | ?> 233 |

234 |
235 | $block->name, 268 | 'attributes' => $block->attributes, 269 | 'deprecated' => [ 270 | 'selectedLines' => [ 271 | 'type' => 'string', 272 | 'default' => '', 273 | ], 274 | 'showLines' => [ 275 | 'type' => 'boolean', 276 | 'default' => false, 277 | ], 278 | ], 279 | ]; 280 | wp_add_inline_script( 281 | EDITOR_SCRIPT_HANDLE, 282 | sprintf( 'const syntaxHighlightingCodeBlockType = %s;', wp_json_encode( $data ) ), 283 | 'before' 284 | ); 285 | 286 | wp_add_inline_script( 287 | EDITOR_SCRIPT_HANDLE, 288 | sprintf( 'const syntaxHighlightingCodeBlockLanguageNames = %s;', wp_json_encode( get_language_names() ) ), 289 | 'before' 290 | ); 291 | } 292 | 293 | /** 294 | * Get highlight theme name. 295 | * 296 | * @return string Theme name or empty string if disabled. 297 | */ 298 | function get_theme_name(): string { 299 | if ( has_filter( BLOCK_STYLE_FILTER ) ) { 300 | /** 301 | * Filters the style used for the code syntax block. 302 | * 303 | * The string returned must correspond to the filenames found at , 304 | * minus the file extension. 305 | * 306 | * This filter takes precedence over any settings set in the database as an option. Additionally, if this filter 307 | * is provided, then a theme selector will not be provided in Customizer. 308 | * 309 | * @since 1.0.0 310 | * @param string $style Style. 311 | */ 312 | $style = apply_filters( BLOCK_STYLE_FILTER, DEFAULT_THEME ); 313 | if ( ! is_string( $style ) ) { 314 | $style = DEFAULT_THEME; 315 | } 316 | } else { 317 | $style = get_plugin_options()['theme_name']; 318 | } 319 | return is_string( $style ) ? $style : ''; 320 | } 321 | 322 | /** 323 | * Register styles for the frontend. 324 | * 325 | * @noinspection PhpUnused -- See https://youtrack.jetbrains.com/issue/WI-22217/Extend-possible-linking-between-function-and-callback-using-different-constants-NAMESPACE-CLASS-and-class 326 | */ 327 | function register_styles(): void { 328 | if ( ! is_styling_enabled() || is_admin() ) { // TODO: The same styling should be used in the admin. 329 | return; 330 | } 331 | $styles = wp_styles(); 332 | $theme = get_theme_name(); 333 | 334 | $theme_style_path = sprintf( 335 | '%s/styles/%s.css', 336 | get_highlight_php_vendor_path(), 337 | 0 === validate_file( $theme ) ? $theme : DEFAULT_THEME 338 | ); 339 | $styles->add( 340 | THEME_STYLE_HANDLE, 341 | plugins_url( $theme_style_path, PLUGIN_MAIN_FILE ), 342 | [], 343 | SCRIPT_DEBUG 344 | ? (string) filemtime( plugin_dir_path( PLUGIN_MAIN_FILE ) . $theme_style_path ) 345 | : PLUGIN_VERSION 346 | ); 347 | 348 | // TODO: Ideally this would be minified. 349 | $block_style_name = 'style.css'; 350 | $block_style_path = plugin_dir_path( PLUGIN_MAIN_FILE ) . $block_style_name; 351 | $styles->add( 352 | BLOCK_STYLE_HANDLE, 353 | plugins_url( $block_style_name, PLUGIN_MAIN_FILE ), 354 | [], 355 | SCRIPT_DEBUG 356 | ? (string) filemtime( $block_style_path ) 357 | : PLUGIN_VERSION 358 | ); 359 | wp_style_add_data( BLOCK_STYLE_HANDLE, 'path', $block_style_path ); 360 | 361 | if ( has_filter( HIGHLIGHTED_LINE_BACKGROUND_COLOR_FILTER ) ) { 362 | $default_line_color = get_default_line_background_color( DEFAULT_THEME ); 363 | /** 364 | * Filters the background color of a highlighted line. 365 | * 366 | * This filter takes precedence over any settings set in the database as an option. Additionally, if this filter 367 | * is provided, then a color selector will not be provided in Customizer. 368 | * 369 | * @param string $rgb_color An RGB hexadecimal (with the #) to be used as the background color of a highlighted line. 370 | * 371 | * @since 1.1.5 372 | */ 373 | $line_color = apply_filters( HIGHLIGHTED_LINE_BACKGROUND_COLOR_FILTER, $default_line_color ); 374 | if ( ! is_string( $line_color ) ) { 375 | $line_color = $default_line_color; 376 | } 377 | } else { 378 | $line_color = get_plugin_options()['highlighted_line_background_color']; 379 | } 380 | wp_add_inline_style( 381 | BLOCK_STYLE_HANDLE, 382 | /* language=CSS */ 383 | ".hljs > mark.shcb-loc { background-color: $line_color; }" 384 | ); 385 | } 386 | 387 | /** 388 | * Determines whether styling is enabled. 389 | * 390 | * @return bool Styling. 391 | */ 392 | function is_styling_enabled(): bool { 393 | /** 394 | * Filters whether the Syntax-highlighting Code Block's default styling is enabled. 395 | * 396 | * @param bool $enabled Default styling enabled. 397 | */ 398 | return (bool) apply_filters( 'syntax_highlighting_code_block_styling', true ); 399 | } 400 | 401 | /** 402 | * Language names. 403 | * 404 | * @return array Mapping slug to name. 405 | */ 406 | function get_language_names(): array { 407 | return require PLUGIN_DIR . '/language-names.php'; 408 | } 409 | 410 | /** 411 | * Inject class names and styles into the 412 | * 413 | * @param string $pre_start_tag The `
` start tag.
414 |  * @param string $code_start_tag The `` start tag.
415 |  * @param array{
416 |  *     language: string,
417 |  *     highlightedLines: string,
418 |  *     showLineNumbers: bool,
419 |  *     wrapLines: bool
420 |  * }             $attributes     Attributes.
421 |  * @param string $content        Content.
422 |  * @return string Injected markup.
423 |  */
424 | function inject_markup( string $pre_start_tag, string $code_start_tag, array $attributes, string $content ): string {
425 | 	$added_classes = 'hljs';
426 | 
427 | 	if ( $attributes['language'] ) {
428 | 		$added_classes .= " language-{$attributes['language']}";
429 | 	}
430 | 
431 | 	if ( $attributes['showLineNumbers'] || $attributes['highlightedLines'] ) {
432 | 		$added_classes .= ' shcb-code-table';
433 | 	}
434 | 
435 | 	if ( $attributes['showLineNumbers'] ) {
436 | 		$added_classes .= ' shcb-line-numbers';
437 | 	}
438 | 
439 | 	if ( $attributes['wrapLines'] ) {
440 | 		$added_classes .= ' shcb-wrap-lines';
441 | 	}
442 | 
443 | 	// @todo Update this to use WP_HTML_Tag_Processor.
444 | 	$code_start_tag = (string) preg_replace(
445 | 		'/(]*\sclass=")/',
446 | 		'$1' . esc_attr( $added_classes ) . ' ',
447 | 		$code_start_tag,
448 | 		1,
449 | 		$count
450 | 	);
451 | 	if ( 0 === $count ) {
452 | 		$code_start_tag = (string) preg_replace(
453 | 			'/(?<=%s %s (%s)',
472 | 			esc_attr( $element_id ),
473 | 			esc_html__( 'Code language:', 'syntax-highlighting-code-block' ),
474 | 			esc_html( $language_name ),
475 | 			esc_html( $attributes['language'] )
476 | 		);
477 | 
478 | 		// Also include the language in data attributes on the root 
 element for maximum styling flexibility.
479 | 		$pre_start_tag = str_replace(
480 | 			'>',
481 | 			sprintf(
482 | 				' aria-describedby="%s" data-shcb-language-name="%s" data-shcb-language-slug="%s">',
483 | 				esc_attr( $element_id ),
484 | 				esc_attr( $language_name ),
485 | 				esc_attr( $attributes['language'] )
486 | 			),
487 | 			$pre_start_tag
488 | 		);
489 | 	}
490 | 	$end_tags .= '
'; 491 | 492 | return $pre_start_tag . '' . $code_start_tag . escape( $content ) . $end_tags; 493 | } 494 | 495 | /** 496 | * Escape content. 497 | * 498 | * In order to prevent WordPress the_content filters from rendering embeds/shortcodes, it's important 499 | * to re-escape the content in the same way as the editor is doing with the Code block's save function. 500 | * Note this does not need to escape ampersands because they will already be escaped by highlight.php. 501 | * Also, escaping of ampersands was removed in 502 | * once HTML editing of Code blocks was implemented. 503 | * 504 | * @link 505 | * @link 506 | * @link 507 | * 508 | * @param string $content Highlighted content. 509 | * @return string Escaped content. 510 | */ 511 | function escape( string $content ): string { 512 | // See escapeOpeningSquareBrackets: . 513 | $content = str_replace( '[', '[', $content ); 514 | 515 | // See escapeProtocolInIsolatedUrls: . 516 | return (string) preg_replace( '/^(\s*https?:)\/\/([^\s<>"]+\s*)$/m', '$1//$2', $content ); 517 | } 518 | 519 | /** 520 | * Get transient key. 521 | * 522 | * Returns null if key cannot be computed. 523 | * 524 | * @param string $content Content. 525 | * @param array{ 526 | * language: string, 527 | * highlightedLines: string, 528 | * showLineNumbers: bool, 529 | * wrapLines: bool 530 | * } $attributes Attributes. 531 | * @param bool $is_feed Is feed. 532 | * @param string[] $auto_detect_languages Auto-detect languages. 533 | * 534 | * @return string|null Transient key. 535 | */ 536 | function get_transient_key( string $content, array $attributes, bool $is_feed, array $auto_detect_languages ): ?string { 537 | $hash_input = wp_json_encode( 538 | [ 539 | 'content' => $content, 540 | 'attributes' => $attributes, 541 | 'is_feed' => $is_feed, // TODO: This is obsolete. 542 | 'auto_detect_languages' => $auto_detect_languages, 543 | 'version' => PLUGIN_VERSION, 544 | ] 545 | ); 546 | if ( ! is_string( $hash_input ) ) { 547 | return null; 548 | } 549 | return 'shcb-' . md5( $hash_input ); 550 | } 551 | 552 | /** 553 | * Render code block. 554 | * 555 | * @param array{ 556 | * language: string, 557 | * highlightedLines: string, 558 | * showLineNumbers: bool, 559 | * wrapLines: bool, 560 | * selectedLines?: string, 561 | * showLines?: bool 562 | * } $attributes Attributes. 563 | * @param string $content Content. 564 | * @return string Highlighted content. 565 | */ 566 | function render_block( array $attributes, string $content ): string { 567 | $pattern = '(?P]*?>)(?P]*?>)'; 568 | $pattern .= '(?P.*)'; 569 | $pattern .= '
'; 570 | 571 | if ( ! preg_match( '#^\s*' . $pattern . '\s*$#s', $content, $matches ) ) { 572 | return $content; 573 | } 574 | 575 | // Migrate legacy attribute names. 576 | if ( isset( $attributes['selectedLines'] ) ) { 577 | $attributes['highlightedLines'] = $attributes['selectedLines']; 578 | unset( $attributes['selectedLines'] ); 579 | } 580 | if ( isset( $attributes['showLines'] ) ) { 581 | $attributes['showLineNumbers'] = $attributes['showLines']; 582 | unset( $attributes['showLines'] ); 583 | } 584 | 585 | /** 586 | * Filters the list of languages that are used for auto-detection. 587 | * 588 | * @param string[] $auto_detect_language Auto-detect languages. 589 | */ 590 | $auto_detect_languages = apply_filters( 'syntax_highlighting_code_block_auto_detect_languages', [] ); 591 | if ( ! is_array( $auto_detect_languages ) ) { 592 | $auto_detect_languages = []; 593 | } 594 | $auto_detect_languages = array_filter( $auto_detect_languages, 'is_string' ); 595 | 596 | // Use the previously-highlighted content if cached. 597 | $transient_key = ! DEVELOPMENT_MODE ? get_transient_key( $matches['content'], $attributes, is_feed(), $auto_detect_languages ) : null; 598 | $highlighted = $transient_key ? get_transient( $transient_key ) : null; 599 | if ( 600 | is_array( $highlighted ) 601 | && 602 | isset( $highlighted['content'] ) && is_string( $highlighted['content'] ) 603 | && 604 | is_array( $highlighted['attributes'] ) 605 | && 606 | isset( $highlighted['attributes']['language'] ) && is_string( $highlighted['attributes']['language'] ) 607 | && 608 | isset( $highlighted['attributes']['highlightedLines'] ) && is_string( $highlighted['attributes']['highlightedLines'] ) 609 | && 610 | isset( $highlighted['attributes']['showLineNumbers'] ) && is_bool( $highlighted['attributes']['showLineNumbers'] ) 611 | && 612 | isset( $highlighted['attributes']['wrapLines'] ) && is_bool( $highlighted['attributes']['wrapLines'] ) 613 | ) { 614 | return inject_markup( $matches['pre_start_tag'], $matches['code_start_tag'], $highlighted['attributes'], $highlighted['content'] ); 615 | } 616 | 617 | try { 618 | if ( ! class_exists( '\Highlight\Autoloader' ) ) { 619 | require_once PLUGIN_DIR . '/' . get_highlight_php_vendor_path() . '/Highlight/Autoloader.php'; 620 | spl_autoload_register( 'Highlight\Autoloader::load' ); 621 | } 622 | 623 | $highlighter = new Highlighter(); 624 | if ( ! empty( $auto_detect_languages ) ) { 625 | $highlighter->setAutodetectLanguages( $auto_detect_languages ); 626 | } 627 | 628 | $language = $attributes['language']; 629 | 630 | // As of Gutenberg 17.1, line breaks in Code blocks are serialized as
tags whereas previously they were newlines. 631 | $content = str_replace( '
', "\n", $matches['content'] ); 632 | 633 | // Note that the decoding here is reversed later in the escape() function. 634 | // @todo Now that Code blocks may have markup (e.g. bolding, italics, and hyperlinks), these need to be removed and then restored after highlighting is completed. 635 | $content = html_entity_decode( $content, ENT_QUOTES ); 636 | 637 | // Convert from Prism.js languages names. 638 | if ( 'clike' === $language ) { 639 | $language = 'cpp'; 640 | } elseif ( 'git' === $language ) { 641 | $language = 'diff'; // Best match. 642 | } elseif ( 'markup' === $language ) { 643 | $language = 'xml'; 644 | } 645 | 646 | if ( $language ) { 647 | $r = $highlighter->highlight( $language, $content ); 648 | } else { 649 | $r = $highlighter->highlightAuto( $content ); 650 | } 651 | $attributes['language'] = $r->language; 652 | 653 | $content = $r->value; 654 | if ( $attributes['showLineNumbers'] || $attributes['highlightedLines'] ) { 655 | require_highlight_php_functions(); 656 | 657 | $highlighted_lines = parse_highlighted_lines( $attributes['highlightedLines'] ); 658 | $lines = split_code_into_array( $content ); 659 | $content = ''; 660 | 661 | // We need to wrap the line of code twice in order to let out `white-space: pre` CSS setting to be respected 662 | // by our `table-row`. 663 | foreach ( $lines as $i => $line ) { 664 | $tag_name = in_array( $i, $highlighted_lines, true ) ? 'mark' : 'span'; 665 | $content .= "<$tag_name class='shcb-loc'>$line\n"; 666 | } 667 | } 668 | 669 | if ( $transient_key ) { 670 | set_transient( $transient_key, compact( 'content', 'attributes' ), MONTH_IN_SECONDS ); 671 | } 672 | 673 | return inject_markup( $matches['pre_start_tag'], $matches['code_start_tag'], $attributes, $content ); 674 | } catch ( Exception $e ) { 675 | return sprintf( 676 | '%s', 677 | get_class( $e ), 678 | $e->getCode(), 679 | str_replace( '--', '', $e->getMessage() ), 680 | $content 681 | ); 682 | } 683 | } 684 | 685 | /** 686 | * Split code into an array. 687 | * 688 | * @param string $code Code to split. 689 | * @return string[] Lines. 690 | * @throws Exception If an error occurred in splitting up by lines. 691 | */ 692 | function split_code_into_array( string $code ): array { 693 | $lines = splitCodeIntoArray( $code ); 694 | if ( ! is_array( $lines ) ) { 695 | throw new Exception( 'Unable to split code into array.' ); 696 | } 697 | return $lines; 698 | } 699 | 700 | /** 701 | * Parse the highlighted line syntax from the front-end and return an array of highlighted line numbers. 702 | * 703 | * @param string $highlighted_lines The highlighted line syntax. 704 | * @return int[] 705 | */ 706 | function parse_highlighted_lines( string $highlighted_lines ): array { 707 | $highlighted_line_numbers = []; 708 | 709 | if ( ! $highlighted_lines || empty( trim( $highlighted_lines ) ) ) { 710 | return $highlighted_line_numbers; 711 | } 712 | 713 | $ranges = explode( ',', (string) preg_replace( '/\s/', '', $highlighted_lines ) ); 714 | 715 | foreach ( $ranges as $chunk ) { 716 | if ( strpos( $chunk, '-' ) !== false ) { 717 | $range = explode( '-', $chunk ); 718 | 719 | if ( count( $range ) === 2 ) { 720 | for ( $i = (int) $range[0]; $i <= (int) $range[1]; $i++ ) { 721 | $highlighted_line_numbers[] = $i - 1; 722 | } 723 | } 724 | } else { 725 | $highlighted_line_numbers[] = (int) $chunk - 1; 726 | } 727 | } 728 | 729 | return $highlighted_line_numbers; 730 | } 731 | 732 | /** 733 | * Validate the given stylesheet name against available stylesheets. 734 | * 735 | * @param WP_Error $validity Validator object. 736 | * @param string $input Incoming theme name. 737 | * @return WP_Error Amended errors. 738 | */ 739 | function validate_theme_name( WP_Error $validity, string $input ): WP_Error { 740 | require_highlight_php_functions(); 741 | 742 | $themes = getAvailableStyleSheets(); 743 | 744 | if ( ! in_array( $input, $themes, true ) ) { 745 | $validity->add( 'invalid_theme', __( 'Unrecognized theme', 'syntax-highlighting-code-block' ) ); 746 | } 747 | 748 | return $validity; 749 | } 750 | 751 | /** 752 | * Add plugin settings to Customizer. 753 | * 754 | * @param WP_Customize_Manager $wp_customize The Customizer object. 755 | */ 756 | function customize_register( WP_Customize_Manager $wp_customize ): void { 757 | if ( has_filter( BLOCK_STYLE_FILTER ) && has_filter( HIGHLIGHTED_LINE_BACKGROUND_COLOR_FILTER ) ) { 758 | return; 759 | } 760 | 761 | if ( ! is_styling_enabled() ) { 762 | return; 763 | } 764 | 765 | require_highlight_php_functions(); 766 | 767 | $theme_name = get_theme_name(); 768 | 769 | if ( ! has_filter( BLOCK_STYLE_FILTER ) ) { 770 | $themes = getAvailableStyleSheets(); 771 | sort( $themes ); 772 | $choices = array_combine( $themes, $themes ); 773 | 774 | $setting = $wp_customize->add_setting( 775 | 'syntax_highlighting[theme_name]', 776 | [ 777 | 'type' => 'option', 778 | 'default' => DEFAULT_THEME, 779 | 'validate_callback' => __NAMESPACE__ . '\validate_theme_name', 780 | ] 781 | ); 782 | 783 | // Obtain the working theme name in the changeset. 784 | /** 785 | * Theme name sanitized by Customizer setting callback & default 786 | * 787 | * @var string $theme_name 788 | */ 789 | $theme_name = $setting->post_value( $theme_name ); 790 | 791 | $wp_customize->add_control( 792 | 'syntax_highlighting[theme_name]', 793 | [ 794 | 'type' => 'select', 795 | 'section' => 'colors', 796 | 'label' => __( 'Syntax Highlighting Theme', 'syntax-highlighting-code-block' ), 797 | 'description' => __( 'Preview the theme by navigating to a page with a Code block to see the different themes in action.', 'syntax-highlighting-code-block' ), 798 | 'choices' => $choices, 799 | ] 800 | ); 801 | } 802 | 803 | if ( ! has_filter( HIGHLIGHTED_LINE_BACKGROUND_COLOR_FILTER ) && $theme_name ) { 804 | $default_color = strtolower( get_default_line_background_color( $theme_name ) ); 805 | $wp_customize->add_setting( 806 | 'syntax_highlighting[highlighted_line_background_color]', 807 | [ 808 | 'type' => 'option', 809 | 'default' => $default_color, 810 | 'sanitize_callback' => 'sanitize_hex_color', 811 | ] 812 | ); 813 | $wp_customize->add_control( 814 | new WP_Customize_Color_Control( 815 | $wp_customize, 816 | 'syntax_highlighting[highlighted_line_background_color]', 817 | [ 818 | 'section' => 'colors', 819 | 'setting' => 'syntax_highlighting[highlighted_line_background_color]', 820 | 'label' => __( 'Highlighted Line Color', 'syntax-highlighting-code-block' ), 821 | 'description' => __( 'The background color of a highlighted line in a Code block.', 'syntax-highlighting-code-block' ), 822 | ] 823 | ) 824 | ); 825 | 826 | // Add the script to synchronize the default highlighting line color with the selected theme. 827 | if ( ! has_filter( BLOCK_STYLE_FILTER ) ) { 828 | add_action( 'customize_controls_enqueue_scripts', __NAMESPACE__ . '\enqueue_customize_scripts' ); 829 | } 830 | } 831 | } 832 | 833 | /** 834 | * Enqueue scripts for Customizer. 835 | * 836 | * @noinspection PhpUnused -- See https://youtrack.jetbrains.com/issue/WI-22217/Extend-possible-linking-between-function-and-callback-using-different-constants-NAMESPACE-CLASS-and-class 837 | */ 838 | function enqueue_customize_scripts(): void { 839 | $script_handle = 'syntax-highlighting-code-block-customize-controls'; 840 | $script_path = '/build/customize-controls.js'; 841 | $script_asset = require PLUGIN_DIR . '/build/customize-controls.asset.php'; 842 | 843 | wp_enqueue_script( 844 | $script_handle, 845 | plugins_url( $script_path, PLUGIN_MAIN_FILE ), 846 | array_merge( [ 'customize-controls' ], $script_asset['dependencies'] ), 847 | $script_asset['version'], 848 | true 849 | ); 850 | } 851 | 852 | /** 853 | * Register REST endpoint. 854 | * 855 | * @noinspection PhpUnused -- See https://youtrack.jetbrains.com/issue/WI-22217/Extend-possible-linking-between-function-and-callback-using-different-constants-NAMESPACE-CLASS-and-class 856 | */ 857 | function register_rest_endpoint(): void { 858 | register_rest_route( 859 | REST_API_NAMESPACE, 860 | '/highlighted-line-background-color/(?P[^/]+)', 861 | [ 862 | 'methods' => WP_REST_Server::READABLE, 863 | 'permission_callback' => static function () { 864 | return current_user_can( 'customize' ); 865 | }, 866 | 'callback' => static function ( WP_REST_Request $request ) { 867 | $theme_name = $request['theme_name']; 868 | $validity = validate_theme_name( new WP_Error(), $theme_name ); 869 | if ( $validity->errors ) { 870 | return $validity; 871 | } 872 | return new WP_REST_Response( get_default_line_background_color( $theme_name ) ); 873 | }, 874 | ] 875 | ); 876 | } 877 | 878 | /** 879 | * Gets relative path to highlight.php library in vendor directory. 880 | * 881 | * @return string Relative path. 882 | */ 883 | function get_highlight_php_vendor_path(): string { 884 | if ( DEVELOPMENT_MODE && file_exists( PLUGIN_DIR . '/vendor/scrivo/highlight.php' ) ) { 885 | return 'vendor/scrivo/highlight.php'; 886 | } else { 887 | return 'vendor/scrivo/highlight-php'; 888 | } 889 | } 890 | -------------------------------------------------------------------------------- /language-names.php: -------------------------------------------------------------------------------- 1 | __( '1C:Enterprise (v7, v8)', 'syntax-highlighting-code-block' ), 6 | 'abnf' => __( 'Augmented Backus-Naur Form', 'syntax-highlighting-code-block' ), 7 | 'accesslog' => __( 'Access log', 'syntax-highlighting-code-block' ), 8 | 'actionscript' => __( 'ActionScript', 'syntax-highlighting-code-block' ), 9 | 'ada' => __( 'Ada', 'syntax-highlighting-code-block' ), 10 | 'angelscript' => __( 'AngelScript', 'syntax-highlighting-code-block' ), 11 | 'apache' => __( 'Apache', 'syntax-highlighting-code-block' ), 12 | 'applescript' => __( 'AppleScript', 'syntax-highlighting-code-block' ), 13 | 'arcade' => __( 'ArcGIS Arcade', 'syntax-highlighting-code-block' ), 14 | 'arduino' => __( 'Arduino', 'syntax-highlighting-code-block' ), 15 | 'armasm' => __( 'ARM Assembly', 'syntax-highlighting-code-block' ), 16 | 'asciidoc' => __( 'AsciiDoc', 'syntax-highlighting-code-block' ), 17 | 'aspectj' => __( 'AspectJ', 'syntax-highlighting-code-block' ), 18 | 'autohotkey' => __( 'AutoHotkey', 'syntax-highlighting-code-block' ), 19 | 'autoit' => __( 'AutoIt', 'syntax-highlighting-code-block' ), 20 | 'avrasm' => __( 'AVR Assembler', 'syntax-highlighting-code-block' ), 21 | 'awk' => __( 'Awk', 'syntax-highlighting-code-block' ), 22 | 'axapta' => __( 'Microsoft Axapta (now Dynamics 365)', 'syntax-highlighting-code-block' ), 23 | 'bash' => __( 'Bash', 'syntax-highlighting-code-block' ), 24 | 'basic' => __( 'Basic', 'syntax-highlighting-code-block' ), 25 | 'bnf' => __( 'Backus–Naur Form', 'syntax-highlighting-code-block' ), 26 | 'brainfuck' => __( 'Brainfuck', 'syntax-highlighting-code-block' ), 27 | 'cal' => __( 'C/AL', 'syntax-highlighting-code-block' ), 28 | 'capnproto' => __( 'Cap’n Proto', 'syntax-highlighting-code-block' ), 29 | 'ceylon' => __( 'Ceylon', 'syntax-highlighting-code-block' ), 30 | 'clean' => __( 'Clean', 'syntax-highlighting-code-block' ), 31 | 'clojure-repl' => __( 'Clojure REPL', 'syntax-highlighting-code-block' ), 32 | 'clojure' => __( 'Clojure', 'syntax-highlighting-code-block' ), 33 | 'cmake' => __( 'CMake', 'syntax-highlighting-code-block' ), 34 | 'coffeescript' => __( 'CoffeeScript', 'syntax-highlighting-code-block' ), 35 | 'coq' => __( 'Coq', 'syntax-highlighting-code-block' ), 36 | 'cos' => __( 'Caché Object Script', 'syntax-highlighting-code-block' ), 37 | 'cpp' => __( 'C++', 'syntax-highlighting-code-block' ), 38 | 'crmsh' => __( 'crmsh', 'syntax-highlighting-code-block' ), 39 | 'crystal' => __( 'Crystal', 'syntax-highlighting-code-block' ), 40 | 'cs' => __( 'C#', 'syntax-highlighting-code-block' ), 41 | 'csp' => __( 'CSP', 'syntax-highlighting-code-block' ), 42 | 'css' => __( 'CSS', 'syntax-highlighting-code-block' ), 43 | 'd' => __( 'D', 'syntax-highlighting-code-block' ), 44 | 'dart' => __( 'Dart', 'syntax-highlighting-code-block' ), 45 | 'delphi' => __( 'Delphi', 'syntax-highlighting-code-block' ), 46 | 'diff' => __( 'Diff', 'syntax-highlighting-code-block' ), 47 | 'django' => __( 'Django', 'syntax-highlighting-code-block' ), 48 | 'dns' => __( 'DNS Zone file', 'syntax-highlighting-code-block' ), 49 | 'dockerfile' => __( 'Dockerfile', 'syntax-highlighting-code-block' ), 50 | 'dos' => __( 'DOS .bat', 'syntax-highlighting-code-block' ), 51 | 'dsconfig' => __( 'dsconfig', 'syntax-highlighting-code-block' ), 52 | 'dts' => __( 'Device Tree', 'syntax-highlighting-code-block' ), 53 | 'dust' => __( 'Dust', 'syntax-highlighting-code-block' ), 54 | 'ebnf' => __( 'Extended Backus-Naur Form', 'syntax-highlighting-code-block' ), 55 | 'elixir' => __( 'Elixir', 'syntax-highlighting-code-block' ), 56 | 'elm' => __( 'Elm', 'syntax-highlighting-code-block' ), 57 | 'erb' => __( 'ERB (Embedded Ruby)', 'syntax-highlighting-code-block' ), 58 | 'erlang-repl' => __( 'Erlang REPL', 'syntax-highlighting-code-block' ), 59 | 'erlang' => __( 'Erlang', 'syntax-highlighting-code-block' ), 60 | 'excel' => __( 'Excel', 'syntax-highlighting-code-block' ), 61 | 'fix' => __( 'FIX', 'syntax-highlighting-code-block' ), 62 | 'flix' => __( 'Flix', 'syntax-highlighting-code-block' ), 63 | 'fortran' => __( 'Fortran', 'syntax-highlighting-code-block' ), 64 | 'fsharp' => __( 'F#', 'syntax-highlighting-code-block' ), 65 | 'gams' => __( 'GAMS', 'syntax-highlighting-code-block' ), 66 | 'gauss' => __( 'GAUSS', 'syntax-highlighting-code-block' ), 67 | 'gcode' => __( 'G-code (ISO 6983)', 'syntax-highlighting-code-block' ), 68 | 'gherkin' => __( 'Gherkin', 'syntax-highlighting-code-block' ), 69 | 'glsl' => __( 'GLSL', 'syntax-highlighting-code-block' ), 70 | 'gml' => __( 'GML', 'syntax-highlighting-code-block' ), 71 | 'go' => __( 'Go', 'syntax-highlighting-code-block' ), 72 | 'golo' => __( 'Golo', 'syntax-highlighting-code-block' ), 73 | 'gradle' => __( 'Gradle', 'syntax-highlighting-code-block' ), 74 | 'groovy' => __( 'Groovy', 'syntax-highlighting-code-block' ), 75 | 'haml' => __( 'Haml', 'syntax-highlighting-code-block' ), 76 | 'handlebars' => __( 'Handlebars', 'syntax-highlighting-code-block' ), 77 | 'haskell' => __( 'Haskell', 'syntax-highlighting-code-block' ), 78 | 'haxe' => __( 'Haxe', 'syntax-highlighting-code-block' ), 79 | 'hsp' => __( 'HSP', 'syntax-highlighting-code-block' ), 80 | 'htmlbars' => __( 'HTMLBars', 'syntax-highlighting-code-block' ), 81 | 'http' => __( 'HTTP', 'syntax-highlighting-code-block' ), 82 | 'hy' => __( 'Hy', 'syntax-highlighting-code-block' ), 83 | 'inform7' => __( 'Inform 7', 'syntax-highlighting-code-block' ), 84 | 'ini' => __( 'TOML, also INI', 'syntax-highlighting-code-block' ), 85 | 'irpf90' => __( 'IRPF90', 'syntax-highlighting-code-block' ), 86 | 'isbl' => __( 'ISBL', 'syntax-highlighting-code-block' ), 87 | 'java' => __( 'Java', 'syntax-highlighting-code-block' ), 88 | 'javascript' => __( 'JavaScript', 'syntax-highlighting-code-block' ), 89 | 'jboss-cli' => __( 'jboss-cli', 'syntax-highlighting-code-block' ), 90 | 'json' => __( 'JSON / JSON with Comments', 'syntax-highlighting-code-block' ), 91 | 'julia-repl' => __( 'Julia REPL', 'syntax-highlighting-code-block' ), 92 | 'julia' => __( 'Julia', 'syntax-highlighting-code-block' ), 93 | 'kotlin' => __( 'Kotlin', 'syntax-highlighting-code-block' ), 94 | 'lasso' => __( 'Lasso', 'syntax-highlighting-code-block' ), 95 | 'ldif' => __( 'LDIF', 'syntax-highlighting-code-block' ), 96 | 'leaf' => __( 'Leaf', 'syntax-highlighting-code-block' ), 97 | 'less' => __( 'Less', 'syntax-highlighting-code-block' ), 98 | 'lisp' => __( 'Lisp', 'syntax-highlighting-code-block' ), 99 | 'livecodeserver' => __( 'LiveCode', 'syntax-highlighting-code-block' ), 100 | 'livescript' => __( 'LiveScript', 'syntax-highlighting-code-block' ), 101 | 'llvm' => __( 'LLVM IR', 'syntax-highlighting-code-block' ), 102 | 'lsl' => __( 'LSL (Linden Scripting Language)', 'syntax-highlighting-code-block' ), 103 | 'lua' => __( 'Lua', 'syntax-highlighting-code-block' ), 104 | 'makefile' => __( 'Makefile', 'syntax-highlighting-code-block' ), 105 | 'markdown' => __( 'Markdown', 'syntax-highlighting-code-block' ), 106 | 'mathematica' => __( 'Mathematica', 'syntax-highlighting-code-block' ), 107 | 'matlab' => __( 'Matlab', 'syntax-highlighting-code-block' ), 108 | 'maxima' => __( 'Maxima', 'syntax-highlighting-code-block' ), 109 | 'mel' => __( 'MEL', 'syntax-highlighting-code-block' ), 110 | 'mercury' => __( 'Mercury', 'syntax-highlighting-code-block' ), 111 | 'mipsasm' => __( 'MIPS Assembly', 'syntax-highlighting-code-block' ), 112 | 'mizar' => __( 'Mizar', 'syntax-highlighting-code-block' ), 113 | 'mojolicious' => __( 'Mojolicious', 'syntax-highlighting-code-block' ), 114 | 'monkey' => __( 'Monkey', 'syntax-highlighting-code-block' ), 115 | 'moonscript' => __( 'MoonScript', 'syntax-highlighting-code-block' ), 116 | 'n1ql' => __( 'N1QL', 'syntax-highlighting-code-block' ), 117 | 'nginx' => __( 'Nginx', 'syntax-highlighting-code-block' ), 118 | 'nimrod' => __( 'Nim (formerly Nimrod)', 'syntax-highlighting-code-block' ), 119 | 'nix' => __( 'Nix', 'syntax-highlighting-code-block' ), 120 | 'nsis' => __( 'NSIS', 'syntax-highlighting-code-block' ), 121 | 'objectivec' => __( 'Objective-C', 'syntax-highlighting-code-block' ), 122 | 'ocaml' => __( 'OCaml', 'syntax-highlighting-code-block' ), 123 | 'openscad' => __( 'OpenSCAD', 'syntax-highlighting-code-block' ), 124 | 'oxygene' => __( 'Oxygene', 'syntax-highlighting-code-block' ), 125 | 'parser3' => __( 'Parser3', 'syntax-highlighting-code-block' ), 126 | 'perl' => __( 'Perl', 'syntax-highlighting-code-block' ), 127 | 'pf' => __( 'pf.conf', 'syntax-highlighting-code-block' ), 128 | 'pgsql' => __( 'PostgreSQL SQL dialect and PL/pgSQL', 'syntax-highlighting-code-block' ), 129 | 'php' => __( 'PHP', 'syntax-highlighting-code-block' ), 130 | 'plaintext' => __( 'plaintext', 'syntax-highlighting-code-block' ), 131 | 'pony' => __( 'Pony', 'syntax-highlighting-code-block' ), 132 | 'powershell' => __( 'PowerShell', 'syntax-highlighting-code-block' ), 133 | 'processing' => __( 'Processing', 'syntax-highlighting-code-block' ), 134 | 'profile' => __( 'Python profile', 'syntax-highlighting-code-block' ), 135 | 'prolog' => __( 'Prolog', 'syntax-highlighting-code-block' ), 136 | 'properties' => __( 'Properties', 'syntax-highlighting-code-block' ), 137 | 'protobuf' => __( 'Protocol Buffers', 'syntax-highlighting-code-block' ), 138 | 'puppet' => __( 'Puppet', 'syntax-highlighting-code-block' ), 139 | 'purebasic' => __( 'PureBASIC', 'syntax-highlighting-code-block' ), 140 | 'python' => __( 'Python', 'syntax-highlighting-code-block' ), 141 | 'q' => __( 'Q', 'syntax-highlighting-code-block' ), 142 | 'qml' => __( 'QML', 'syntax-highlighting-code-block' ), 143 | 'r' => __( 'R', 'syntax-highlighting-code-block' ), 144 | 'reasonml' => __( 'ReasonML', 'syntax-highlighting-code-block' ), 145 | 'rib' => __( 'RenderMan RIB', 'syntax-highlighting-code-block' ), 146 | 'roboconf' => __( 'Roboconf', 'syntax-highlighting-code-block' ), 147 | 'routeros' => __( 'Microtik RouterOS script', 'syntax-highlighting-code-block' ), 148 | 'rsl' => __( 'RenderMan RSL', 'syntax-highlighting-code-block' ), 149 | 'ruby' => __( 'Ruby', 'syntax-highlighting-code-block' ), 150 | 'ruleslanguage' => __( 'Oracle Rules Language', 'syntax-highlighting-code-block' ), 151 | 'rust' => __( 'Rust', 'syntax-highlighting-code-block' ), 152 | 'sas' => __( 'SAS', 'syntax-highlighting-code-block' ), 153 | 'scala' => __( 'Scala', 'syntax-highlighting-code-block' ), 154 | 'scheme' => __( 'Scheme', 'syntax-highlighting-code-block' ), 155 | 'scilab' => __( 'Scilab', 'syntax-highlighting-code-block' ), 156 | 'scss' => __( 'SCSS', 'syntax-highlighting-code-block' ), 157 | 'shell' => __( 'Shell Session', 'syntax-highlighting-code-block' ), 158 | 'smali' => __( 'Smali', 'syntax-highlighting-code-block' ), 159 | 'smalltalk' => __( 'Smalltalk', 'syntax-highlighting-code-block' ), 160 | 'sml' => __( 'SML (Standard ML)', 'syntax-highlighting-code-block' ), 161 | 'sqf' => __( 'SQF', 'syntax-highlighting-code-block' ), 162 | 'sql' => __( 'SQL (Structured Query Language)', 'syntax-highlighting-code-block' ), 163 | 'stan' => __( 'Stan', 'syntax-highlighting-code-block' ), 164 | 'stata' => __( 'Stata', 'syntax-highlighting-code-block' ), 165 | 'step21' => __( 'STEP Part 21', 'syntax-highlighting-code-block' ), 166 | 'stylus' => __( 'Stylus', 'syntax-highlighting-code-block' ), 167 | 'subunit' => __( 'SubUnit', 'syntax-highlighting-code-block' ), 168 | 'swift' => __( 'Swift', 'syntax-highlighting-code-block' ), 169 | 'taggerscript' => __( 'Tagger Script', 'syntax-highlighting-code-block' ), 170 | 'tap' => __( 'Test Anything Protocol', 'syntax-highlighting-code-block' ), 171 | 'tcl' => __( 'Tcl', 'syntax-highlighting-code-block' ), 172 | 'tex' => __( 'TeX', 'syntax-highlighting-code-block' ), 173 | 'thrift' => __( 'Thrift', 'syntax-highlighting-code-block' ), 174 | 'tp' => __( 'TP', 'syntax-highlighting-code-block' ), 175 | 'twig' => __( 'Twig', 'syntax-highlighting-code-block' ), 176 | 'typescript' => __( 'TypeScript', 'syntax-highlighting-code-block' ), 177 | 'vala' => __( 'Vala', 'syntax-highlighting-code-block' ), 178 | 'vbnet' => __( 'VB.NET', 'syntax-highlighting-code-block' ), 179 | 'vbscript-html' => __( 'VBScript in HTML', 'syntax-highlighting-code-block' ), 180 | 'vbscript' => __( 'VBScript', 'syntax-highlighting-code-block' ), 181 | 'verilog' => __( 'Verilog', 'syntax-highlighting-code-block' ), 182 | 'vhdl' => __( 'VHDL', 'syntax-highlighting-code-block' ), 183 | 'vim' => __( 'Vim Script', 'syntax-highlighting-code-block' ), 184 | 'x86asm' => __( 'Intel x86 Assembly', 'syntax-highlighting-code-block' ), 185 | 'xl' => __( 'XL', 'syntax-highlighting-code-block' ), 186 | 'xml' => __( 'HTML, XML', 'syntax-highlighting-code-block' ), 187 | 'xquery' => __( 'XQuery', 'syntax-highlighting-code-block' ), 188 | 'yaml' => __( 'YAML', 'syntax-highlighting-code-block' ), 189 | 'zephir' => __( 'Zephir', 'syntax-highlighting-code-block' ), 190 | ]; 191 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "syntax-highlighting-code-block", 3 | "private": true, 4 | "description": "Extending the Code block with syntax highlighting rendered on the server, thus being AMP-compatible and having faster frontend performance.", 5 | "author": "Weston Ruter", 6 | "license": "GPL-2.0-or-later", 7 | "keywords": [ 8 | "wordpress", 9 | "wordpress-plugin" 10 | ], 11 | "homepage": "https://github.com/westonruter/syntax-highlighting-code-block", 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/westonruter/syntax-highlighting-code-block.git" 15 | }, 16 | "bugs": { 17 | "url": "https://github.com/westonruter/syntax-highlighting-code-block/issues" 18 | }, 19 | "devDependencies": { 20 | "@wordpress/api-fetch": "7.24.0", 21 | "@wordpress/block-editor": "14.19.0", 22 | "@wordpress/block-library": "9.24.0", 23 | "@wordpress/blocks": "14.13.0", 24 | "@wordpress/components": "29.10.0", 25 | "@wordpress/editor": "14.24.0", 26 | "@wordpress/element": "6.24.0", 27 | "@wordpress/env": "10.24.0", 28 | "@wordpress/eslint-plugin": "22.10.0", 29 | "@wordpress/hooks": "4.24.0", 30 | "@wordpress/i18n": "5.24.0", 31 | "@wordpress/scripts": "30.17.0", 32 | "eslint": "8.57.1", 33 | "grunt": "1.6.1", 34 | "grunt-wp-deploy": "2.1.2", 35 | "highlight.js": "git+https://github.com/highlightjs/highlight.js.git#9.18.1", 36 | "husky": "9.1.7", 37 | "lint-staged": "16.0.0", 38 | "lodash": "4.17.21", 39 | "npm-run-all": "4.1.5", 40 | "prettier": "3.5.3" 41 | }, 42 | "scripts": { 43 | "update": "bin/update-highlight-libs.sh", 44 | "build": "npm-run-all build:*", 45 | "build:transform-readme": "php ./bin/transform-readme.php", 46 | "build:clean": "if [ -e dist ]; then rm -r dist; fi; if [ -e build ]; then rm -r build; fi; if [ -e syntax-highlighting-code-block ]; then rm -r syntax-highlighting-code-block; fi", 47 | "build:js": "wp-scripts build src/index.js src/customize-controls.js --output-path=build", 48 | "build:dist": "bash ./bin/build-dist.sh", 49 | "build:zip": "if [ -e syntax-highlighting-code-block.zip ]; then rm syntax-highlighting-code-block.zip; fi; vendor/bin/wp dist-archive --plugin-dirname=syntax-highlighting-code-block dist syntax-highlighting-code-block.zip && echo \"ZIP of build: $(pwd)/syntax-highlighting-code-block.zip\"", 50 | "verify-matching-versions": "php ./bin/verify-version-consistency.php", 51 | "deploy": "npm-run-all verify-matching-versions build && unzip syntax-highlighting-code-block.zip && grunt wp_deploy && rm -r syntax-highlighting-code-block", 52 | "generate-language-names": "php ./bin/generate-language-names.php", 53 | "check-engines": "wp-scripts check-engines", 54 | "check-licenses": "wp-scripts check-licenses", 55 | "lint": "npm-run-all --parallel lint:*", 56 | "lint:composer": "composer normalize --dry-run", 57 | "lint:composer:fix": "composer normalize", 58 | "lint:css": "wp-scripts lint-style", 59 | "lint:css:fix": "npm run lint:css -- --fix", 60 | "lint:js": "wp-scripts lint-js", 61 | "lint:js:fix": "wp-scripts lint-js --fix", 62 | "lint:js:report": "npm run lint:js -- --output-file lint-js-report.json --format json .", 63 | "lint:php": "composer phpcs", 64 | "lint:php:fix": "composer phpcbf", 65 | "lint:phpstan": "composer analyze", 66 | "lint:pkg-json": "wp-scripts lint-pkg-json . --ignorePath .gitignore", 67 | "md5sum:check": "md5sum -c block-library.md5", 68 | "md5sum:update": "md5sum node_modules/@wordpress/block-library/src/code/edit.js > block-library.md5", 69 | "prepare": "husky", 70 | "start": "wp-scripts start src/index.js src/customize-controls.js --output-path=build", 71 | "symlink-wp-env-install-paths": "bin/symlink-wp-env-install-paths.sh", 72 | "wp-env": "wp-env" 73 | }, 74 | "npmpackagejsonlint": { 75 | "extends": "@wordpress/npm-package-json-lint-config", 76 | "rules": { 77 | "require-version": "off" 78 | } 79 | }, 80 | "title": "Syntax-highlighting Code Block (with Server-side Rendering)" 81 | } 82 | -------------------------------------------------------------------------------- /phpstan.neon.dist: -------------------------------------------------------------------------------- 1 | includes: 2 | # @see https://github.com/phpstan/phpstan-src/blob/b9f62d63f2deaa0a5e97f51073e41a422c48aa01/conf/bleedingEdge.neon 3 | - phar://phpstan.phar/conf/bleedingEdge.neon 4 | - vendor/szepeviktor/phpstan-wordpress/extension.neon 5 | parameters: 6 | level: 9 7 | paths: 8 | - syntax-highlighting-code-block.php 9 | - language-names.php 10 | - uninstall.php 11 | - inc/ 12 | stubFiles: 13 | # https://github.com/scrivo/highlight.php/pull/107 14 | - tests/phpstan/HighlightAutoloader.stub 15 | dynamicConstantNames: 16 | - Syntax_Highlighting_Code_Block\DEVELOPMENT_MODE 17 | treatPhpDocTypesAsCertain: false 18 | -------------------------------------------------------------------------------- /src/customize-controls.js: -------------------------------------------------------------------------------- 1 | /** 2 | * WordPress dependencies 3 | */ 4 | import apiFetch from '@wordpress/api-fetch'; 5 | 6 | /** 7 | * External dependencies 8 | */ 9 | import { memoize } from 'lodash'; 10 | 11 | const { customize } = global.wp; 12 | 13 | const themeNameCustomizeId = 'syntax_highlighting[theme_name]'; 14 | const lineColorCustomizeId = 15 | 'syntax_highlighting[highlighted_line_background_color]'; 16 | 17 | /** 18 | * Init. 19 | * 20 | * @param {Object} args 21 | * @param {wp.customize.Control} args.themeNameControl 22 | * @param {wp.customize.Control} args.lineColorControl 23 | */ 24 | function init({ themeNameControl, lineColorControl }) { 25 | const colorPickerElement = 26 | lineColorControl.container.find('.color-picker-hex'); 27 | 28 | themeNameControl.setting.bind(async (newThemeName) => { 29 | const isColorCustomized = 30 | lineColorControl.setting().toLowerCase() !== 31 | lineColorControl.params.defaultValue.toLowerCase(); 32 | 33 | lineColorControl.params.defaultValue = 34 | await getDefaultThemeLineColor(newThemeName); 35 | 36 | // Make sure the default value gets propagated into the wpColorPicker. 37 | colorPickerElement.wpColorPicker( 38 | 'defaultColor', 39 | lineColorControl.params.defaultValue 40 | ); 41 | 42 | // Update the color to be the default if it was not customized. 43 | if (!isColorCustomized) { 44 | lineColorControl.setting.set(lineColorControl.params.defaultValue); 45 | } 46 | }); 47 | } 48 | 49 | /** 50 | * Get default theme line color. 51 | * 52 | * @param {string} themeName 53 | * @return {Promise} Promise. 54 | */ 55 | const getDefaultThemeLineColor = memoize((themeName) => { 56 | return apiFetch({ 57 | path: `/syntax-highlighting-code-block/v1/highlighted-line-background-color/${themeName}`, 58 | }); 59 | }); 60 | 61 | // Initialize once the controls are available. 62 | customize.control( 63 | themeNameCustomizeId, 64 | lineColorCustomizeId, 65 | (themeNameControl, lineColorControl) => { 66 | init({ 67 | themeNameControl, 68 | lineColorControl, 69 | }); 70 | } 71 | ); 72 | -------------------------------------------------------------------------------- /src/edit.js: -------------------------------------------------------------------------------- 1 | /* global syntaxHighlightingCodeBlockLanguageNames */ 2 | 3 | /** 4 | * WordPress dependencies 5 | */ 6 | 7 | import { Fragment, useRef, useEffect, useState } from '@wordpress/element'; 8 | import { __ } from '@wordpress/i18n'; 9 | import { 10 | RichText, 11 | useBlockProps, 12 | InspectorControls, 13 | } from '@wordpress/block-editor'; 14 | import { 15 | SelectControl, 16 | TextControl, 17 | CheckboxControl, 18 | PanelBody, 19 | PanelRow, 20 | } from '@wordpress/components'; 21 | import { createBlock, getDefaultBlockName } from '@wordpress/blocks'; 22 | 23 | /** 24 | * External dependencies 25 | */ 26 | import { sortBy } from 'lodash'; 27 | 28 | const languageNames = syntaxHighlightingCodeBlockLanguageNames; 29 | 30 | const HighlightableTextArea = (props_) => { 31 | const { highlightedLines, ...props } = props_; 32 | const textAreaRef = useRef(); 33 | const [styles, setStyles] = useState({}); 34 | 35 | useEffect(() => { 36 | if (textAreaRef.current !== null) { 37 | const element = textAreaRef.current; 38 | const computedStyles = window.getComputedStyle(element); 39 | 40 | setStyles({ 41 | fontFamily: computedStyles.getPropertyValue('font-family'), 42 | fontSize: computedStyles.getPropertyValue('font-size'), 43 | overflow: 'hidden', // Prevent doubled-scrollbars from appearing. 44 | overflowWrap: computedStyles.getPropertyValue('overflow-wrap'), 45 | resize: computedStyles.getPropertyValue('resize'), 46 | }); 47 | } 48 | }, [props.style]); 49 | 50 | return ( 51 | 52 | 53 |
58 | {(props.value || '').split(/\n|
/i).map((v, i) => { 59 | let cName = 'loc'; 60 | 61 | if (highlightedLines.has(i)) { 62 | cName += ' highlighted'; 63 | } 64 | 65 | return ( 66 | 73 | ); 74 | })} 75 |
76 |
77 | ); 78 | }; 79 | 80 | /** 81 | * Parse a string representation of highlighted lines into a set of each highlighted line number. 82 | * 83 | * @param {string} highlightedLines Highlighted lines. 84 | * @return {Set} Highlighted lines. 85 | */ 86 | const parseHighlightedLines = (highlightedLines) => { 87 | const highlightedLinesSet = new Set(); 88 | 89 | if (!highlightedLines || highlightedLines.trim().length === 0) { 90 | return highlightedLinesSet; 91 | } 92 | 93 | let chunk; 94 | const ranges = highlightedLines.replace(/\s/, '').split(','); 95 | 96 | for (chunk of ranges) { 97 | if (chunk.indexOf('-') >= 0) { 98 | let i; 99 | const range = chunk.split('-'); 100 | 101 | if (range.length === 2) { 102 | for (i = +range[0]; i <= +range[1]; ++i) { 103 | highlightedLinesSet.add(i - 1); 104 | } 105 | } 106 | } else { 107 | highlightedLinesSet.add(+chunk - 1); 108 | } 109 | } 110 | 111 | return highlightedLinesSet; 112 | }; 113 | 114 | export default function CodeEdit({ 115 | attributes, 116 | setAttributes, 117 | onRemove, 118 | insertBlocksAfter, 119 | mergeBlocks, 120 | }) { 121 | const blockProps = useBlockProps(); 122 | 123 | const updateLanguage = (language) => { 124 | setAttributes({ language }); 125 | }; 126 | 127 | const updateHighlightedLines = (highlightedLines) => { 128 | setAttributes({ highlightedLines }); 129 | }; 130 | 131 | const updateShowLineNumbers = (showLineNumbers) => { 132 | setAttributes({ showLineNumbers }); 133 | }; 134 | 135 | const updateWrapLines = (wrapLines) => { 136 | setAttributes({ wrapLines }); 137 | }; 138 | 139 | const sortedLanguageNames = sortBy( 140 | Object.entries(languageNames).map(([value, label]) => ({ 141 | label, 142 | value, 143 | })), 144 | (languageOption) => languageOption.label.toLowerCase() 145 | ); 146 | 147 | const richTextProps = { 148 | // These RichText props must mirror core . 149 | ...{ 150 | tagName: 'code', 151 | identifier: 'content', 152 | value: attributes.content, 153 | onChange: (content) => setAttributes({ content }), 154 | onRemove, 155 | onMerge: mergeBlocks, 156 | placeholder: __('Write code…'), 157 | 'aria-label': __('Code'), 158 | preserveWhiteSpace: true, 159 | __unstablePastePlainText: true, // See . 160 | __unstableOnSplitAtDoubleLineEnd: () => { 161 | insertBlocksAfter(createBlock(getDefaultBlockName())); 162 | }, 163 | }, 164 | 165 | // Additional props unique to HighlightableTextArea. 166 | ...{ 167 | highlightedLines: parseHighlightedLines( 168 | attributes.highlightedLines 169 | ), 170 | className: [ 171 | 'shcb-textedit', 172 | attributes.wrapLines ? 'shcb-textedit-wrap-lines' : '', 173 | ].join(' '), 174 | 175 | // Copy the styles to ensure that the code-block-overlay is updated when the font size is changed. 176 | style: blockProps.style, 177 | }, 178 | }; 179 | 180 | return ( 181 | 182 | 183 | 190 | 191 | 209 | 210 | 211 | 223 | 224 | 225 | 233 | 234 | 235 | 243 | 244 | 245 | 246 | {/* Keep in sync with https://github.com/WordPress/gutenberg/blob/e95bb8c9530bbdef1db623eca11b80bd73493197/packages/block-library/src/code/edit.js#L17 */} 247 |
248 | 				
249 | 			
250 |
251 | ); 252 | } 253 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | /* global syntaxHighlightingCodeBlockType */ 2 | 3 | /** 4 | * WordPress dependencies 5 | */ 6 | import { addFilter } from '@wordpress/hooks'; 7 | 8 | /** 9 | * Internal dependencies 10 | */ 11 | import edit from './edit'; 12 | 13 | /** 14 | * Extend code block with syntax highlighting. 15 | * 16 | * @param {Object} settings Settings. 17 | * @return {Object} Modified settings. 18 | */ 19 | const extendCodeBlockWithSyntaxHighlighting = (settings) => { 20 | if (syntaxHighlightingCodeBlockType.name !== settings.name) { 21 | return settings; 22 | } 23 | 24 | return { 25 | ...settings, 26 | 27 | /* 28 | * @todo Why do the attributes need to be augmented here when they have already been declared for the block type in PHP? 29 | * There seems to be a race condition, as wp.blocks.getBlockType('core/code') returns the PHP-augmented data after the 30 | * page loads, but at the moment this filter calls it is still undefined. 31 | */ 32 | attributes: { 33 | ...settings.attributes, 34 | ...syntaxHighlightingCodeBlockType.attributes, // @todo Why can't this be supplied via a blocks.getBlockAttributes filter? 35 | }, 36 | 37 | edit, 38 | 39 | deprecated: [ 40 | ...(settings.deprecated || []), 41 | { 42 | attributes: { 43 | ...settings.attributes, 44 | ...syntaxHighlightingCodeBlockType.deprecated, 45 | }, 46 | isEligible(attributes) { 47 | return Object.keys(attributes).some((attribute) => { 48 | return syntaxHighlightingCodeBlockType.deprecated.hasOwnProperty( 49 | attribute 50 | ); 51 | }); 52 | }, 53 | migrate(attributes, innerBlocks) { 54 | return [ 55 | { 56 | ...attributes, 57 | highlightedLines: attributes.selectedLines, 58 | showLineNumbers: attributes.showLines, 59 | }, 60 | innerBlocks, 61 | ]; 62 | }, 63 | }, 64 | ], 65 | }; 66 | }; 67 | 68 | addFilter( 69 | 'blocks.registerBlockType', 70 | 'westonruter/syntax-highlighting-code-block-type', 71 | extendCodeBlockWithSyntaxHighlighting 72 | ); 73 | -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | .wp-block-code { 2 | border: 0; 3 | padding: 0; 4 | -webkit-text-size-adjust: 100%; 5 | text-size-adjust: 100%; 6 | } 7 | 8 | .wp-block-code > span { 9 | display: block; 10 | overflow: auto; 11 | } 12 | 13 | .shcb-language { 14 | border: 0; 15 | clip: rect(1px, 1px, 1px, 1px); 16 | -webkit-clip-path: inset(50%); 17 | clip-path: inset(50%); 18 | height: 1px; 19 | margin: -1px; 20 | overflow: hidden; 21 | padding: 0; 22 | position: absolute; 23 | width: 1px; 24 | word-wrap: normal; 25 | word-break: normal; 26 | } 27 | 28 | .hljs { 29 | box-sizing: border-box; 30 | } 31 | 32 | .hljs.shcb-code-table { 33 | display: table; 34 | width: 100%; 35 | } 36 | 37 | .hljs.shcb-code-table > .shcb-loc { 38 | color: inherit; 39 | display: table-row; 40 | width: 100%; 41 | } 42 | 43 | .hljs.shcb-code-table .shcb-loc > span { 44 | display: table-cell; 45 | } 46 | 47 | .wp-block-code code.hljs:not(.shcb-wrap-lines) { 48 | white-space: pre; 49 | } 50 | 51 | .wp-block-code code.hljs.shcb-wrap-lines { 52 | white-space: pre-wrap; 53 | } 54 | 55 | .hljs.shcb-line-numbers { 56 | border-spacing: 0; 57 | counter-reset: line; 58 | } 59 | 60 | .hljs.shcb-line-numbers > .shcb-loc { 61 | counter-increment: line; 62 | } 63 | 64 | .hljs.shcb-line-numbers .shcb-loc > span { 65 | padding-left: 0.75em; 66 | } 67 | 68 | .hljs.shcb-line-numbers .shcb-loc::before { 69 | border-right: 1px solid #ddd; 70 | content: counter(line); 71 | display: table-cell; 72 | padding: 0 0.75em; 73 | text-align: right; 74 | -webkit-user-select: none; 75 | -moz-user-select: none; 76 | -ms-user-select: none; 77 | user-select: none; 78 | white-space: nowrap; 79 | width: 1%; 80 | } 81 | -------------------------------------------------------------------------------- /syntax-highlighting-code-block.php: -------------------------------------------------------------------------------- 1 | [ 54 | 'type' => 'string', 55 | 'default' => '', 56 | ], 57 | 'highlightedLines' => [ 58 | 'type' => 'string', 59 | 'default' => '', 60 | ], 61 | 'showLineNumbers' => [ 62 | 'type' => 'boolean', 63 | 'default' => false, 64 | ], 65 | 'wrapLines' => [ 66 | 'type' => 'boolean', 67 | 'default' => false, 68 | ], 69 | ]; 70 | 71 | require_once __DIR__ . '/inc/functions.php'; 72 | 73 | add_action( 'plugins_loaded', __NAMESPACE__ . '\boot' ); 74 | -------------------------------------------------------------------------------- /tests/phpstan/HighlightAutoloader.stub: -------------------------------------------------------------------------------- 1 |