This page is for testing the syntax highlighting features and color theme.

Bash

#!/usr/bin/env bash
STR="Hello World!"
e () {
  echo $1
}
e $STR
# Simple calculator
calc () {
  local result="";
  result="$(printf "scale=10;$*\n" | bc --mathlib | tr -d '\\\n')";
  #                       └─ default (when `--mathlib` is used) is 20
  if [[ "$result" == *.* ]]; then
    # improve the output for decimal numbers
    printf "$result" |
    sed -e 's/^\./0./'        `# add "0" for cases like ".5"` \
        -e 's/^-\./-0./'      `# add "0" for cases like "-.5"`\
        -e 's/0*$//;s/\.$//';  # remove trailing zeros
  else
    printf "$result"
  fi
  printf "\n"
}

CSS

body:before {
  content: 'Hello World!';
}
html {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  -ms-text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}
.test input[type="number"]::-webkit-inner-spin-button {
  height: auto;
}

Elixir

defmodule HelloModule do
  # A "Hello world" function
  def some_fun do
    IO.puts "Hello World!"
  end
  # This one works only with lists
  def some_fun(list) when is_list(list) do
    IO.inspect list
  end
  # A private function
  defp priv do
    :secret_info
  end
end
HelloModule.some_fun
#=> "Hello World!"
kw = [another_key: 20, key: 10]
kw[:another_key]
#=> 20
Regex.run ~r/abc\s/, "abc "
#=> ["abc "]

Go

package main

import "fmt"

func main() {
  fmt.Println("Hello World!")

  if 7%2 == 0 {
    fmt.Println("7 is even")
  } else {
    fmt.Println("7 is odd")
  }

  if num := 9; num < 0 {
    fmt.Println(num, "is negative")
  } else if num < 10 {
    fmt.Println(num, "has 1 digit")
  } else {
    fmt.Println(num, "has multiple digits")
  }
}

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="schema.DC" href="http://purl.org/dc/elements/1.1/">
    <link rel="schema.DCTERMS" href="http://purl.org/dc/terms/">
    <title>Hello World!</title>
    <meta name="description" content="Pygments test for HTML syntax">
    <meta name="keywords" content="hello, world, test, pygments, html">
    <link rel="alternate" type="application/rss+xml" title="Hello World Test" href="/feed.xml">
    <link href="https://fonts.googleapis.com/css?family=Lora:700,700italic,400italic,400" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="/css/main.css">
    <link rel="icon" type="image/x-icon" href="/favicon.ico">
    <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
    <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
    <link rel="manifest" href="/site.webmanifest">
    <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#222222">
    <meta name="msapplication-TileColor" content="#222222">
    <meta name="theme-color" content="#222222">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js"></script>
    <!--[if lt IE 9]>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
    <article class="page" itemscope itemtype="http://schema.org/WebPage">
      <header class="page-header">
        <h1 itemprop="name headline">Hello World!</h1>
        <div class="page-date">
          Published <time datetime="2019-07-09T17:21:28-04:00" itemprop="datePublished">09 Jul 2019</time>
        </div>
        <div class="page-author">
          By <span itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">Tes Ting Name</span></span>
        </div>
      </header>
      <section class="page-content" itemprop="mainContentOfPage">
        Words&hellip;
      </section>
    </article>
  </body>
  <footer id="site-footer">
    <div class="footer-copyright"><abbr title="Copyright">&copy;</abbr> 2019 Hello World Test</div>
  </footer>
</html>

Java

import java.io.File;
import java.io.IOException;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class HelloWorld {
  public static void main(String[] args) {
    System.out.println("Hello World!");
  }
}

public class SimpleWordCounter {
  public static void main(String[] args) {
    try {
      File f = new File("filename.txt");
      Scanner sc;
      sc = new Scanner(f);
      // sc.useDelimiter("[^a-zA-Z']+");
      Map<String, Integer> wordCount = new TreeMap<String, Integer>();
      while(sc.hasNext()) {
        String word = sc.next();
        if(!wordCount.containsKey(word))
          wordCount.put(word, 1);
        else
          wordCount.put(word, wordCount.get(word) + 1);
      }
      // show results
      for(String word : wordCount.keySet())
        System.out.println(word + " " + wordCount.get(word));
      System.out.println(wordCount.size());
    }
    catch(IOException e) {
      System.out.println("Unable to read from file.");
    }
  }
}

JavaScript

const helloWorld = 'Hello World!';
let body = document.querySelector('body');
if (body != undefined) {
  // Print to page
  body.textContent = helloWorld;
} else {
  // Print to console
  console.log(helloWorld);
  // Send alert message
  alert('\'helloWorld\' could not be printed to page.');
}
// jQuery Character Counter for inputs and text areas
$(".word_count").each(function() {
  var charlength = $(this).val().length;
  $(this).parent().parent().find(".counter").html(charlength + ' characters');
  $(this).keyup(function() {
    var new_charlength = $(this).val().length;
    $(this).parent().parent().find(".counter").html(new_charlength + ' characters');
  });
});

PHP

<?php
class HelloWorld {
  // property declaration
  public $text = 'Hello World!';
  // static method declaration
  static public function display() {
    $obj = new static;
    echo $obj->text;
  }
}
HelloWorld::display();

Python

print("Hello World!")
# Program to display the Fibonacci sequence up to n-th term where n is provided by the user
# change this value for a different result
nterms = 10
# uncomment to take input from the user
#nterms = int(input("How many terms? "))
# first two terms
n1 = 0
n2 = 1
count = 0
# check if the number of terms is valid
if nterms <= 0:
  print("Please enter a positive integer")
elif nterms == 1:
  print("Fibonacci sequence upto",nterms,":")
  print(n1)
else:
  print("Fibonacci sequence upto",nterms,":")
  while count < nterms:
    print(n1,end=' , ')
    nth = n1 + n2
    # update values
    n1 = n2
    n2 = nth
    count += 1

Ruby

puts 'Hello World!'

def print_hi(name)
  puts "Hi, #{name}"
end
print_hi('Sean'.upcase())
#=> prints 'Hi, SEAN' to STDOUT.
class String
  def NullOrEmpty?
  (self == nil || self == "")
  end
end
puts "test".NullOrEmpty?
puts "".NullOrEmpty?

Sass

body {
  &:before {
    content: 'Hello World!';
  }
}
html {
  -ms-text-size-adjust: 100%; // 2
  -webkit-text-size-adjust: 100%; // 2
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; // 1
}
.test {
  input {
    &[type='number'] {
      &::-webkit-outer-spin-button {
        height: auto;
      }
    }
  }
}
@mixin bg-variant($parent, $color) {
  #{$parent} {
    background-color: $color;
  }
  a#{$parent}:hover,
  a#{$parent}:focus {
    background-color: darken($color, 10%);
  }
}
@mixin make-row($gutter: $grid-gutter-width) {
  @include clearfix;
  margin-left:  ceil(($gutter / -2));
  margin-right: floor(($gutter / -2));
}

YAML

openapi: '3.0.0'
info:
  title: 'Sample API'
  version: '1.0.0-development'
  description: |
    This is the Sample API.

    For this sample, you can use the api key `special-key` to test the authorization filters.
  contact:
    name: engineering@domain.com
  termsOfService: https://www.domain.com/terms/
  license:
    name: Private
    url: https://www.domain.com/license
servers:
  - url: https://localhost:3000
  - url: https://api.domain.com
# ---
paths:
  # ----------------------------------------------------------------------------
  /articles:
    get:
      tags:
        - Articles
      summary: List Articles by criteria
      description: Returns list of Articles
      operationId: getArticles
      parameters:
        - name: body
          in: query
          description: Article object properties
          required: false
          schema:
            $ref: '#/components/schemas/Article'
      responses:
        '200':
          description: successful operation
          headers:
            x-next:
              description: A link to the next page of responses
              schema:
                type: string
          content:
            application/json:
              schema:
                type: object
                properties:
                  metadata:
                    type: object
                    properties:
                      message:
                        type: string
                      status:
                        type: string
                  data:
                    $ref: '#/components/schemas/Article'
        '400':
          description: Invalid criteria supplied
        '404':
          description: No matching articles found
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Thing'
      security:
        - apiKey: []
        - OAuth2:
          - read
    post:
      tags:
        - Articles
      summary: Create new Article
      description: ''
      operationId: createArticle
      parameters:
        - in: query
          name: body
          description: Article object that needs to be added
          required: false
          schema:
            $ref: '#/components/schemas/Article'
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: object
                properties:
                  metadata:
                    type: object
                    properties:
                      message:
                        type: string
                      status:
                        type: string
                  data:
                    $ref: '#/components/schemas/Article'
        '400':
          description: Invalid ID supplied
        '404':
          description: Article not found
        '405':
          description: Validation exception
      security:
        - OAuth2:
          - read
          - write
  # ----------------------------------------------------------------------------
  /articles/{id}:
    get:
      tags:
        - Articles
      summary: Find Article by ID
      description: Returns Article
      operationId: findArticleById
      parameters:
        - name: id
          in: path
          description: ID of Article that needs to be retrieved
          required: true
          schema:
            type: integer
            format: int64
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: object
                properties:
                  metadata:
                    type: object
                    properties:
                      message:
                        type: string
                      status:
                        type: string
                  data:
                    $ref: '#/components/schemas/Article'
        '400':
          description: Invalid ID supplied
        '404':
          description: Article not found
      security:
        - apiKey: []
        - OAuth2:
          - read
    put:
      tags:
        - Articles
      summary: Update existing Article
      description: ''
      operationId: updateArticle
      parameters:
        - name: id
          in: path
          description: ID of Article that needs to be updated
          required: true
          schema:
            type: integer
            format: int64
        - name: body
          in: query
          description: Article object with revisions
          required: false
          schema:
            $ref: '#/components/schemas/Article'
      responses:
        '405':
          description: Invalid input
      security:
        - OAuth2:
          - read
          - write
    delete:
      tags:
        - Articles
      summary: Delete Article
      description: ''
      operationId: deleteArticle
      parameters:
        - name: apiKey
          in: header
          description: ''
          required: true
          schema:
            type: string
        - name: id
          in: path
          description: Article id to delete
          required: true
          schema:
            type: integer
            format: int64
      responses:
        '400':
          description: Invalid article value
      security:
        - OAuth2:
          - read
          - write
# ---
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
    OAuth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://api.domain.com/auth/authorize
          tokenUrl: https://api.domain.com/auth/token
          scopes:
            read: Grants read access
            write: Grants write access
            admin: Grants access to admin operations
  schemas:
    # ----------------------------------------------------------------------------
    Action:
      allOf:
        - $ref: '#/components/schemas/Thing'
        - type: object
          description: An action performed by a direct agent and indirect participants upon a direct object. Optionally happens at a location with the help of an inanimate instrument. The execution of the action may produce a result. Specific action sub-type documentation specifies the exact expectation of each argument/role.
          properties:
            actionStatus: # Indicates the current disposition of the Action.
              $ref: '#/components/schemas/ActionStatusType'
            agent: # The direct performer or driver of the action (animate or inanimate).
              $ref: '#/components/schemas/Person'
    # ----------------------------------------------------------------------------
    ActionStatusType:
      allOf:
        - $ref: '#/components/schemas/Enumeration'
        - type: object
          description: The status of an Action.
    # ----------------------------------------------------------------------------
    Article:
      allOf:
        - $ref: '#/components/schemas/CreativeWork'
        - type: object
          description: An article, such as a news article or piece of investigative report. Newspapers and magazines have articles of many different types and this is intended to cover them all.
          properties:
            articleBody:
              type: string
              description: The actual body of the article.
            articleSection:
              type: string
              description: Articles may belong to one or more 'sections' in a magazine or newspaper, such as Sports, Lifestyle, etc.
    # ----------------------------------------------------------------------------
    ContactPoint:
      allOf:
        - $ref: '#/components/schemas/StructuredValue'
        - type: object
          description: A contact point—for example, a Customer Complaints department.
          properties:
            contactType:
              type: string
              description: A person or organization can have different contact points, for different purposes. For example, a sales contact point, a PR contact point and so on. This property is used to specify the kind of contact point.
            email:
              type: string
              description: Email address.
            faxNumber:
              type: string
              description: The fax number.
            telephone:
              type: string
              description: The telephone number.
    # ----------------------------------------------------------------------------
    CreativeWork:
      allOf:
        - $ref: '#/components/schemas/Thing'
        - type: object
          description: The most generic kind of creative work, including books, movies, photographs, software programs, etc.
          properties:
            about:
              type: string
              description: The subject matter of the content. Inverse property; 'subjectOf'.
            author: # The author of this content or rating. Please note that author is special in that HTML 5 provides a special mechanism for indicating authorship via the rel tag. That is equivalent to this and may be used interchangeably.
              $ref: '#/components/schemas/Person'
            citation: # A citation or reference to another creative work, such as another publication, web page, scholarly article, etc.
              $ref: '#/components/schemas/CreativeWork'
            contributor: # A secondary contributor to the CreativeWork or Event.
              $ref: '#/components/schemas/Person'
    # ----------------------------------------------------------------------------
    Enumeration:
      allOf:
        - $ref: '#/components/schemas/Intangible'
        - type: object
          description: Lists or enumerations—for example, a list of cuisines or music genres, etc.
    # ----------------------------------------------------------------------------
    Intangible:
      allOf:
        - $ref: '#/components/schemas/Thing'
        - type: object
          description: A utility class that serves as the umbrella for a number of 'intangible' things such as quantities, structured values, etc.
    # ----------------------------------------------------------------------------
    Organization:
      allOf:
        - $ref: '#/components/schemas/Thing'
        - type: object
          description: An organization such as a school, NGO, corporation, club, etc.
          properties:
            address:
              oneOf:
                - type: string
                - $ref: '#/components/schemas/PostalAddress'
              description: Physical address of the item.
            contactPoint: # A contact point for a person or organization. Supersedes 'contactPoints'.
              $ref: '#/components/schemas/ContactPoint'
            department: # A relationship between an organization and a department of that organization, also described as an organization (allowing different urls, logos, opening hours).
              $ref: '#/components/schemas/Organization'
            email:
              type: string
              description: Email address.
            employee: # Someone working for this organization. Supersedes employees.
              $ref: '#/components/schemas/Person'
    # ----------------------------------------------------------------------------
    Person:
      allOf:
        - $ref: '#/components/schemas/Thing'
        - type: object
          description: A person (alive, dead, undead, or fictional).
          properties:
            additionalName:
              type: string
              description: An additional name for a Person, can be used for a middle name.
            address:
              oneOf:
                - type: string
                - $ref: '#/components/schemas/PostalAddress'
              description: Physical address of the item.
            affiliation: # An organization that this person is affiliated with. For example, a school/university, a club, or a team.
              $ref: '#/components/schemas/Organization'
            email:
              type: string
              description: Email address.
            familyName:
              type: string
              description: Family name. In the U.S., the last name of an Person. This can be used along with givenName instead of the name property.
            givenName:
              type: string
              description: Given name. In the U.S., the first name of a Person. This can be used along with familyName instead of the name property.
    # ----------------------------------------------------------------------------
    PostalAddress:
      allOf:
        - $ref: '#/components/schemas/ContactPoint'
        - type: object
          description: The mailing address.
          properties:
            addressCountry:
              type: string
              description: The country. For example, USA. You can also provide the two-letter ISO 3166-1 alpha-2 country code.
            addressLocality:
              type: string
              description: The locality. For example, Mountain View.
            addressRegion:
              type: string
              description: The region. For example, CA.
            postOfficeBoxNumber:
              type: string
              description: The post office box number for PO box addresses.
            postalCode:
              type: string
              description: The postal code. For example, 94043.
            streetAddress:
              type: string
              description: The street address. For example, 1600 Amphitheatre Pkwy.
    # ----------------------------------------------------------------------------
    PropertyValue:
      allOf:
        - $ref: '#/components/schemas/StructuredValue'
        - type: object
          description: A property-value pair, e.g. representing a feature of a product or place. Use the 'name' property for the name of the property. If there is an additional human-readable version of the value, put that into the 'description' property.
    # ----------------------------------------------------------------------------
    Review:
      allOf:
        - $ref: '#/components/schemas/CreativeWork'
        - type: object
          description: A review of an item - for example, of a restaurant, movie, or store.
          properties:
            author:
              $ref: '#/components/schemas/Person'
    # ----------------------------------------------------------------------------
    ScholarlyArticle:
      allOf:
        - $ref: '#/components/schemas/Article'
        - type: object
          description: A scholarly article.
    # ----------------------------------------------------------------------------
    StructuredValue:
      allOf:
        - $ref: '#/components/schemas/Thing'
        - type: object
          description: Structured values are used when the value of a property has a more complex structure than simply being a textual value or a reference to another thing.
    # ----------------------------------------------------------------------------
    Thing:
      type: object
      description: The most generic type of item.
      properties:
        _id:
          type: string
          description: Hexstring unique identifier. Generated automatically for new instances.
        additionalType:
          type: string
          description: An additional type for the item, typically used for adding more specific types from external vocabularies in microdata syntax. This is a relationship between something and a class that the thing is in. In RDFa syntax, it is better to use the native RDFa syntax - the 'typeof' attribute - for multiple types. Schema.org tools may have only weaker understanding of extra types, in particular those defined externally.
        alternateName:
          type: string
          description: An alias for the item.
        description:
          type: string
          description: A description of the item.
        identifier:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/PropertyValue'
          description: The identifier property represents any kind of identifier for any kind of Thing, such as ISBNs, GTIN codes, UUIDs etc. Schema.org provides dedicated properties for representing many of these, either as textual strings or as URL (URI) links.
        name:
          type: string
          description: The name of the item.
        potentialAction:
          $ref: '#/components/schemas/Action'
        url:
          type: string
          description: URL of the item.