Back to all posts

Testing the Highlight Shortcode

October 27, 2023
Jules

Testing Highlight Shortcode

This post tests the new highlight shortcode.

1. Basic Python Highlighting

def hello_world(): print("Hello, world!") return True hello_world()

2. JavaScript with Line Numbers

1function greet(name) { 2 const message = `Hello, ${name}!`; 3 console.log(message); 4 return message; 5} 6 7greet("World");

3. Python with Line Highlighting

import math def calculate_area(radius): if radius < 0: raise ValueError("Radius cannot be negative") return math.pi * radius ** 2 print(calculate_area(5))

4. Full Features (JS, Line Numbers, Line Highlighting)

1import { useEffect, useState } from 'react'; 2 3function MyComponent() { 4 const [data, setData] = useState(null); 5 6 useEffect(() => { 7 fetchData().then(res => setData(res)); 8 }, []); 9 10 return <div>{data}</div>; 11}

  1. New Format Support (PHP with positional lang and quoted hl_lines)

<?php echo "Hello, CloudScale!"; ?>

  1. Normal Markdown Code Block (Fallback)
console.log("This is a normal markdown code block");