mirror of
https://github.com/catppuccin/catppuccin
synced 2024-11-21 11:03:05 +00:00
chore: add more sample code (#2168)
This commit is contained in:
parent
1c5a013e5f
commit
aa608f17a5
22 changed files with 843 additions and 165 deletions
19
samples/Makefile
Normal file
19
samples/Makefile
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Simple Makefile
|
||||
include make.mk
|
||||
|
||||
all: hello ## Doc comment
|
||||
|
||||
hello: hello.o world.o
|
||||
.PHONY: hello
|
||||
|
||||
GCC = gcc \
|
||||
-O2
|
||||
|
||||
.o.c:
|
||||
ifeq ($(FOO),'bar')
|
||||
$(GCC) -c qwe \
|
||||
-Wall
|
||||
else
|
||||
echo "Hello World"
|
||||
$(error Architecture $(ARCH) is not supported)
|
||||
endif
|
121
samples/asciidoc.adoc
Normal file
121
samples/asciidoc.adoc
Normal file
|
@ -0,0 +1,121 @@
|
|||
= Hello, AsciiDoc!
|
||||
|
||||
This is an interactive editor.
|
||||
Use it to try https://asciidoc.org[AsciiDoc].
|
||||
|
||||
Italic text is surrounded by _underscores_.
|
||||
Bold text is surrounded by *asterisks*.
|
||||
|
||||
== Section Title
|
||||
|
||||
* A list item
|
||||
* Another list item
|
||||
- A third list item
|
||||
|
||||
Some Stuff
|
||||
|
||||
1. A numbered list item
|
||||
2. Another numbered list item
|
||||
3. A third numbered list item
|
||||
|
||||
[,ruby]
|
||||
----
|
||||
puts 'Hello, World!'
|
||||
----
|
||||
|
||||
|
||||
= h1
|
||||
|
||||
== h2
|
||||
|
||||
=== h3
|
||||
|
||||
==== h4
|
||||
|
||||
===== h5
|
||||
|
||||
====== h6
|
||||
|
||||
|
||||
= Chapter Title
|
||||
|
||||
|
||||
|
||||
A paragraph with *bold* and _italic_ text.
|
||||
|
||||
|
||||
|
||||
.Image title
|
||||
|
||||
image::an-image.jpg[align=center]
|
||||
|
||||
|
||||
|
||||
The `xref` macro is used for source-to-source links, like xref:a-book.adoc[].
|
||||
|
||||
An external link to https://eclipse.org[Eclipse].
|
||||
|
||||
|
||||
|
||||
NOTE: One of five built-in admonition block types.
|
||||
|
||||
|
||||
= Document Title
|
||||
|
||||
:toc:
|
||||
|
||||
:url-gitlab: https://gitlab.eclipse.org
|
||||
|
||||
|
||||
|
||||
A paragraph with *bold* and _italic_ text.
|
||||
|
||||
A link to https://eclipse.org[Eclipse].
|
||||
|
||||
A reusable link to {url-gitlab}[GitLab].
|
||||
|
||||
|
||||
|
||||
image::an-image.png[An image,800]
|
||||
|
||||
|
||||
|
||||
== Section title
|
||||
|
||||
|
||||
|
||||
* Unordered list item
|
||||
|
||||
** Add another marker to make a nested item
|
||||
|
||||
* Another unordered list item
|
||||
|
||||
|
||||
|
||||
NOTE: One of five built-in admonition block types.
|
||||
|
||||
|
||||
|
||||
=== Subsection title
|
||||
|
||||
|
||||
|
||||
Text indented by one space is preformatted.
|
||||
|
||||
|
||||
|
||||
A source block with a Ruby function named `hello` that prints "`Hello, World!`":
|
||||
|
||||
|
||||
|
||||
[,ruby]
|
||||
|
||||
----
|
||||
|
||||
def hello name = 'World'
|
||||
|
||||
puts "Hello, #{name}!"
|
||||
|
||||
end
|
||||
|
||||
----
|
|
@ -1,23 +1,50 @@
|
|||
#!/usr/bin/env sh
|
||||
#!/usr/bin/env bash
|
||||
IFS=$'\n\t'
|
||||
set -euo pipefail
|
||||
|
||||
#Sample comment
|
||||
let "a=16 << 2";
|
||||
b="Sample text";
|
||||
# This script does nothing in particular
|
||||
# It somehow manages to include most of Bash's syntax elements :)
|
||||
|
||||
function foo() {
|
||||
if [ $string1 == $string2 ]; then
|
||||
for url in `cat example.txt`; do
|
||||
curl $url > result.html
|
||||
done
|
||||
fi
|
||||
# Computes the number 42 using Bash
|
||||
function compute42() {
|
||||
echo $((2 * 3 * (3 + 4)))
|
||||
}
|
||||
|
||||
rm -f $(find / -name core) &> /dev/null
|
||||
mkdir -p "${AGENT_USER_HOME_${PLATFORM}}"
|
||||
# Computes the number 42 using a subshell command
|
||||
function compute42Subshell() {
|
||||
echo "$(echo "2*3*(3+4)" | bc)"
|
||||
}
|
||||
|
||||
multiline='first line
|
||||
second line
|
||||
third line'
|
||||
cat << EOF
|
||||
Sample text
|
||||
# Subtract the second parameter from the first and outputs the result
|
||||
# It can only handle integers
|
||||
function subtract() {
|
||||
local a=${1:?"First param not set"}
|
||||
local b=${2:?"Second param not set"}
|
||||
|
||||
echo -n "$((a - b))"
|
||||
}
|
||||
|
||||
echo 'The current working directory is: '" ${PWD}"
|
||||
|
||||
echo "100 - 58 = $(subtract 100 58)"
|
||||
|
||||
fortyTwo=$(compute42)
|
||||
echo "$fortyTwo is 42"
|
||||
|
||||
fortyTwo=$(compute42Subshell)
|
||||
echo "${fortyTwo} is 42"
|
||||
|
||||
echo "6 * 7 is $fortyTwo" > log.txt 2>&1
|
||||
|
||||
echo `echo This is an echo`
|
||||
|
||||
empty=""
|
||||
[ -z "$empty" ] && This variable is empty!
|
||||
|
||||
cat - << EOF
|
||||
Dear Mr. X,
|
||||
this is a message to you.
|
||||
|
||||
With kind regards,
|
||||
Mr. Y
|
||||
EOF
|
||||
|
|
|
@ -19,12 +19,6 @@ namespace foo {
|
|||
class Class {
|
||||
T n;
|
||||
public:
|
||||
/**
|
||||
* Semantic highlighting:
|
||||
* Generated spectrum to pick colors for local variables and parameters:
|
||||
* Color#1 SC1.1 SC1.2 SC1.3 SC1.4 Color#2 SC2.1 SC2.2 SC2.3 SC2.4 Color#3
|
||||
* Color#3 SC3.1 SC3.2 SC3.3 SC3.4 Color#4 SC4.1 SC4.2 SC4.3 SC4.4 Color#5
|
||||
*/
|
||||
void function(int param1, int param2, int param3) {
|
||||
int localVar1, localVar2, localVar3;
|
||||
int *localVar = new int[1];
|
||||
|
|
31
samples/dart.dart
Normal file
31
samples/dart.dart
Normal file
|
@ -0,0 +1,31 @@
|
|||
library libraryName;
|
||||
import "dart:html" as html;
|
||||
// Comment. Error. Warning. Hint.
|
||||
dynamic topLevelVariable = "Escape sequences: \n \xFF \u1234 \u{2F}";
|
||||
get topLevelGetter { return topLevelVariable; }
|
||||
set topLevelSetter(bool parameter) { print(parameter); }
|
||||
void topLevelFunction(dynamicParameter) {
|
||||
localFunction() {}
|
||||
num localVar = "Invalid escape sequences: \xZZ \uXYZZ \u{XYZ}";
|
||||
var dynamicLocalVar = dynamicParameter + localVar + localFunction();
|
||||
topLevelSetter = dynamicLocalVar + topLevelGetter + topLevelFunction(null);
|
||||
label: while (true) { if (identifier) break label; }
|
||||
}
|
||||
/* block comment */
|
||||
class Foo<K, V> {
|
||||
static var staticField = staticGetter;
|
||||
List instanceField = [566];
|
||||
@deprecated Foo.constructor(this.instanceField) { instanceMethod(); }
|
||||
instanceMethod() { print(instanceField + instanceGetter); }
|
||||
get instanceGetter { instanceSetter = true; }
|
||||
set instanceSetter(_) { staticSetter = null; }
|
||||
static staticMethod() => staticField.unresolved();
|
||||
static get staticGetter { return staticMethod(); }
|
||||
static set staticSetter(Foo param) { #Enum.EnumConstant; }
|
||||
}
|
||||
/// documentation for [Enum]
|
||||
enum Enum { EnumConstant }
|
||||
mixin Mixin {}
|
||||
typedef int FunctionTypeAlias(x, y);
|
||||
extension Ext on int {}
|
||||
±±§§``
|
19
samples/diff.diff
Normal file
19
samples/diff.diff
Normal file
|
@ -0,0 +1,19 @@
|
|||
2c2
|
||||
< int value;
|
||||
---
|
||||
> long value;
|
||||
4,5d3
|
||||
< void leftOnly() {}
|
||||
<
|
||||
7c5
|
||||
< // Left changes
|
||||
---
|
||||
> // Right changes
|
||||
10c8
|
||||
< void bar() {
|
||||
---
|
||||
> void removedFromLeft() {}
|
||||
11a10
|
||||
> void bar() {
|
||||
12a12
|
||||
>
|
|
@ -12,13 +12,6 @@ import alias "fmt"
|
|||
|
||||
//go:generate go tool yacc -o gopher.go -p parser gopher.y
|
||||
|
||||
/*
|
||||
Semantic highlighting:
|
||||
Generated spectrum to pick colors for local variables and parameters:
|
||||
Color#1 SC1.1 SC1.2 SC1.3 SC1.4 Color#2 SC2.1 SC2.2 SC2.3 SC2.4 Color#3
|
||||
Color#3 SC3.1 SC3.2 SC3.3 SC3.4 Color#4 SC4.1 SC4.2 SC4.3 SC4.4 Color#5
|
||||
*/
|
||||
|
||||
type (
|
||||
PublicInterface interface {
|
||||
PublicFunc() int
|
||||
|
|
|
@ -1,33 +1,37 @@
|
|||
var globalVar;
|
||||
|
||||
var globalVar
|
||||
/**
|
||||
* Constructor for AjaxRequest class
|
||||
* @param {string} url the url for the request<p/>
|
||||
* Constructor for <code>AjaxRequest</code> class
|
||||
* @param url the url for the request<p/>
|
||||
*/
|
||||
function AjaxRequest(url) {
|
||||
function local() {}
|
||||
var urls = [ "www.cnn.com", 5, globalVar];
|
||||
this.request = new XMLHttpRequest();
|
||||
url = url.replace(/^\s*(.*)/, "$1"); // skip leading whitespace
|
||||
/* check the url to be in urls */
|
||||
var a = "\u1111\z\n\u11";
|
||||
this.foo = new function() {};
|
||||
foo();
|
||||
#
|
||||
var hello = () => console.log("hello")
|
||||
var urls = ['www.cnn.com', 5, globalVar]
|
||||
this.request = new XMLHttpRequest()
|
||||
url = url.replace(/^\s*(.*)/, '$1') // skip leading whitespace
|
||||
/* check the url to be in urls */
|
||||
var a = '\u1111z\n\u11ac'
|
||||
this.foo = new (function () {})()
|
||||
let a = true && false
|
||||
foo()
|
||||
// #
|
||||
const cons = 'abc'
|
||||
let a = true
|
||||
console.log(cons)
|
||||
}
|
||||
let myObj = {
|
||||
first: 'first',
|
||||
second: 3,
|
||||
o: {
|
||||
hello: 'world',
|
||||
},
|
||||
}
|
||||
|
||||
@decorator()
|
||||
class NameClass {
|
||||
}
|
||||
typeof 'nice'
|
||||
new Class()
|
||||
class NameClass {}
|
||||
foo({ abc: 'abcde' })
|
||||
foo.bar({ foo: 'abc' })
|
||||
obj.abc = function () {}
|
||||
|
||||
declare module name{
|
||||
declare export var exportedVar: string;
|
||||
declare export function exportedFunction(): void;
|
||||
declare export class ExportedClass {}
|
||||
;async () => {
|
||||
await Promise.resolve()
|
||||
}
|
||||
|
||||
interface MyInterface { }
|
||||
type FooBarAlias = string;
|
||||
var html =`<div title='HTML injection'>Injected language fragment</div>`;
|
||||
var x: MyInterface, y: string, z: FooBarAlias;
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
],
|
||||
"strings with": {
|
||||
"no escapes": "pseudopolinomiality"
|
||||
"valid escapes": "C-style\r\n and unicode\u0021",
|
||||
"illegal escapes": "\0377\x\"
|
||||
},
|
||||
"some numbers": [
|
||||
42,
|
||||
|
|
17
samples/jsx.jsx
Normal file
17
samples/jsx.jsx
Normal file
|
@ -0,0 +1,17 @@
|
|||
import React, { useState } from 'react'
|
||||
|
||||
export default function () {
|
||||
const [count, setCount] = useState(0)
|
||||
|
||||
return (
|
||||
<>
|
||||
<main>
|
||||
<h1>IntelliJ IDEA</h1>
|
||||
<img border="0" height="12" src="images/hg.gif" width="18" />
|
||||
What is IntelliJ IDEA? · Α
|
||||
<button onClick={() => setCount(count + 1)}>Click me</button>
|
||||
<div>{count}</div>
|
||||
</main>
|
||||
</>
|
||||
)
|
||||
}
|
|
@ -1,20 +1,16 @@
|
|||
Test Markdown document
|
||||
======================
|
||||
# Test Markdown document
|
||||
|
||||
Text
|
||||
----
|
||||
## Text
|
||||
|
||||
Here is a paragraph with bold text. **This is some bold text.** Here is a
|
||||
paragraph with bold text. __This is also some bold text.__
|
||||
paragraph with bold text. **This is also some bold text.**
|
||||
|
||||
Here is another one with italic text. *This is some italic text.* Here is
|
||||
Here is another one with italic text. _This is some italic text._ Here is
|
||||
another one with italic text. _This is some italic text._
|
||||
|
||||
Here is another one with struckout text. ~~This is some struckout text.~~
|
||||
|
||||
|
||||
Links
|
||||
-----
|
||||
## Links
|
||||
|
||||
Autolink: <http://example.com>
|
||||
|
||||
|
@ -22,16 +18,13 @@ Link: [Example](http://example.com)
|
|||
|
||||
Reference style [link][1].
|
||||
|
||||
[1]: http://example.com "Example"
|
||||
[1]: http://example.com 'Example'
|
||||
|
||||
|
||||
Images
|
||||
------
|
||||
## Images
|
||||
|
||||
Image: ![My image](http://www.foo.bar/image.png)
|
||||
|
||||
Headers
|
||||
-------
|
||||
## Headers
|
||||
|
||||
# First level title
|
||||
|
||||
|
@ -49,8 +42,7 @@ Headers
|
|||
|
||||
### Title with ![image](http://localhost)
|
||||
|
||||
Code
|
||||
----
|
||||
## Code
|
||||
|
||||
```
|
||||
This
|
||||
|
@ -59,6 +51,10 @@ This
|
|||
fence
|
||||
```
|
||||
|
||||
```ts
|
||||
console.log('hello world')
|
||||
```
|
||||
|
||||
Inline `code span in a` paragraph.
|
||||
|
||||
This is a code block:
|
||||
|
@ -78,8 +74,7 @@ This is a code block:
|
|||
DualPivotQuicksort.sort(a);
|
||||
}
|
||||
|
||||
Quotes
|
||||
------
|
||||
## Quotes
|
||||
|
||||
> This is the first level of quoting.
|
||||
>
|
||||
|
@ -87,23 +82,19 @@ Quotes
|
|||
>
|
||||
> Back to the first level.
|
||||
|
||||
|
||||
> A list within a blockquote:
|
||||
>
|
||||
> * asterisk 1
|
||||
> * asterisk 2
|
||||
> * asterisk 3
|
||||
|
||||
> - asterisk 1
|
||||
> - asterisk 2
|
||||
> - asterisk 3
|
||||
|
||||
> Formatting within a blockquote:
|
||||
>
|
||||
> ### header
|
||||
>
|
||||
> Link: [Example](http://example.com)
|
||||
|
||||
|
||||
|
||||
Html
|
||||
-------
|
||||
## Html
|
||||
|
||||
This is inline <span>html</html>.
|
||||
And this is an html block.
|
||||
|
@ -123,25 +114,21 @@ And this is an html block.
|
|||
</tr>
|
||||
</table>
|
||||
|
||||
Horizontal rules
|
||||
----------------
|
||||
## Horizontal rules
|
||||
|
||||
---
|
||||
|
||||
___
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
***
|
||||
|
||||
|
||||
Lists
|
||||
-----
|
||||
## Lists
|
||||
|
||||
Unordered list:
|
||||
|
||||
* asterisk 1
|
||||
* asterisk 2
|
||||
* asterisk 3
|
||||
- asterisk 1
|
||||
- asterisk 2
|
||||
- asterisk 3
|
||||
|
||||
Ordered list:
|
||||
|
||||
|
@ -154,9 +141,9 @@ Mixed:
|
|||
1. First
|
||||
2. Second:
|
||||
|
||||
* Fee
|
||||
* Fie
|
||||
* Foe
|
||||
- Fee
|
||||
- Fie
|
||||
- Foe
|
||||
|
||||
3. Third
|
||||
|
||||
|
@ -166,7 +153,6 @@ Some term
|
|||
: First definition
|
||||
: Second definition
|
||||
|
||||
|
||||
Tables:
|
||||
|
||||
| Header 1 | Header 2 |
|
||||
|
|
21
samples/nix.nix
Normal file
21
samples/nix.nix
Normal file
|
@ -0,0 +1,21 @@
|
|||
/* This code demonstrates the syntax highlighting for the Nix Expression Language */
|
||||
{pkgs ? import <nixpkgs> {}}:
|
||||
let
|
||||
literals.null = null;
|
||||
literals.boolean = true;
|
||||
literals.number = 42;
|
||||
literals.string1 = "This is a normal string";
|
||||
literals.string2 = ''
|
||||
Broken escape sequence: \${literals.number}
|
||||
Escaped interpolation: ''${literals.number}
|
||||
Generic escape sequence: $''\{literals.number}
|
||||
'';
|
||||
literals.paths = [/etc/gitconfig ~/.gitconfig .git/config];
|
||||
# Note that unquoted URIs were deperecated by RFC 45
|
||||
literals.uri = https://github.com/NixOS/rfcs/pull/45;
|
||||
in {
|
||||
inherit (literals) number string1 string2 paths uri;
|
||||
baseNames = map baseNameOf literals.paths;
|
||||
f = { multiply ? 1, add ? 0, ... }@args:
|
||||
builtins.mapAttrs (name: value: multiply * value + add) args;
|
||||
}
|
53
samples/php.php
Normal file
53
samples/php.php
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
$heredoc = <<< HEREDOC_ID
|
||||
some $contents
|
||||
HEREDOC_ID;
|
||||
|
||||
function foo() {
|
||||
$a = [0, 1, 2];
|
||||
return SomeClass::$shared;
|
||||
}
|
||||
|
||||
// Sample comment
|
||||
|
||||
use AnotherClass as SomeAlias;
|
||||
#[Attribute] class SomeClass extends One implements Another {
|
||||
#[Attribute(1, 2)] public $my;
|
||||
protected $myProtected;
|
||||
private $myPrivate;
|
||||
public static $shared;
|
||||
const CONSTANT = 0987654321;
|
||||
/**
|
||||
* Description by <a href="mailto:">user@host.dom</a>
|
||||
* @param $abc
|
||||
* @param $def
|
||||
* @property $magic
|
||||
* @method m()
|
||||
* @return SomeType
|
||||
*/
|
||||
function doSmth($abc, $def, int $foo, SomeClass $bar) {
|
||||
/** @var SomeAlias $b */
|
||||
$b = new SomeAlias();
|
||||
foo();
|
||||
$def .= self::magic;
|
||||
$def .= self::CONSTANT;
|
||||
$v = Helper::convert(namedArgument: $abc . "\n {$def}" . $$def);
|
||||
$q = new Query( $this->invent(abs(0x80)) );
|
||||
$q = new Query( $this->protectedInvent(abs(0x80)) );
|
||||
$q = new Query( $this->privateInvent(abs(0x80)) );
|
||||
return array($v => $q->result);
|
||||
}
|
||||
}
|
||||
|
||||
interface Another {
|
||||
}
|
||||
|
||||
include (dirname(__FILE__) . "inc.php");
|
||||
`rm -r`;
|
||||
|
||||
goto Label;
|
||||
|
||||
<p><?php echo "Hello, world!"?></p>
|
||||
|
||||
Label:
|
||||
№
|
285
samples/pug.pug
Normal file
285
samples/pug.pug
Normal file
|
@ -0,0 +1,285 @@
|
|||
doctype html
|
||||
- var em_sometext = "<em>some text</em>"
|
||||
-var var2 = 'no spaces after -'
|
||||
_test = [{abc: "lalal"}]
|
||||
name = function() {}
|
||||
|
||||
html
|
||||
head
|
||||
script#idscript.script(type="text/javascript", qwerqwer)(test="123", lol=(1+
|
||||
1), other).
|
||||
var la = lala;
|
||||
|
||||
function script(arg1, arg2) {
|
||||
console.log("string", arg1, arg2);
|
||||
}
|
||||
|
||||
console.log(script(la, "string3"));
|
||||
|
||||
|
||||
style(type="text/css").
|
||||
.test-cls {
|
||||
float: left;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
div.saf {
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
link(rel="stylesheet", href="asdiofjs.css")
|
||||
|
||||
body
|
||||
mixin lala(abc, lala)
|
||||
div.lala-output(style="background-color: #ccc") lala output
|
||||
ul
|
||||
li.abc= null + abc
|
||||
li.lala= lala
|
||||
|
||||
div mixin long call
|
||||
mixin lala((123+{asdf:(1+1)}), "mixin long call")strong after lontg mixinty use
|
||||
|
||||
.test + mixin use
|
||||
+lala(123, "mixin + call 1")
|
||||
|
||||
mixin another()
|
||||
- console.log(attributes)
|
||||
input&attributes({cde: 3434})(ccc=343)&attributes(attributes).cls&attributes([1,2,'no'])
|
||||
|
||||
.test mixin attributes new syntax
|
||||
+another(abc=123, bcd='lol')
|
||||
|
||||
mixin mix2()
|
||||
div: p.mix2
|
||||
block
|
||||
|
||||
+mix2(): p paragraph in mix2
|
||||
|
||||
mixin mix2() mix2tag lol
|
||||
|
||||
mixin mix3()
|
||||
div: p.mix3
|
||||
|
||||
+mix3().mix2class It's time
|
||||
|
||||
.98349 class name omly numbers
|
||||
._[invalid character in class name should result in it and text following be considered text
|
||||
|
||||
// some html comment
|
||||
p.
|
||||
this is some text inside the p tag
|
||||
since it is only a html comment, pug will render it normally
|
||||
|
||||
div
|
||||
p: iv:asd-_FD tag name weird &characters
|
||||
p
|
||||
asdf: ab:[this should be text
|
||||
|
||||
tstr = 'strong'
|
||||
#{tstr} iterpolated tag name
|
||||
|
||||
pre
|
||||
em this is inside 'em' tag <br/>
|
||||
|
||||
[this is rendered as standalone text
|
||||
##this too
|
||||
"this too"
|
||||
|
||||
div(style="background-color: #eef") some examples of dot text blocks bellow:
|
||||
|
||||
#{'di' + 'v'}: em.
|
||||
some text block inside tag with interpolated name and subtag
|
||||
|
||||
.lol: strong(prop="()(())").
|
||||
another block of text, this time the tag has parenthesis inside
|
||||
a tag property value that is a string
|
||||
|
||||
#test(abc="asdfsdf").
|
||||
another case of text block
|
||||
|
||||
div.class.another: p.red(style="").asdfsd(lol=123)#ohno.
|
||||
another case of text block with interpolated text: #{10*100}
|
||||
|
||||
div: [this will be text
|
||||
p.
|
||||
and this will be a text block
|
||||
inside a p tag
|
||||
|
||||
#{'d' + 'i' + 'v'}}.
|
||||
em this should be italic because it is not a text block, and start the line with '}.'
|
||||
|
||||
p a tag with text ending in dot.
|
||||
strong and child tags to show that the dot text block detection is
|
||||
em working
|
||||
|
||||
div: div: thisisavar = 'THIS_IS_A_VARIABLE'
|
||||
= 'thisisavar is a variable declaration as demonstrated here: ' + thisisavar
|
||||
|
||||
sub2: tag2: -console.log('unbuffered js inside subtag?')
|
||||
|
||||
p#-tagid.-sdfa tag ids and classes with valid characters
|
||||
|
||||
p this tag has <em>embedded html #{console}</em>
|
||||
|
||||
textblock.
|
||||
<div style="color: red;">
|
||||
<p>this is embedded html in dot text block with a interpolated value: #{'te'+'st'+1}</p>
|
||||
</div>
|
||||
|
||||
<div style="color: green;">
|
||||
<p>this is directly embedded html with a interpolated value: #{'te'+'st'+2}</p>
|
||||
</div>
|
||||
|
||||
emb
|
||||
div regular tag and text
|
||||
| <div style="color: blue;">
|
||||
| <p>this is embedded html in pipe text with a interpolated value: #{'te'+'st'+2}</p>
|
||||
| </div>
|
||||
|
||||
p: em(sdf-+a\||.asd=123, type="te\x98t\u8876",lol,
|
||||
lol2
|
||||
lol3, abc = _test, fdg=console.log(123, (1 + (1 + 2)), undefined || true && "sdf#{1+1}asdf")
|
||||
asdf, bcd=[123, [_test, {asdf: console.log(123)}]], afd={a: 1+1, 'b': {c: (null)}}
|
||||
style="background-color: #ccc;") this is a tag with all sorts of crazy properties properly highlighted
|
||||
|
||||
p(qwer,|asdf, zxcv, poiu)= console + NaN
|
||||
|
||||
p: em(sdf-+a\||.asd=123 + undefined | 64 type="te\x98t\u8876" lol
|
||||
lol2
|
||||
lol3 abc = _test fuuuuu fdg=console.log(123, (1 + (1 + 2)), undefined || true && "sdf#{1+1}asdf")
|
||||
asdf bcd=[123, [_test, {asdf: console.log(123)}]] faaaaaa afd={a: 1+1, 'b': {c: (null)}} lol4=sdf+sdf lastattr
|
||||
style="background-color: #ccc;") new attributes without commas
|
||||
|
||||
p(qwer |asdf zxcv lol=123 * 0 || Math + "sdf") attributes no commas
|
||||
|
||||
p(aprop).lol.lil#theid(style="background-color: black; color: white;").lul(anotherprop='TEST')
|
||||
| tag with any combination/order of id/classes/attributes
|
||||
|
||||
include page
|
||||
|
||||
block testblock1
|
||||
div.lala-block this is in testblock1
|
||||
yield
|
||||
|
||||
div.lala-block-test
|
||||
block prepend testblock1
|
||||
div.lala-prepend line1
|
||||
| line2
|
||||
|
||||
append testblock1
|
||||
div.lala-append line1
|
||||
| line2
|
||||
yield
|
||||
|
||||
div a list generated in a loop as subtag code:
|
||||
ul: - for i in [1,2,3,null]
|
||||
li= i
|
||||
|
||||
div a list generated in another loop as subtag code:
|
||||
ul: for i in [1,2,3,null]
|
||||
li= i
|
||||
|
||||
div(style="color: red;"): append testblock1
|
||||
|
||||
div(style="color: green;"): include page
|
||||
|
||||
div(style="color: blue;"): mixin lala
|
||||
|
||||
|
||||
if true
|
||||
p conditional text
|
||||
else
|
||||
p and this won't show
|
||||
|
||||
friends = 10
|
||||
case friends
|
||||
when 0
|
||||
p you have no friends
|
||||
when (1+(1+1)): p you have a friend
|
||||
default: p you have #{friends} friends
|
||||
|
||||
h1 title
|
||||
|
||||
p= console.log("logging before text") || 'after console.log'
|
||||
|
||||
#div
|
||||
label
|
||||
| Username1:
|
||||
input(type="text")
|
||||
|
||||
label Username2:
|
||||
input(type="text")
|
||||
|
||||
p unescaped and escaped variable:
|
||||
div!= em_sometext
|
||||
div= em_sometext
|
||||
#test(abc="lala", lele=9, lili=em_sometext) the variable used as property value
|
||||
.class interpolated escaped and unescaped variable: #{em_sometext + "&"} and !{em_sometext}} \#{this will show}
|
||||
|
||||
p some text // not some comment
|
||||
|
||||
a(href="lala", something=em_sometext,) some link
|
||||
|
||||
div: span: em= 'extra spaces between tags and js output'
|
||||
|
||||
div(style="background-color: #ccf;"): p:.a subtag without spaces will work only if id or class is used directly.
|
||||
p: em and this will be a part of it
|
||||
|
||||
p='output without spaces separating tag: ' + em_sometext
|
||||
|
||||
//-
|
||||
this is an unbuffered comment
|
||||
it will never show on the html
|
||||
|
||||
and here to test skipping a line with less spaces than the indent level
|
||||
|
||||
div.class.another#someid: a(href=em_sometext, test="la\"sdafla", style="display: block; width: 100px; height: 10px"): p.red(style="") some lalalalal
|
||||
|
||||
p
|
||||
multi.line tag with pipe lines,
|
||||
| like this first #{em_sometext + "aosidjfsd" + 0 + undefined} ending here.
|
||||
| <br/> more pure text breaking the line with embedded html
|
||||
|
||||
p Test inline mixin #[+lala(123, 'lala inside inline')] end
|
||||
p Here is some #[strong: em text] and look at #[a(href='http://google.com') this link!]
|
||||
p Here is some #[.strong: em text] and look at #[a(href='http://google.com') this link!]
|
||||
p Other inline #[strong= 'test']
|
||||
p Test #[|text line]
|
||||
p Test buffered #[= console.log('inline tag code') + 'inline code']
|
||||
p Test unbuffered #[- console.log('inline tag code') + 'inline code']
|
||||
p #[- abcf = [[123, [[],[]], []],'abc']] #[= abcf]
|
||||
p Crazy #[em: strong #[span #[='inline']]: test]
|
||||
p We can also #[strong combine #[em multiple #[img(src='http://pug-lang.com/style/logo.png')]]]
|
||||
p Another #[strong.lil#okf(acs=[1,2]) test [[with brackets]] [in#[='side']]]
|
||||
#[strong start] line with #[i]\#[j] inline
|
||||
#[#[#[#[#[i a] b] c] d]e]
|
||||
#[asdf.lol(fff)#[asdf]]
|
||||
|
||||
p.
|
||||
block with #[i inline] tag.
|
||||
|
||||
| pipe text with #[i inline] tag.
|
||||
|
||||
!{'tag' + 234} text line starting with interpolated
|
||||
[!{sdfasdf}
|
||||
##{sadf} lol2
|
||||
"#[asdf]"
|
||||
|
||||
- var left_wrapper = 'p'
|
||||
- var left_classes = 'one two'
|
||||
- var left = 'the content'
|
||||
p this is not a code block
|
||||
|
||||
-
|
||||
var peeps = ["Mathias", "David", "Github"];
|
||||
|
||||
var msg = peeps.map(function(name) {
|
||||
return "Hi " + name
|
||||
}).join(", ");
|
||||
|
||||
<#[span test inline in brackets]>
|
||||
|
||||
div
|
||||
<#{left_wrapper}.lol#dsfsdf class="group-left !{left_classes}">
|
||||
!= left
|
||||
</!{left_wrapper}>
|
|
@ -1,13 +1,13 @@
|
|||
from typing import List
|
||||
|
||||
def decorator(param):
|
||||
pass
|
||||
|
||||
@decorator(param=1)
|
||||
def f(x):
|
||||
"""
|
||||
Syntax Highlighting Demo
|
||||
@param x Parameter
|
||||
|
||||
Semantic highlighting:
|
||||
Generated spectrum to pick colors for local variables and parameters:
|
||||
Color#1 SC1.1 SC1.2 SC1.3 SC1.4 Color#2 SC2.1 SC2.2 SC2.3 SC2.4 Color#3
|
||||
Color#3 SC3.1 SC3.2 SC3.3 SC3.4 Color#4 SC4.1 SC4.2 SC4.3 SC4.4 Color#5
|
||||
"""
|
||||
|
||||
def nested_func(y):
|
||||
|
@ -23,6 +23,7 @@ class Foo:
|
|||
def __init__(self: Foo):
|
||||
byte_string: bytes = b'newline:\n also newline:\x0a'
|
||||
text_string = u"Cyrillic Я is \u042f. Oops: \u042g"
|
||||
print(f"Got bytes: {byte_string!r}, text: {text_string!s}")
|
||||
self.make_sense(whatever=1)
|
||||
|
||||
def make_sense(self, whatever):
|
||||
|
|
|
@ -9,12 +9,18 @@ mod stuff;
|
|||
pub enum Flag {
|
||||
Good,
|
||||
Bad,
|
||||
Ugly
|
||||
Ugly,
|
||||
}
|
||||
|
||||
const QUALITY: Flag = Flag::Good;
|
||||
|
||||
struct Table<const N: usize>([[i32; N]; N])
|
||||
static COUNTER: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
extern "C" {
|
||||
static mut ERROR_MESSAGE: *mut std::os::raw::c_char;
|
||||
}
|
||||
|
||||
struct Table<const N: usize>([[i32; N]; N]);
|
||||
|
||||
pub trait Write {
|
||||
fn write(&mut self, buf: &[u8]) -> Result<usize>;
|
||||
|
@ -22,7 +28,7 @@ pub trait Write {
|
|||
|
||||
struct Object<T> {
|
||||
flag: Flag,
|
||||
fields: HashMap<T, u64>
|
||||
fields: HashMap<T, u64>,
|
||||
}
|
||||
|
||||
union MyUnion {
|
||||
|
@ -42,7 +48,10 @@ impl<T> Write for Object<T> {
|
|||
|
||||
impl<T> Default for Object<T> {
|
||||
fn default() -> Self {
|
||||
Object { flag: Flag::Good, fields: HashMap::new() }
|
||||
Object {
|
||||
flag: Flag::Good,
|
||||
fields: HashMap::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,19 +99,28 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
info!("The program \"{}\" calculates the value {}",
|
||||
program, accumulator);
|
||||
info!(
|
||||
"The program \"{}\" calculates the value {}",
|
||||
program, accumulator
|
||||
);
|
||||
}
|
||||
|
||||
// example syntax for derive
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct MyStruct {
|
||||
pub field1: u32,
|
||||
pub field2: u32,
|
||||
}
|
||||
|
||||
/// Some documentation `with a code`, *an italic text*
|
||||
/// and **a bold text**
|
||||
/// # Heading
|
||||
/// [Rust](https://www.rust-lang.org/)
|
||||
#[cfg(target_os="linux")]
|
||||
#[cfg(target_os = "linux")]
|
||||
unsafe fn a_function<T: 'lifetime>(count: &mut i64) -> ! {
|
||||
count += 1;
|
||||
'label: loop {
|
||||
let str_with_escapes = "Hello\x20W\u{f3}rld!\u{abcdef}";
|
||||
let str_with_escapes = "Hello\x20W\u{f3}rld!\u{abcd}";
|
||||
println!("{} {foo:<4}", str_with_escapes, foo = 42);
|
||||
}
|
||||
}
|
||||
|
|
19
samples/scss.scss
Normal file
19
samples/scss.scss
Normal file
|
@ -0,0 +1,19 @@
|
|||
@use "sass:color";
|
||||
|
||||
$primary-color: hotpink;
|
||||
|
||||
@mixin border-radius($radius) {
|
||||
-webkit-border-radius: $radius;
|
||||
-moz-border-radius: $radius;
|
||||
border-radius: $radius;
|
||||
}
|
||||
|
||||
.my-element {
|
||||
color: #{color.change($primary-color, $alpha: 0.1)};
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.my-other-element {
|
||||
@include border-radius(5px);
|
||||
}
|
31
samples/svelte.svelte
Normal file
31
samples/svelte.svelte
Normal file
|
@ -0,0 +1,31 @@
|
|||
<script>
|
||||
import { applyAction, enhance } from '$app/forms'
|
||||
import Names from '$lib/components/names.svelte'
|
||||
export let data
|
||||
export let form
|
||||
console.log('form: ', form)
|
||||
const { names } = data
|
||||
</script>
|
||||
|
||||
<h1>Some form</h1>
|
||||
|
||||
<form
|
||||
method="POST"
|
||||
use:enhance={({ form }) => {
|
||||
return async ({ update }) => {
|
||||
update()
|
||||
}
|
||||
}}
|
||||
action="?/create"
|
||||
>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Type here"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
name="myText"
|
||||
/>
|
||||
</form>
|
||||
|
||||
<br />
|
||||
|
||||
<Names namesData={names} />
|
|
@ -9,7 +9,7 @@ date = 2019-11-04T07:32:00-08:00
|
|||
|
||||
[database]
|
||||
server = "192.168.1.1"
|
||||
ports = [ 8001, 8001, 8002 ]
|
||||
ports = [8001, 8001, 8002]
|
||||
"connection_max" = 5000
|
||||
enabled = true
|
||||
|
||||
|
@ -18,15 +18,10 @@ alpha = { ip = '10.0.0.1', dc = "eqdc10" }
|
|||
beta = { ip = '10.0.0.2', dc = "eqdc10" }
|
||||
|
||||
[clients]
|
||||
data = [ ["gamma", "delta"], [1.0, 2.0] ]
|
||||
data = [["gamma", "delta"], [1.0, 2.0]]
|
||||
hosts = ["alpha", "omega"]
|
||||
|
||||
hosts = [
|
||||
"alpha",
|
||||
"omega",
|
||||
]
|
||||
|
||||
valid-escapes = """\tline \"1\"
|
||||
invalid-escapes = "\a \u20 \U0020"valid-escapes = """\tline \"1\"
|
||||
line\u00202
|
||||
line 3\U0000002E
|
||||
"""
|
||||
invalid-escapes = "\a \u20 \U0020"
|
||||
|
|
19
samples/tsx.tsx
Normal file
19
samples/tsx.tsx
Normal file
|
@ -0,0 +1,19 @@
|
|||
import React, { useState } from 'react'
|
||||
|
||||
const Component = (): JSX.Element => {
|
||||
const [count, setCount] = useState<number>(0)
|
||||
|
||||
return (
|
||||
<>
|
||||
<main>
|
||||
<h1>IntelliJ IDEA</h1>
|
||||
<img height="12" src="images/hg.gif" width="18" />
|
||||
What is IntelliJ IDEA? · Α
|
||||
<button onClick={() => setCount(count + 1)}>Click me</button>
|
||||
<div>{count}</div>
|
||||
</main>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default Component
|
|
@ -1,54 +1,55 @@
|
|||
module ModuleValidator {
|
||||
import checkChars = CharUtils.notWhiteSpace
|
||||
import checkChars = CharUtils.notWhiteSpace
|
||||
|
||||
export interface HasValidator<T> {
|
||||
validateValue(): Boolean;
|
||||
}
|
||||
|
||||
type FooBarAlias = string;
|
||||
|
||||
@decorator()
|
||||
class HasValidator implements HasValidator<String> {
|
||||
/* Processed values */
|
||||
static validatedValue: Array<String> = ['', 'aa']
|
||||
private myValue: String
|
||||
|
||||
/**
|
||||
* Constructor for class
|
||||
* @param valueParameter Value for <i>validation</i>
|
||||
*/
|
||||
constructor(valueParameter: String) {
|
||||
this.myValue = valueParameter
|
||||
HasValidator.validatedValue.push(value)
|
||||
export interface HasValidator<T> {
|
||||
validateValue(): Boolean
|
||||
}
|
||||
|
||||
public validateValue(): Boolean {
|
||||
var resultValue: Boolean = checkChars(this.myValue)
|
||||
return resultValue
|
||||
type FooBarAlias = string
|
||||
|
||||
@decorator()
|
||||
class HasValidator implements HasValidator<String> {
|
||||
/* Processed values */
|
||||
static validatedValue: Array<String> = ['', 'aa']
|
||||
private myValue: String
|
||||
|
||||
/**
|
||||
* Constructor for class
|
||||
* @param valueParameter Value for <i>validation</i>
|
||||
*/
|
||||
constructor(valueParameter: String) {
|
||||
this.myValue = valueParameter
|
||||
HasValidator.validatedValue.push(value)
|
||||
}
|
||||
|
||||
public validateValue(): Boolean {
|
||||
var resultValue: Boolean = checkChars(this.myValue)
|
||||
return resultValue
|
||||
}
|
||||
|
||||
static createInstance(valueParameter: string): HasValidator {
|
||||
return new HasValidator(valueParameter)
|
||||
}
|
||||
}
|
||||
|
||||
static createInstance(valueParameter: string): HasValidator {
|
||||
return new HasValidator(valueParameter)
|
||||
function globalFunction<TypeParameter>(value: TypeParameter) {
|
||||
//global function
|
||||
return 42
|
||||
}
|
||||
}
|
||||
|
||||
function globalFunction<TypeParameter>(value: TypeParameter) { //global function
|
||||
return 42
|
||||
}
|
||||
declare var declareUrl
|
||||
var varUrl = declareUrl.replace(/^\s*(.*)/, '$1').concat('\u1111z\n\u0022')
|
||||
var html = `<div title='HTML injection'>Injected language fragment</div>`
|
||||
var hello = () => console.log('hello')
|
||||
HasValidator.createInstance(varUrl).validateValue()
|
||||
|
||||
declare var declareUrl
|
||||
var varUrl = declareUrl.replace(/^\s*(.*)/, '$1').concat('\u1111\z\n\u22')
|
||||
var html = `<div title='HTML injection'>Injected language fragment</div>`
|
||||
var hello = () => console.log('hello')
|
||||
HasValidator.createInstance(varUrl).validateValue()
|
||||
|
||||
function acceptsUnion(s: string | number) {
|
||||
if (typeof s === 'string') {
|
||||
s
|
||||
function acceptsUnion(s: string | number) {
|
||||
if (typeof s === 'string') {
|
||||
s
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum EnumName {
|
||||
EnumMember
|
||||
}
|
||||
enum EnumName {
|
||||
EnumMember,
|
||||
}
|
||||
}
|
||||
|
|
26
samples/typst.typst
Normal file
26
samples/typst.typst
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
#set page(width: 10cm, height: auto)
|
||||
#set heading(numbering: "1.")
|
||||
|
||||
= Fibonacci sequence
|
||||
|
||||
The Fibonacci sequence is *defined throught* the recurrence relation $F_n = F_(n-1) + F_(n-2)$.
|
||||
It can also be expressed in _closed form_.
|
||||
|
||||
$ F_n = round(1 / sqrt(5) phi.alt^n), quad
|
||||
phi.alt = (1 + sqrt(5)) / 2 $
|
||||
|
||||
#let count = 8
|
||||
#let nums = range(1, count + 1)
|
||||
#let fib(n) = (
|
||||
if n <= 2 { 1 }
|
||||
else { fib(n - 1) + fib(n - 2) }
|
||||
)
|
||||
|
||||
The first #count numbers of the sequence are:
|
||||
|
||||
#align(center, table(
|
||||
columns: count,
|
||||
..nums.map(n => $F_#n$),
|
||||
..nums.map(n => str(fib(n)))
|
||||
))
|
Loading…
Reference in a new issue