Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 0 additions & 71 deletions assets/highlighting-tests/bash.sh

This file was deleted.

117 changes: 117 additions & 0 deletions assets/highlighting-tests/javascript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
// Comments
// Single-line comment

/*
* Multi-line
* comment
*/

// Numbers
42;
3.14;
.5;
1e10;
1.5e-3;
0xff;
0xFF;
0b1010;
0o77;
1_000_000;
42n;

// Constants
true;
false;
null;
undefined;
NaN;
Infinity;

// Strings
'single quotes with escape: \' \n \t \\';
"double quotes with escape: \" \n \t \\";

// Control flow keywords
if (true) {
} else if (false) {
} else {
}

for (let i = 0; i < 10; i++) {
if (i === 5) continue;
if (i === 8) break;
}

while (false) { }
do { } while (false);

switch (42) {
case 1: break;
default: break;
}

try {
throw new Error("oops");
} catch (e) {
} finally {
}

debugger;

// Template literals
`template literal: ${1 + 2} and ${greet("world")}`;
`multi
line
template`;

// Other keywords (some are contextually reserved)
var a = 1;
let b = 2;
const c = 3;

function greet(name) {
return "Hello, " + name;
}

async function fetchData() {
const result = await fetch("/api");
return result;
}

function* gen() {
yield 1;
yield 2;
}

class Animal extends Object {
static count = 0;

constructor(name) {
super();
this.name = name;
Animal.count++;
}

speak() {
return `${this.name} speaks`;
}
}

const obj = { a: 1 };
delete obj.a;
typeof obj;
void 0;
"a" instanceof Object;
"a" in obj;

import { readFile } from "fs";
export const PI = 3.14;
for (const x of [1, 2]) { }
for (const k in { a: 1 }) { }

// Function calls
console.log("hello");
Math.max(1, 2);
[1, 2, 3].map(x => x * 2);
greet("world");
parseInt("42");
11 changes: 11 additions & 0 deletions assets/highlighting-tests/markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,21 @@ Reference: ![Logo][logo-ref]
echo "Hello, world" | tr a-z A-Z
```

```javascript
export function greet(name) {
return `hello ${name}`;
}
```

```json
{
"name": "gfm-kitchen-sink",
"private": true,
"scripts": { "test": "echo ok" }
}
```

```python
def greet(name: str) -> str:
return f"hello {name}"
```
142 changes: 142 additions & 0 deletions assets/highlighting-tests/python.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# Comments
# Single-line comment

# Numbers
42
3.14
.5
1e10
1.5e-3
0xff
0xFF
0b1010
0o77
1_000_000
3.14j

# Constants
True
False
None

# Strings
'single quotes: \' \n \t \\'
"double quotes: \" \n \t \\"

# Control flow keywords
if True:
pass
elif False:
pass
else:
pass

for i in range(10):
if i == 5:
continue
if i == 8:
break

while False:
pass

match 42:
case 1:
pass
case _:
pass

try:
raise ValueError("oops")
except ValueError as e:
pass
finally:
pass

with open("/dev/null") as f:
pass

return # (only valid inside a function)

# Triple-quoted strings
"""
Multi-line
docstring (double quotes)
"""

'''
Multi-line
string (single quotes)
'''

# Prefixed strings (f, r, b)
f"f-string: {1 + 2}"
r"raw string: \n is literal"
b"byte string"

# Decorators
@staticmethod
def helper():
pass

@property
def name(self):
return self._name

@custom_decorator
def decorated():
pass

# Other keywords (some are contextually reserved)
import os
from os import path
import sys as system

def greet(name):
return "Hello, " + name

async def fetch_data():
result = await some_coroutine()
return result

class Animal:
count = 0

def __init__(self, name):
self.name = name
Animal.count += 1

def speak(self):
return f"{self.name} speaks"

class Dog(Animal):
pass

lambda x: x + 1

x = 1
del x
assert True
not False
True and False
True or False
1 is 1
1 is not 2
1 in [1, 2]

global _g
nonlocal # (only valid inside nested function)

def gen():
yield 1
yield from [2, 3]

type Alias = int

# Function calls
print("hello")
len([1, 2, 3])
list(range(10))
greet("world")
int("42")
"hello".upper()
Loading
Loading