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

sZ=i=1N(ZiMZ)2N1sZ2=i=1N(Zi0)2N1sZ2=1N1i=1NZi2sZ2=1N1i=1N(XiMXs)2sZ2=1N1×1s2×i=1N(XiMX)2sZ2=1s2×i=1N(XiMX)2N1sZ2=1s2×s2sZ2=1sZ=1=1\begin{align*}s_{Z} &= \sqrt{\frac{\sum_{i=1}^{N} (Z_{i}-M_{Z})^2}{N-1}}\\s_{Z}^2 &= \frac{\sum_{i=1}^{N} (Z_{i}-0)^2}{N-1}\\s_{Z}^2 &= \frac{1}{N-1}\sum_{i=1}^{N} Z_{i}^2\\s_{Z}^2 &= \frac{1}{N-1}\sum_{i=1}^{N} \left(\frac{X_{i}-M_{X}}{s}\right)^2\\s_{Z}^2 &= \frac{1}{N-1} \times \frac{1}{s^2} \times \sum_{i=1}^{N} (X_{i}-M_{X})^2\\s_{Z}^2 &= \frac{1}{s^2} \times \frac{\sum_{i=1}^{N} (X_{i}-M_{X})^2}{N-1}\\s_{Z}^2 &= \frac{1}{s^2} \times s^2\\s_{Z}^2 &= 1\\s_{Z} &= \sqrt{1} = 1\end{align*}

Two equation blocks one after the other

   AaBbc   C=D\begin{CD}    A @>a>> B \\ @VbVV @AAcA \\    C @= D \end{CD}
MZ=i=1NZiN=1Ni=1N(XiMXs)=1sNi=1N(XiMX)=1sN(i=1NXiNMX)=1s(i=1NXiNMX)=1s(MXMX)MZ=0\begin{align*}M_{Z} &= \frac{\sum_{i=1}^{N} Z_{i}}{N}\\&= \frac{1}{N}\sum_{i=1}^{N} \left(\frac{X_{i}-M_{X}}{s}\right)\\&= \frac{1}{sN}\sum_{i=1}^{N}(X_{i}-M_{X})\\&= \frac{1}{sN}\left(\sum_{i=1}^{N}X_{i} - NM_{X}\right)\\&= \frac{1}{s}\left(\frac{\sum_{i=1}^{N}X_{i}}{N} - M_{X}\right)\\&= \frac{1}{s}(M_{X} - M_{X})\\M_{Z} &= 0\end{align*}