Examples for Syntax Highlighting

HTML

<!DOCTYPE html> <html> <body> <script src="app.js"> </script> <canvas id="myCanvas"></canvas> <script> var canvas = document.getElementById("myCanvas"); var ctx = canvas.getContext("2d"); ctx.fillStyle = "#FF00CC"; ctx.fillRect(0, 0, 180, 80); </script> <div style="border: 1px solid grey; padding: 2pt;"> &copy; JProggy.org </div> </body> </html>

CSS

td,th { font-family: 'Courier New'; font-size: 10pt; padding-left: 0; }

Eiffel

class APPLICATION inherit ARGUMENTS create make feature {NONE} -- Initialization make -- Print values for arguments with options 'c' and 'h'. do print ("Command line argument value for option 'c' is: ") print (separate_character_option_value ('c') + "%N") print ("Command line argument value for option 'h' is: ") print (separate_character_option_value ('h') + "%N") io.read_line -- Keep console window open end end

Markdown

# A code generation platform for java ## Fluent API ```java Syntaxes.FLUYT.parse("Hello $who").set("who", "world").render(System.out); ``` ## Simple Syntax ### Locations ``` $name ``` Locations can have [attributes].

Batch

set list=1 2 3 4 (for %%a in (%list%) do ( echo %%a ))

Plant UML

@startuml actor Alice participant Bob ' Some more the passive kind of guy loop Alice -> Bob: wants something Bob --> Alice: gives annoyed look end @enduml

Rust

pub fn public_function() { println!("called rary's `public_function()`"); } fn private_function() { println!("called rary's `private_function()`"); } pub fn indirect_access() { print!(r##"called rary's r#"indirect_access()"#, that > "##); private_function(); } impl Display for OCPRecData { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { write!(f, "OCPRecData {{\n\ \x20 msg: {:?}\n\ \x20 device_name: {:?}\n\ \x20 parent_device_name: {:?}\n\ }}", self.msg, self.device_name, self.parent_device_name) } }

Scheme

;;; Tim Goodwin (tim@pipex.net) (define bottles (lambda (n) (cond ((= n 0) (display "No more bottles")) ((= n 1) (display "One bottle")) (else (display n) (display " bottles"))) (display " of beer"))) (define beer (lambda (n) (if (> n 0) (begin (bottles n) (display " on the wall") (newline) (bottles n) (newline) (display "Take one down, pass it around") (newline) (bottles (- n 1)) (display " on the wall") (newline) (newline) (beer (- n 1)))))) (beer 99)

PHP

<div style="border: 1px solid grey; padding: 2pt;"> <?php if (str_contains($_SERVER['HTTP_USER_AGENT'], 'Firefox')) { echo 'You got the fox!'; } ?> &copy; JProggy.org </div>

PL SQL

-- available online in file 'sample1' DECLARE x NUMBER := 100; BEGIN FOR i IN 1..10 LOOP IF MOD(i,2) = 0 THEN -- i is even INSERT INTO temp VALUES (i, x, 'i is even'); ELSE INSERT INTO temp VALUES (i, x, 'i is odd'); END IF; x := x + 100; END LOOP; COMMIT; END;

Groovy

class Person { String name /** * Creates a greeting method for a certain person. * * @param greeted the person to greet * @return a greeting message */ String greet(Person greeted) { "Hello ${greeted.name}" } } def testSwitch(val) { switch (val) { case 52 -> 'Number value match' case "Groovy 4" -> 'String value match' case ~/^Switch.*Groovy$/ -> 'Pattern match' case BigInteger -> 'Class isInstance' case 60..90 -> 'Range contains' case [21, 'test', 9.12] -> 'List contains' case 42.056 -> 'Object equals' case { it instanceof Integer && it < 50 } -> 'Closure boolean' case [groovy: 'Rocks!', version: '1.7.6'] -> "Map contains key '$val'" default -> 'Default' } }

Gradle

plugins { id 'org.jetbrains.kotlin.jvm' version '1.9.0' id 'application' } repositories { mavenCentral() } dependencies { implementation 'org.jproggy.snippetory::snippetory-core::0.9.7' }

Ant

<project name="MyProject" default="dist" basedir="."> <description> simple example build file </description> <!-- set global properties for this build --> <property name="src" location="src"/> <target name="init"> <!-- Create the time stamp --> <tstamp/> <!-- Create the build directory structure used by compile --> <mkdir dir="${build}"/> </target> </project>

Ini

[Section1] # comment entry1=value1

Yaml

--- apiVersion: v3 kind: Pod metadata: name: "rss-site" labels: app: web

Properties

# comment entry1=value1 \ continuation of value1

Apache Configs

# Ensure that Apache listens on port 80 Listen 80 ServerRoot "/usr" LoadModule authn_file_module libexec/apache2/mod_authn_file.so <VirtualHost *:80> DocumentRoot "/www/example1" ServerName www.example.com # Other directives here </VirtualHost>