# Header 1
## Header 2
### Header 3

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum

WyPyPlus can generate headline anchor links. If you want to turn on this feature, replace the headline function:
```
hl=lambda m,n:'<h%d>%s</h%d>'%(n,m.group(1),n)
```
with
```
hl=lambda m,n:'<h%d id=%s>%s<a href=#%s> ¶</a></h%d>'%(n,hs(m),m.group(1),hs(m),n);
```

## Bold

This is a **Bold** text!

## Links

YouTube Video:

https://www.youtube.com/watch?v=0v5lKOQka9c

List everything in this wiki: @All

Wiki link: DemoPage

Raw URL link:   http://www.google.com

Markdown link: [google homepage](http://google.com)

Reference to a date or a month: Jan1 Jan2021

## Template

A template is a page with a special name: Tpl[three characters]. A page starts with the same three characters will use the template.

For example, when you create TplJan, Any page starts with "Jan" such as Jan21 will include the template. 

## Images

External image:

![test image](https://upload.wikimedia.org/wikipedia/commons/5/5f/Emacs-logo.svg)

Local image:

![local image](../screenshots/example.png)

## Quote


```
# Python Code
def hello():
  print("hello world")
```

## List

{{
* Item A
{{
* Item A1
* Item A2
}}
* Item B
}}

## Page Break

---

## Table

WyPyPlus supports [media wiki style table](https://www.mediawiki.org/wiki/Help:Tables).
{|
|Orange
|Apple
|-
|Bread
|Pie
|-
|Butter
|Ice cream 
|}

{|
|  Orange || Apple || more
|-
|   Bread || Pie || more
|-
|   Butter || Ice cream || and more
|}

## The RPN Calculator

The built-in RPN calculator supports 
* Basic math operations: +, -, *, and /
* Control flow: if else then
* Compare: > < =
* Stack operations: dup, over, swap, drop, and rot
* Other functions: ^(pow), log, sqrt, abs, sin, cos, and tan
* Print operations: . cr

### Basic Math
{|
| 1 1 + || RPN(1 1 +) 
|-
| 1 1 - || RPN(1 1 -)
|-
| 2 2 * || RPN(2 2 *)
|-
| 10 5 / || RPN(10 5 /)
|-
| 2 3 ^ || RPN(2 3 ^)
|-
| 5 10  randint || RPN(5 10 randint ) 
|-
| Print error message: || RPN(2 3 abcde)
|} 

### Control Flow
{|
| 2 3 > if "yes" else "no" then || RPN(2 3 > if "yes" else "no" then) 
|-
| "a" "a" = if "yes" else "no" then || RPN("a" "a" = if "yes" else "no" then)
|}

### User Defined Functions
A user can define new functions with the following syntax:

RPN (: <fun name> <fun content> ;)

Two examples:

RPN (: squire dup * ;)
RPN(: squire dup * ;)

RPN (: pythagoras squire swap squire + sqrt ;)
RPN(: pythagoras squire swap squire + sqrt ;)



### Built-in and User Defined Functions
{|
| 3 squire  || RPN(3 squire)
|-
| 3 4 pythagoras  || RPN(3 4 pythagoras)
|-
| 1000 10 log || RPN(1000 10 log)
|-
| e 1000 log || RPN( 2.718281 1000 log)
|-
| 3.1415926 2 / sin || RPN( 3.1415926 2 / sin )
|-
| -10 fabs || RPN(-10 fabs) 
|-
| "hello" 0 3 slice || RPN("hello" 0 3 slice)
|}

### Stack & Print Operations
{|
| 1 dup || RPN(1 dup)
|-
| 2 1 swap || RPN(2 1 swap)
|-
| 10 5 drop  || RPN(10 5 drop)
|-
| 1 2 3 rot || RPN(1 2 3 rot)
|-
| 100 . || RPN(100 .)
|-
| "hello" . cr cr " world" . || RPN("hello" . cr cr " world" .)
|} 

### Use RPN in a Table

You can create a simple spreadsheet by embedding RPN expressions in a table. A RPN expression in the table must start with '='.  

* $X : Reference a cell on the same row. X starts from 0.
* @X: Reference a cell on the same column. X starts from 0.

You can use range functions: **sum** and **avg** 
* $X..$Y: Reference a range on the same row. $Y is included.
* @X..@Y: Reference a range on the same column. $Y is included.

{|Example
| || A || B || `A^2 + B^2`|| `sqrt(A^2 + B^2)` || Total || Average
|-
|  || 3  || 4 ||=$1 2 ^ $2 2 ^ + ||= $1 $2 pythagoras ||= $1..$4 sum || =$1..$4 avg
|-
|  || 6  || 8 ||=$1 2 ^ $2 2 ^ + ||= $1 $2 pythagoras ||= $1..$4 sum || =$1..$4 avg
|-
|  || 9  || 12 ||=$1 2 ^ $2 2 ^ + || = $1 $2 pythagoras ||= $1..$4 sum|| =$1..$4 avg
|-
| Total || =@1..@3 sum  || =@1..@3 sum   || =@1..@3 sum  || =@1..@3 sum || =@1..@3 sum 
|}

### Probabilities for the two dice
{|
| Total	|| Number of combinations || Probability
|-
| 2	|| 1	||=$1 @12$1 / 
|-
| 3	|| 2	||=$1 @12$1 / 
|-
| 4	|| 3	||=$1 @12$1 / 
|-
| 5	|| 4	||=$1 @12$1 / 
|-
| 6	|| 5	||=$1 @12$1 / 
|-
| 7	|| 6	||=$1 @12$1 / 
|-
| 8	|| 5	||=$1 @12$1 / 
|-
| 9	|| 4	||=$1 @12$1 / 
|-
| 10	|| 3	||=$1 @12$1 / 
|-
| 11	|| 2	||=$1 @12$1 / 
|-
| 12	|| 1	||=$1 @12$1 / 
|-
| Total ||=@1..@11 sum ||=@1..@11 sum 
|}

You can add more functions to the built-in RPN by modifying the rpn.py file.

##  Math Notation with [Ascii Math](http://asciimath.org)

`
sum_(i=1)^n i^3=((n(n+1))/2)^2
`

## Synatx Highlight with [highlight.js](https://highlightjs.org) (Optional) 

Insert the following line to the <head> section at the end of wypyplus.py to support synatx highligh for over 150 languages.
```
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.1.0/styles/default.min.css">\
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.1.0/highlight.min.js"></script><script>hljs.highlightAll();</script>
```
