Skip to content

Commit

Permalink
Bump version to 1.2.0, update readme and screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed May 10, 2020
1 parent 1ad8df7 commit ecddb40
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 38 deletions.
29 changes: 10 additions & 19 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,23 @@ Extending the Code block with syntax highlighting rendered on the server, thus b
**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)
**Requires at least:** 5.2
**Tested up to:** 5.4
**Stable tag:** 1.1.4
**Stable tag:** 1.2.0
**License:** [GPLv2 or later](http://www.gnu.org/licenses/gpl-2.0.html)
**Requires PHP:** 5.6

[![Build Status](https://travis-ci.org/westonruter/syntax-highlighting-code-block.svg?branch=master)](https://travis-ci.org/westonruter/syntax-highlighting-code-block) [![Built with Grunt](https://gruntjs.com/cdn/builtwith.svg)](http://gruntjs.com)

## Description ##

This plugin extends to Code block in WordPress core to add syntax highlighting which is rendered on the server. By performing the syntax highlighting on the server, there is then no 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)).
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.

The extended Code block uses auto-detection for the language in the block to add syntax highlighting, but you can override the language in the block inspector. (There is currently no syntax highlighting of the Code block in the editor.) The plugin supports for all [185 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/)).
In addition to not adding any JavaScript to the frontend, the stylesheets needed for styling the Code block will only be added to the page if there is a Code block present. The stylesheets are added inline when the Code block is rendered, ensuring that they do not block rendering of any content higher in the page. If stylesheets fail to load for any reason, the block simply renders without styling, with one key exception: highlighted lines are wrapped in [`mark` elements](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/mark) so they'll get highlighted regardless, including in RSS Feeds and posts syndicated in email (as long as the `mark` element is supported in the client).

Any one of [89 styles](https://highlightjs.org/static/demo/) may be enqueued that highlight.php/highlight.js provide. To change the `default` style, you may do so by picking a theme via Customizer in the Colors section. To override the `default` style programmatically, use the `syntax_highlighting_code_block_style` to supply the one of the [style names](https://github.com/scrivo/highlight.php/tree/master/styles), for example `github`:
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.) 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 the aforementioned highlighted lines. 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 as to 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.

<pre lang=php>
add_filter(
'syntax_highlighting_code_block_style',
function() {
return 'github';
}
);
</pre>
For advanced usage, please see the [plugin wiki](https://github.com/westonruter/syntax-highlighting-code-block/wiki).

When a filter is provided, the theme selector in Customizer is automatically disabled.

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 to help extend.
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.
### Credits ###
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.

Expand All @@ -42,13 +33,13 @@ This is a fork of [Code Syntax Block](https://github.com/mkaz/code-syntax-block)

## Screenshots ##

### Supply content as you do normally in the Code block, optionally overriding the auto-detected language.
### 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.

![Supply content as you do normally in the Code block, optionally overriding the auto-detected language.](wp-assets/screenshot-1.png)
![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.](wp-assets/screenshot-1.png)

### The Code block renders with syntax highlighting on the frontend without any JavaScript enqueued.
### The Code block renders with syntax highlighting on the frontend without any JavaScript enqueued. Stylesheets are added only when block is on the page.

![The Code block renders with syntax highlighting on the frontend without any JavaScript enqueued.](wp-assets/screenshot-2.png)
![The Code block renders with syntax highlighting on the frontend without any JavaScript enqueued. Stylesheets are added only when block is on the page.](wp-assets/screenshot-2.png)

## Changelog ##

Expand Down
25 changes: 8 additions & 17 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: westonruter, allejo
Tags: block, code, code syntax, syntax highlight, code highlighting
Requires at least: 5.2
Tested up to: 5.4
Stable tag: 1.1.4
Stable tag: 1.2.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Requires PHP: 5.6
Expand All @@ -12,24 +12,15 @@ Extending the Code block with syntax highlighting rendered on the server, thus b

== Description ==

This plugin extends to Code block in WordPress core to add syntax highlighting which is rendered on the server. By performing the syntax highlighting on the server, there is then no 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)).
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.

The extended Code block uses auto-detection for the language in the block to add syntax highlighting, but you can override the language in the block inspector. (There is currently no syntax highlighting of the Code block in the editor.) The plugin supports for all [185 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/)).
In addition to not adding any JavaScript to the frontend, the stylesheets needed for styling the Code block will only be added to the page if there is a Code block present. The stylesheets are added inline when the Code block is rendered, ensuring that they do not block rendering of any content higher in the page. If stylesheets fail to load for any reason, the block simply renders without styling, with one key exception: highlighted lines are wrapped in [`mark` elements](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/mark) so they'll get highlighted regardless, including in RSS Feeds and posts syndicated in email (as long as the `mark` element is supported in the client).

Any one of [89 styles](https://highlightjs.org/static/demo/) may be enqueued that highlight.php/highlight.js provide. To change the `default` style, you may do so by picking a theme via Customizer in the Colors section. To override the `default` style programmatically, use the `syntax_highlighting_code_block_style` to supply the one of the [style names](https://github.com/scrivo/highlight.php/tree/master/styles), for example `github`:
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.) 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 the aforementioned highlighted lines. 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 as to 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.

<pre lang=php>
add_filter(
'syntax_highlighting_code_block_style',
function() {
return 'github';
}
);
</pre>
For advanced usage, please see the [plugin wiki](https://github.com/westonruter/syntax-highlighting-code-block/wiki).

When a filter is provided, the theme selector in Customizer is automatically disabled.

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 to help extend.
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.

= Credits =

Expand All @@ -39,8 +30,8 @@ This is a fork of [Code Syntax Block](https://github.com/mkaz/code-syntax-block)

== Screenshots ==

1. Supply content as you do normally in the Code block, optionally overriding the auto-detected language.
2. The Code block renders with syntax highlighting on the frontend without any JavaScript enqueued.
1. 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.
2. The Code block renders with syntax highlighting on the frontend without any JavaScript enqueued. Stylesheets are added only when block is on the page.

== Changelog ==

Expand Down
4 changes: 2 additions & 2 deletions syntax-highlighting-code-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Syntax-highlighting Code Block (with Server-side Rendering)
* Plugin URI: https://github.com/westonruter/syntax-highlighting-code-block
* Description: Extending the Code block with syntax highlighting rendered on the server, thus being AMP-compatible and having faster frontend performance.
* Version: 1.2-beta2
* Version: 1.2.0
* Author: Weston Ruter
* Author URI: https://weston.ruter.net/
* License: GPL2
Expand All @@ -22,7 +22,7 @@
use WP_Customize_Manager;
use WP_Styles;

const PLUGIN_VERSION = '1.2-beta2';
const PLUGIN_VERSION = '1.2.0';

const BLOCK_NAME = 'core/code';

Expand Down
Binary file modified wp-assets/screenshot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified wp-assets/screenshot-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ecddb40

Please sign in to comment.