Code & Equations

Code blocks

Potion uses highlight.js for syntax highlighting with base16-one-light as the default theme. A selection of light and dark themes can be used for your site.

CSS code

p {
  color: #442200;
  width: 500px;
  border: 1px solid black;
}
p,
li,
h1 {
  color: red;
}

bash script

#!/bin/bash

for i in /var/*; do
	echo $i 
done

for ((i = 0 ; i < 10 ; i++)); do
	echo "Hello Friend"
done

Code blocks with captions

# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

"""
Purpose

Shows how to implement an AWS Lambda function that handles input from direct
invocation.
"""

# snippet-start:[python.example_code.lambda.handler.arithmetic]
import logging
import os


logger = logging.getLogger()

# Define a list of Python lambda functions that are called by this AWS Lambda function.
ACTIONS = {
    "plus": lambda x, y: x + y,
    "minus": lambda x, y: x - y,
    "times": lambda x, y: x * y,
    "divided-by": lambda x, y: x / y,
}


def lambda_handler(event, context):
    """
    Accepts an action and two numbers, performs the specified action on the numbers,
    and returns the result.

    :param event: The event dict that contains the parameters sent when the function
                  is invoked.
    :param context: The context in which the function is called.
    :return: The result of the specified action.
    """
    # Set the log level based on a variable configured in the Lambda environment.
    logger.setLevel(os.environ.get("LOG_LEVEL", logging.INFO))
    logger.debug("Event: %s", event)

    action = event.get("action")
    func = ACTIONS.get(action)
    x = event.get("x")
    y = event.get("y")
    result = None
    try:
        if func is not None and x is not None and y is not None:
            result = func(x, y)
            logger.info("%s %s %s is %s", x, action, y, result)
        else:
            logger.error("I can't calculate %s %s %s.", x, action, y)
    except ZeroDivisionError:
        logger.warning("I can't divide %s by 0!", x)

    response = {"result": result}
    return response


# snippet-end:[python.example_code.lambda.handler.arithmetic]
https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/python/example_code/lambda/lambda_handler_calculator.py
const testElements = document.getElementsByClassName("test");
const testDivs = Array.prototype.filter.call(
  testElements,
  (testElement) => testElement.nodeName === "DIV",
);
test-file.js
<html lang="en">
  <body>
    <div id="parent-id">
      <p>hello world 1</p>
      <p class="test">hello world 2</p>
      <p>hello world 3</p>
      <p>hello world 4</p>
    </div>

    <script>
      const parentDOM = document.getElementById("parent-id");

      // a list of matching elements, *not* the element itself
      const test = parentDOM.getElementsByClassName("test");
      console.log(test);

      const testTarget = parentDOM.getElementsByClassName("test")[0];
      console.log(testTarget);
    </script>
  </body>
</html>
Example.html

Equations

We can do inline equations like this n=12n=1\sum_{n=1}^{\infty} 2^{-n} = 1 or show a simple integral abx2dx\int_{a}^{b} x^2 \,dx

A first equation block

   a=b+c      =e+f\begin{equation} \begin{split}   a &=b+c\\       &=e+f \end{split} \end{equation}

Two equation blocks one after the other

   AaBbc   C=D\begin{CD}    A @>a>> B \\ @VbVV @AAcA \\    C @= D \end{CD}
(ab)2=(ab)(ab)=a(ab)b(ab)=a2abba+b2=a2+2ab+b2\begin{equation} \begin{split} (a - b)^2 &= (a - b)(a - b) \\ &= a(a - b) - b(a - b) \\ &= a^2 -ab -ba + b^2 \\ &= a^2 + 2ab + b^2 \end{split} \end{equation}