Coder Social home page Coder Social logo

grav-plugin-prism-highlight-simpler's Introduction

Grav Prism Highlighter Simpler Plugin

Prism Highlighter Simpler is a Grav plugin that adds simple and powerful code highlighting functionality utilizing the Prism.js syntax highlighter.

It is mainly based on the Prism Highlighter plugin by Trilby Media.

But it doesn't need you to use shortcodes to include your code samples! You just have to use the usual Markdown syntax:

```bash
$ echo $USER

Installation

Manual Installation

To install this plugin, just download the zip version of this repository and unzip it under /your/site/grav/user/plugins. Then, rename the folder to prism-highlight-simpler.

You should now have all the plugin files under

/your/site/grav/user/plugins/prism-highlight-simpler

Languages included

Prism.js supports currently 210 languages, at the time of this edit, and they are all included in this plugin.

Plugins Included

This build of Prism also includes the following plugins:

  • Line Highlight
  • Toolbar
  • Copy to Clipboard

Basic Usage

In your markdown, you can create a block of code, and assign the language to it. You can choose between the list above.

Example using regular markdown fenced code syntax:

  ```php
  <?php
  
  namespace Grav\Plugin;
  
  use \Grav\Common\Plugin;
  use \Grav\Common\Grav;
  use \Grav\Common\Page\Page;
  
  class PrismHighlightSimplerPlugin extends Plugin
  {
      /**
       * @return array
       */
      public static function getSubscribedEvents()
      {
          return [
              'onPageInitialized' => ['onPageInitialized', 0],
              'onShortcodeHandlers' => ['onShortcodeHandlers', 0],
              'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0],
          ];
      }
  }

Configuration

Configuration shall be set in config/plugins/prism-highlight-simpler.yaml.

enabled: true
theme: prism-base16-ocean.dark.css
line-numbers: true  
default-language-toggle: true
default-language-value: txt

You can also override configuration settings at the page level by prefixing options with prism-highlight-simpler:. For example you could set a different theme, and turning on line numbers on a particular page with:

title: My Page
prism-highlight-simpler:
  theme: base16-duotone-dark.light.css
  line-numbers: true 

Themes

The themes available are those of the original plugin (listed in the README).

I've just added my personal theme, using Base2Tone, in different versions; the dark version is the default specified in the config file (prism-base2tone-momh-dark.css).

grav-plugin-prism-highlight-simpler's People

Contributors

bricebou avatar growtopiajaw avatar rhukster avatar w00fz avatar

Watchers

 avatar

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.