Code blocks php extension

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Code Block is a TYPO3 extension. It adds a content type to display source code processed using highlight.php to render code snippets with syntax highlighting.

License

b13/codeblock

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Читайте также:  Python dasturlash tilidan test

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

What does this extension do?

Code Block is a TYPO3 extension. It adds a content type to display source code processed using highlight.php to render code snippets with syntax highlighting. The CSS-classes applied are identical to what highlight.js would render, but the transformation takes place on the server (instead of the browser when using JS).

The rendered result is cached like any other content element with the page in TYPO3. Using this extension you can skip adding highlight.js to your JS-build. This helps reduce the JavaScript size for your website and also allows rendering of source code snippets for AMP pages for example.

The extension supports all code languages that highlight.php supports. These can either be specified by choosing a setting inside the content element or detected automatically.

Add this extension to your TYPO3 setup. Install using composer: composer req b13/codeblock .

Add the TypoScript to your site extensions setup:

Add the PageTS (for adding the element to the New Content Element Wizard):

If you want to use your own Fluid Template, add the Template Root Path to the setup like this:

If your Fluid Layout «Default» uses you should use a custom content type Fluid Template to avoid having your frontend tabs/spaces missing for some parts. Spacelesse removes spaces between tags, and highlight.php can add a series of foo bar strings that need the spaces between the tags to be readable and make sense.

CSS styling needs to be included manually. The classes added to the HTML output are generated automatically. Their styling need to be specified in a CSS file in order to add a custom styling. E.g. for JetBrain’s darcula theme:

.hljs < display: block; overflow-x: auto; padding: 0.5em; background: #2b2b2b; > .hljs < color: #bababa; > .hljs-strong, .hljs-emphasis < color: #a8a8a2; > .hljs-bullet, .hljs-quote, .hljs-link, .hljs-number, .hljs-regexp, .hljs-literal < color: #6896ba; > .hljs-code, .hljs-selector-class < color: #a6e22e; > .hljs-emphasis < font-style: italic; > .hljs-keyword, .hljs-selector-tag, .hljs-section, .hljs-attribute, .hljs-name, .hljs-variable < color: #cb7832; > .hljs-params < color: #b9b9b9; > .hljs-string < color: #6a8759; > .hljs-subst, .hljs-type, .hljs-built_in, .hljs-builtin-name, .hljs-symbol, .hljs-selector-id, .hljs-selector-attr, .hljs-selector-pseudo, .hljs-template-tag, .hljs-template-variable, .hljs-addition < color: #e0c46c; > .hljs-comment, .hljs-deletion, .hljs-meta < color: #7f7f7f; >

This extension uses highlight.php (see https://github.com/scrivo/highlight.php). This package includes a lot of different CSS style themes you can use.

As TYPO3 Core, codeblock is licensed under GPL2 or later. See the LICENSE file for more details.

Background, Authors & Further Maintenance

TYPO3 is highly configurable and it is easy to add custom content types to the system using a few lines of TCA configuration, a simple PageTS configuration to add the type to the list of elements in the New Content Element Wizard, and a few lines of TypoScript and a Fluid Template. This extension adds a content type in the same way we create custom content types for our TYPO3 projects at b13.

EXT:codeblock was initially created by Andreas Hämmerl and David Steeb in 2019 for b13, Stuttgart. We use it to display source code in our blog on b13.com, where we have a full-AMP website and do not include non-AMP JavaScript files.

Find more TYPO3 extensions we have developed that help us deliver value in client projects. As part of the way we work, we focus on testing and best practices to ensure long-term performance, reliability, and results in all our code.

About

Code Block is a TYPO3 extension. It adds a content type to display source code processed using highlight.php to render code snippets with syntax highlighting.

Источник

New features of PHP 8.2 in Code Blocks

The release of PHP’s latest version, PHP 8.2, is just around the corner. On December 8, 2022 to be precise.

In this article, I’m going to list all the new features that are going to be introduced in PHP 8.2 in form of code blocks. This way, you can easily copy and paste the code blocks and try them out in your local environment.

This won’t include improvements and bug fixes that come with PHP 8.2. I’m only going to cover the ones that I think are worth mentioning. So, let’s get started.

Readonly Classes

Readonly classes are just regular classes prepended by the readonly modifier. This feature is in line with the readonly properties that were introduced in PHP 8.1.

readonly class Book  public function __construct( public string $author, public string $title, ) <> > $book = new Book('Ruskin Bond', 'Maharani'); $book->author = 'J. K. Rowling'; // Error: Cannot modify readonly property Book::$author 

The true type

The true type is a new type that can be used to specify that a variable can only be assigned a boolean value of true .

function enableFeature(true $feature): true  // do something return true; > enableFeature(false); // PHP Fatal error: Uncaught TypeError: enableFeature(): // Argument #1 ($feature) must be of type true, bool given 

The false and null types

The false and null types are new types that can be used to specify that a variable can only be assigned a boolean value of false or null respectively.

function disableFeature(false $feature): true  // do something return true; > disableFeature(true); // PHP Fatal error: Uncaught TypeError: disableFeature(): // Argument #1 ($feature) must be of type false, bool given, 

And here’s an example of the null type:

class Nil  public null $nil = null; public function isNull(null $nil): true  /* . */ return true; > > $nil = new Nil(); $nil->isNull(true); // PHP Fatal error: Uncaught TypeError: Nil::isNull(): // Argument #1 ($nil) must be of type null, bool given 

Using constants in traits

PHP 8.2 will allow you to use constants in traits. This means that you can now define constants in traits, and they can be used in classes that use the trait as well as in the trait itself.

trait PersonTrait  public const MIN_AGE = 18; public function isAdult(): bool  return $this->age >= self::MIN_AGE; > > class Person  use PersonTrait; private int $age; public function __construct(int $age)  $this->age = $age; > > echo Person::MIN_AGE; // Output: 18 $person = new Person(20); echo $person->isAdult(); // Output: true 

Disjunctive Normal Form (DNF) types

PHP 8.2 will introduce a new type called DNF (Disjunctive Normal Form). This type is a combination of the | and & operators. It allows you to specify a type that is the union of two or more types, and each of those types is the intersection of one or more other types.

New Random Extension

PHP 8.2 will introduce a new random API that will replace the existing mt_rand() and rand() functions. The new API will be based on a single Randomizer class which provides various randomization methods (like get int/bytes, shuffle string/arrays).

$is_production = false; $rng = $is_production ? new Random\Engine\Secure() : new Random\Engine\PCG64(1234); $randomizer = new Random\Randomizer($rng); $randomizer->shuffleString('jhondoe'); 

PHP 8 in a Nutshell book cover

PHP 8 in a Nutshell book cover

Learn the fundamentals of PHP 8 (including 8.1 and 8.2), the latest version of PHP, and how to use it today with my new book PHP 8 in a Nutshell. It’s a no-fluff and easy-to-digest guide to the latest features and nitty-gritty details of PHP 8. So, if you’re looking for a quick and easy way to PHP 8, this is the book for you.

Caricature of Amit Merchant sketched by a friend

👋 Hi there! I’m Amit. I write articles about all things web development. If you like what I write and want me to continue doing the same, I would like you buy me some coffees. I’d highly appreciate that. Cheers!

Источник

Plugins

Support Code::Blocks

Code::Blocks was designed around a plugin framework to make it easy for users to extend/improve it without having to touch one line of Code::Blocks’ source code.

Over the years, many great plugins have been written by people. Many of them are part of the official Code::Blocks release while others are developed (and managed) by individuals outside our team.

In the future, this page will hold a list of available plugins along with their description and links to their installation instructions or usage manual. But, for the moment, we refer you to our WiKi where we have a dedicated entry point to find information about existing plugins.

If you want to help documenting the existing plugins, you can do so by editing the WiKi pages yourself. The user name and password required to edit WiKi pages is the same as your forums user name and password. So, if you haven’t already signed up to our forums, please do so.

Build system

Code::Blocks implements a custom build system with very important features: ultra-fast dependencies generation, build queues and parallel builds are the most important ones to mention.

Debugging

The debugging subsystem has been greatly enhanced in the latest version. Automatic/manual watches, code/data breakpoints, call stack, disassembly listing and memory dumps are only few of its features.

Источник

Оцените статью