CodeShare
Have some code. Share some code.
cancel
Showing results for 
Search instead for 
Did you mean: 
Custom Alert Banner
Kai_Wilke
MVP
MVP
Code is community submitted, community supported, and recognized as ‘Use At Your Own Risk’.

Short Description

The provided iRule language definition can be used to highlight iRule code within websites using the Prism.js framework.

Problem solved by this Code Snippet

The Prism.js framework is widely used to highlight code blocks on websites. Even the DevCentral Page uses the Prism.js framework to highlight code boxes using the default TCL language definition contributed by Peter Chaplin to the Prism.js repository.

if { "1" equals "1" } then {
	HTTP::path "/something"
	pool some_pool
}

As you may see in the example above, the default TCL language definition is not trained to highlight any of the F5 specific commands (e.g. HTTP::path) and operators (e.g. equals), so that they remain non-highlighted in black color.

I took the time to write a language definition for iRules based on the reduced TCL 8.4 syntax supported by iRules in addition to the iRule command and operator set based on TMOS version 16.1.3.

I finally ended up with nearly 10kbyte RegEx signatures to provide a rich command highlighting experience for iRule code snippets.

Highlight-Example.png 

How to use this Code Snippet

Visit my GitHub Repository for additional implementation notes of the 'Prism.js language definition for iRules'.

Feel free to discuss the project here on CrowSRC!

Cheers, Kai

Code Snippet Meta Information

  1. Version: 1.0
  2. Coding Language: Prism.js, JS, RegEx

Full Code Snippet

Visit: https://github.com/KaiWilke/F5-PrismJS-iRule-Language-Definition

Comments

Has this been submitted over at prisim.js ? It wont get into this forum until it is.

Version history
Last update:
‎06-Mar-2023 02:47
Updated by:
Contributors