Giter Site home page Giter Site logo

kasparsd / code-prettify Goto Github PK

View Code? Open in Web Editor NEW
96.0 5.0 22.0 1.39 MB

WordPress plugin for automatic code highlighting using the Prettify library. No shortcodes, no classnames, pure awesome.

Home Page: https://wordpress.org/plugins/code-prettify

JavaScript 97.69% PHP 2.31%
prettify-library syntax-highlighting wordpress-plugin wordpress blogging composer-package

code-prettify's Introduction

Code Prettify

Contributors: kasparsd
Tags: code, pre, highlighting, highlight, highlighter, syntax, syntax highlighting, prettify
Requires at least: 3.0
Tested up to: 6.1
Stable tag: 1.5.1

100% automatic code highlighting using the Prettify library. No shortcodes, no classnames, fully automatic and pure awesome.

Description

Uses a customized version of the Code Prettify library to support local styles and scripts. Plugin applies code highlighting automatically to all <pre> tags on the page.

Compatible with Gutenberg and doesn't lock you in with specific markup requirements.

Development

Plugin development on GitHub.

Credits

Created and maintained by Kaspars Dambis. All of my open source work is available on GitHub.

Use Contact Form 7? Storage for Contact Form 7 is my commercial plugin (GPL license) for storing all form submissions in your WordPress database.

Cover photo by Yuri Samoilov

Installation

Simply upload the plugin and active it. It works out of the box and doesn't have any configuration options.

Frequently Asked Questions

None, yet.

Screenshots

  1. Syntax highlighting applied to a <pre> block and inline <code> segments.

Changelog

1.5.1 (November 8, 2021)

  • Fix the deprecation notice for how the data is passed to the script.
  • Mark as tested with WordPress 5.8.

1.5.0 (April 19, 2020)

  • Preload the prettify.css file for performance improvements.
  • Add WordPress coding standards checks.
  • Add support for Composer install.

1.4.2 (January 14, 2019)

  • Switch to legacy PHP array syntax for better compatibility.

1.4.1 (December 21, 2018)

  • Add a trailing semicolon to all JS files to support concatenation.

1.4.0 (December 20, 2018)

  • Update the Prettify library.
  • Don't highlight standalone <code> blocks without the <pre> wrapper.
  • Mark as tested with WordPress 5.0.

1.3.4

  • Update the Prettify library.
  • Ensure that Prettify styles are applied to the contents of <pre> and <code> elements.

1.3.3

  • Update the Prettify library.
  • Highlight <code> blocks too.

1.0

  • Initial release.

Upgrade Notice

1.0

Initial release.

code-prettify's People

Contributors

kasparsd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

code-prettify's Issues

Add Code Tag

It detects <pre>code automatically, please add support for <code> tag also.

Plugin can't read '<' character

If you write

<?php 

/* some codes */

?>

The Plugin won't show the code block.

But this will work

&lt;?php 

/* some codes */

?>

So, please allow < as like it's html entity &lt;

I've checked that at my blog with Twenty Fifteen theme.

Not working properly with Wordpress blocks (Gutenberg)

The plugin doesn't work as expected with the latest versions of Wordpress.

It works with posts created in the past without blocks (example)

It doesn't work with posts created with blocks (example)

Basically it treats code blocks as inline code, instead of code blocks. I think this is a bug.

Class attribute requirement

The readme says the prettify code will run against all pre & code tags but I only saw it working when I added class="prettyprint" to the tags. Not sure if the readme forgot to mention this or it was actually meant to work this way. Obviously it is a lot more convenient if the class attribute is not required.

colors...

Hi, this maybe a silly question:

If i have a code block like this:

defmodule WebsiteWeb.PageController do
  use WebsiteWeb, :controller

  def index(conn, _params) do
    render conn, "index.html"
  end
end

when it gets rendered it gets the class "prettyprinted" applied to the pre and the code elements

if i use a different css by adding this in my functions.php file:

function my_prettify_skin( $skin ) { return 'sunburst'; } add_filter( 'prettify_skin', 'my_prettify_skin' );

it doesnt apply the correct css to the backgrounds as its looking for the class "prettyprint" not "prettyprinted"

am i dont something silly?

thanks

Dan

Add scrollbars when needed (or configured)

I have a wordpress theme that has a rather narrow width for the content.

So now code gets some line breaks - which is okay, but what I would prefer is to show some (horizontal) scrollbar when the width is not enough to show the full code.

Would be great to have a global option to turn it off/on, which would also mean that people who do not like this can keep the old behaviour.

Add a couple of hooks

Thanks for the great plugin!

I understand that you want to keep the plugin simple but maybe from developer's point of view it would be really useful if we could have a couple of hooks available for this plugin:

  1. one that would allow to modify the detected pre/code tags content (for example, wrap them in another tag or do search/replace operations);
  2. another that would allow to change the prettyprinted class to something other.

Using <pre> or <code> not working in WP

Hi,

Maybe your plugin is working, but adding code or pre tags in WP is causing me problems, everything in between get messed up, how to solve this first?

Willem

Missing C#

Hello and thank you for your efforts!
I am missing colorization for C# (everything is black when using class="language-cs").
I could abuse class="language-java" but then in the top-right-corner there would be written/standing "Java" (which would not be correct).
Is there any chance to extend the syntaxhighlightnings with C# one?
Please let me know if I can help you with keywords, regular-expressions aso.
Kindly regards.

Loading .tag CSS on tag archive pages

Hi,

On tag archive pages in WordPress the HTML is like this:

As you can see it has a class 'tag'. In your CSS you defined a blue color van this class also, which is now causing al my text to be blue.

How can we solve this?

Kind regards,

Willem

Suggestions regarding to the Readme.txt

I have some suggestions regarding to the Readme.txt.

  1. There is a plugin in Wordpress's plugin repository that has the same name as yours.
    Please see: https://wordpress.org/plugins/code-prettify/. Maybe you can mention it in the readme.txt to clarify that these are two different plugins.
  2. I think #6 should be listed in Frequently Asked Questions since people (like me) may wonder why they could not find this wonderful plugin in Wordpress's plugin repository.

I have tried several famous code highlighter for Wordpress. And I have to say that this is the best one in my opinion. Good job & thanks you.

Minit plugin compatibility

I'm having difficulties making this work with the Minit plugin.

The Minit plugin is stripping out the variable code_prettify_settings, which then prevents it from working. Do you have any ideas how to work around this problem?

Conditional CSS preload

Issue #30 preloads prettify.css. This has a drawback when optimisations like the Fast Velocity Minify plugin are active, which bundles all CSS into a single file. In that case the preloader still fetches prittify.css issuing an unnecessary http request in every page. Preloading should be conditional on a setting.

Triggered a fatal error.

After installing, I get the following error while trying to activate it.

Plugin could not be activated because it triggered a fatal error.
Parse error: syntax error, unexpected '[' in /var/www/html/blog/wp-content/plugins/code-prettify/code-prettify.php on line 28

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.