on master help sign in
Merge branch 'master' into master
commit3a612f063eb157a35b4d09d4dcf2b04ed1604388 authorDavid Peter <sharkdp@users.noreply.github.com> dateFri 30 Oct 2020, 19:36 (6 years ago) parent9daea738e81315
51 files changed+2085−65
.github/workflows/CICD.yml+5 .gitmodules+6 CHANGELOG.md+8−1 CONTRIBUTING.md+48 README.md+16−1 assets/syntaxes/02_Extra/Manpage.sublime-syntax+16−6 assets/syntaxes/02_Extra/Svelte+1 assets/syntaxes/02_Extra/syntax_test_man.man+29−3 assets/themes.bin assets/themes/Coldark+1 src/bin/bat/main.rs+8 src/error.rs+4 src/output.rs+2−2 tests/assets.rs+4 tests/integration_tests.rs+10 tests/syntax-tests/highlighted/D/test.d+44 tests/syntax-tests/highlighted/EtcGroup/test.group+67 tests/syntax-tests/highlighted/Git Attributes/example.gitattributes+16 tests/syntax-tests/highlighted/Git Config/text.gitconfig+107 tests/syntax-tests/highlighted/Graphviz DOT/test_digraph.dot+41 tests/syntax-tests/highlighted/Graphviz DOT/test_graph.dot+3 tests/syntax-tests/highlighted/MATLAB/test.matlab+34 tests/syntax-tests/highlighted/Manpage/bat-0.16.man+3−3 tests/syntax-tests/highlighted/Manpage/select-2.man+49−49 tests/syntax-tests/highlighted/PowerShell/test.ps1+25 tests/syntax-tests/highlighted/QML/BatSyntaxTest.qml+219 tests/syntax-tests/highlighted/SLS/test.sls+57 tests/syntax-tests/highlighted/Svelte/App.svelte+57 tests/syntax-tests/highlighted/Vue/example.vue+55 tests/syntax-tests/highlighted/nginx/nginx.conf+140 tests/syntax-tests/highlighted/nix/test.nix+15 tests/syntax-tests/highlighted/orgmode/test.org+38 tests/syntax-tests/source/D/test.d+44 tests/syntax-tests/source/EtcGroup/test.group+67 tests/syntax-tests/source/Git Attributes/example.gitattributes+16 tests/syntax-tests/source/Git Config/LICENSE.md+1 tests/syntax-tests/source/Git Config/text.gitconfig+107 tests/syntax-tests/source/Graphviz DOT/LICENSE.md+22 tests/syntax-tests/source/Graphviz DOT/test_digraph.dot+41 tests/syntax-tests/source/Graphviz DOT/test_graph.dot+3 tests/syntax-tests/source/MATLAB/LICENSE.md+27 tests/syntax-tests/source/MATLAB/test.matlab+34 tests/syntax-tests/source/PowerShell/test.ps1 tests/syntax-tests/source/QML/BatSyntaxTest.qml+219 tests/syntax-tests/source/SLS/test.sls+57 tests/syntax-tests/source/Svelte/App.svelte+57 tests/syntax-tests/source/Svelte/LICENSE+14 tests/syntax-tests/source/Vue/example.vue+55 tests/syntax-tests/source/nginx/nginx.conf+140 tests/syntax-tests/source/nix/test.nix+15 tests/syntax-tests/source/orgmode/test.org+38
.github/workflows/CICD.yml+5
@@ -58,6 +58,11 @@ jobs:
5858 with:
5959 command: test
6060 args: --release
61+ - name: Run ignored-by-default unit tests with new syntaxes and themes
62+ uses: actions-rs/cargo@v1
63+ with:
64+ command: test
65+ args: --release -- --ignored
6166 - name: Syntax highlighting regression test
6267 run: tests/syntax-tests/regression_test.sh
6368 - name: List of languages
.gitmodules+6
@@ -200,3 +200,9 @@
200200[submodule "assets/syntaxes/02_Extra/Ninja"]
201201 path = assets/syntaxes/02_Extra/Ninja
202202 url = https://github.com/pope/SublimeNinja.git
203+[submodule "assets/syntaxes/02_Extra/Svelte"]
204+ path = assets/syntaxes/02_Extra/Svelte
205+ url = https://github.com/corneliusio/svelte-sublime
206+[submodule "assets/themes/Coldark"]
207+ path = assets/themes/Coldark
208+ url = https://github.com/ArmandPhilippot/coldark-bat.git
CHANGELOG.md+8−1
@@ -1,6 +1,5 @@
11# unreleased
22
3−- Add Note to refer to see detailed help with --help (and vice versa with -h). see #1215 (@henil)
43
54## Features
65
@@ -8,14 +7,22 @@
87
98## Bugfixes
109
10+- Throws an error when `bat` is being used as `pager`, see #1343 (@adrian-rivera)
11+
1112## Other
1213
14+- Add note to refer to see detailed help with `--help` (and vice versa with `-h`), see #1215 (@henil)
15+- Add a `Contributors` section to `README`, see #1348 (@adrian-rivera)
16+
1317## Syntaxes
1418
1519- Manpage syntax highlighting has been improved, see #1315 (@keith-hall)
20+- Add Svelte file syntax, see #1285 (@kjmph)
1621
1722## New themes
1823
24+- Coldark, see #1329 (@armandphilippot)
25+
1926## `bat` as a library
2027
2128## Packaging
CONTRIBUTING.mdnew file+48
@@ -0,0 +1,48 @@
1+# Contributing
2+
3+Thank you for considering to contribute to `bat`!
4+
5+
6+
7+## Add an entry to the changelog
8+
9+If your contribution changes the behavior of `bat` (as opposed to a typo-fix
10+in the documentation), please update the [`CHANGELOG.md`](CHANGELOG.md) file
11+and describe your changes. This makes the release proess much easier and
12+therefore helps to get your changes into a new `bat` release faster.
13+
14+The top of the `CHANGELOG` contains a *"unreleased"* section with a few
15+subsections (Features, Bugfixes, …). Please add your entry to the subsection
16+that best describes your change
17+
18+Entries follow this format:
19+```
20+- Short description of what has been changed, see #123 (@user)
21+```
22+Here, `#123` is the number of the original issue and/or your pull request.
23+Please replace `@user` by your GitHub username.
24+
25+
26+## Development
27+
28+Please check out the [Development](https://github.com/sharkdp/bat#development)
29+section in the README.
30+
31+
32+## Adding a new feature
33+
34+Please consider opening a
35+[feature request ticket](https://github.com/sharkdp/bat/issues/new?assignees=&labels=feature-request&template=feature_request.md)
36+first in order to give us a chance to discuss the feature first.
37+
38+
39+## Adding new syntaxes/languages or themes
40+
41+Before you make a pull request that adds a new syntax or theme, please read
42+the [Customization](https://github.com/sharkdp/bat#customization) section
43+in the README first.
44+
45+If you really think that a particular syntax or theme should be added for all
46+users, please read the corresponding
47+[documentation](https://github.com/sharkdp/bat/blob/master/doc/assets.md)
48+first.
README.md+16−1
@@ -131,7 +131,18 @@ highlighting:
131131git show v0.6.0:src/main.rs | bat -l rs
132132```
133133
134−Note that syntax highlighting within diffs is currently not supported. If you are looking for this, check out [`delta`](https://github.com/dandavison/delta).
134+#### `git diff`
135+
136+You can combine `bat` with `git diff` to view lines around code changes with proper syntax
137+highlighting:
138+```bash
139+batdiff() {
140+ git diff --name-only --diff-filter=d | xargs bat --diff
141+}
142+```
143+If you prefer to use this as a separate tool, check out `batdiff` in [`bat-extras`](https://github.com/eth-p/bat-extras).
144+
145+If you are looking for more support for git and diff operations, check out [`delta`](https://github.com/dandavison/delta).
135146
136147#### `xclip`
137148
@@ -665,6 +676,10 @@ bash assets/create.sh
665676cargo install --path . --locked --force
666677```
667678
679+## Contributing
680+
681+Take a look at the [`CONTRIBUTING.md`](CONTRIBUTING.md) guide.
682+
668683## Maintainers
669684
670685- [sharkdp](https://github.com/sharkdp)
assets/syntaxes/02_Extra/Manpage.sublime-syntax+16−6
@@ -34,11 +34,11 @@ contexts:
3434 scope: markup.heading.title.man
3535 - match: \s\s
3636 pop: true
37− - match: '(?=\S)'
37+ - match: '(?=\S|$)'
3838 pop: true
3939
4040 - match: '$'
41− push: body
41+ set: body
4242
4343 body:
4444 # English, ..., ..., ..., Russian, ...
@@ -48,14 +48,16 @@ contexts:
4848 embed: synopsis
4949 escape: '(?={{section_heading}})'
5050
51+ - match: '^(?:USAGE)'
52+ scope: markup.heading.synopsis.man
53+ embed: synopsis
54+ escape: '(?={{section_heading}})'
5155
5256 - match: '{{section_heading}}'
5357 scope: markup.heading.other.man
5458 embed: options # some man pages put command line options under the description heading
5559 escape: '(?={{section_heading}})'
5660
57− - include: function-call
58−
5961 function-call:
6062 - match: '\b([A-Za-z0-9_\-]+)(\()([^)]*)(\))'
6163 captures:
@@ -83,6 +85,7 @@ contexts:
8385 - match: ''
8486 pop: true
8587 - include: function-call
88+ - include: c-code
8689
8790 expect-command-line-option:
8891 - match: '[A-Za-z0-9-]+'
@@ -127,9 +130,15 @@ contexts:
127130 - match: '$|(?=[],]|{{command_line_option}})'
128131 pop: true
129132
133+ c-code:
134+ - match: '^(?=\s+(?:#include\b|#define\b|/\*|struct\s+(\w+\s*)?\{))'
135+ embed: scope:source.c
136+ #embed_scope: source.c.embedded.man
137+ #escape: ^(?!#|\1|\s*(?:$|/\*|#include\b|#define\b))
138+ escape: ^(?=\s*(?:\(.*\.\)\s*$|[A-Z](?![A-Z])))
139+
130140 synopsis:
131− - match: '^(?=\s+(?:#include|/\*))'
132− push: scope:source.c
141+ - include: c-code
133142 - match: \[
134143 scope: punctuation.section.brackets.begin.man
135144 push: command-line-option-or-pipe
@@ -140,6 +149,7 @@ contexts:
140149 captures:
141150 1: keyword.operator.logical.man
142151 #- match: (?={{command_line_option}})
152+ - match: \w+-\w+
143153 - match: (?=-)
144154 push:
145155 - match: (?=\s*\|)
assets/syntaxes/02_Extra/Sveltenew file+1

Submodule changed.

assets/syntaxes/02_Extra/syntax_test_man.man+29−3
@@ -5,7 +5,7 @@ SOMETHING(8) System Manager's Manual SOMETHING(8)
55# ^^^^^^^ meta.preprocessor
66
77NAME
8−#^^^ markup.heading.title
8+#^^^ markup.heading.other
99 example - do something useful
1010
1111SYNOPSIS
@@ -45,9 +45,16 @@ SYNOPSIS
4545 [--quiet] [--debug] [--help|-h] [--version] [--conf FILE]
4646
4747 /* According to POSIX.1-2001, POSIX.1-2008 */
48−# ^^ source comment.block punctuation.definition.comment
48+# ^^ source.c comment.block punctuation.definition.comment
4949 #include <sys/select.h>
50−# ^^^^^^^^ source meta.preprocessor.include keyword.control.import.include
50+# ^^^^^^^^ source.c meta.preprocessor.include keyword.control.import.include
51+ struct timeval {
52+# ^^^^^^ source.c storage.type
53+
54+ time_t tv_sec; /* seconds */
55+ suseconds_t tv_usec; /* microseconds */
56+ };
57+
5158
5259
5360DESCRIPTION
@@ -123,3 +130,22 @@ OPTIONS
123130# ^^^ variable.parameter
124131# ^^ - variable
125132 output NUM (default 3) lines of copied context
133+
134+EXAMPLE
135+ #include <stdio.h>
136+# ^^^^^^^^ source.c meta.preprocessor.include keyword.control.import.include
137+
138+ (This is not C code.)
139+# ^^^^^^^^^^^^^^^^^^^^^^ - source.c
140+
141+ struct timeval {
142+ time_t tv_sec; /* seconds */
143+ suseconds_t tv_usec; /* microseconds */
144+ };
145+# ^ source.c punctuation.terminator
146+
147+ The corresponding argument for pselect() has the following type:
148+#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - source.c
149+ #define POLLIN_SET (EPOLLRDNORM | EPOLLRDBAND | EPOLLIN |
150+ EPOLLHUP | EPOLLERR)
151+# ^ source.c meta.preprocessor.macro meta.group punctuation.section.group.end
assets/themes.bin

Binary file not shown.

assets/themes/Coldarknew file+1

Submodule changed.

src/bin/bat/main.rs+8
@@ -205,6 +205,14 @@ pub fn list_themes(cfg: &Config) -> Result<()> {
205205 writeln!(stdout, "{}", theme)?;
206206 }
207207 }
208+ writeln!(
209+ stdout,
210+ "Further themes can be installed to '{}', \
211+ and are added to the cache with `bat cache --build`. \
212+ For more information, see:\n\n \
213+ https://github.com/sharkdp/bat#adding-new-themes",
214+ config_file().join("themes").to_string_lossy()
215+ )?;
208216
209217 Ok(())
210218}
src/error.rs+4
@@ -20,6 +20,10 @@ error_chain! {
2020 description("unknown syntax"),
2121 display("unknown syntax: '{}'", name)
2222 }
23+ InvalidPagerValueBat {
24+ description("invalid value `bat` for pager property"),
25+ display("Use of bat as a pager is disallowed in order to avoid infinite recursion problems")
26+ }
2327 }
2428}
2529
src/output.rs+2−2
@@ -85,10 +85,10 @@ impl OutputType {
8585
8686 match pagerflags.split_first() {
8787 Some((pager_name, args)) => {
88− let mut pager_path = PathBuf::from(pager_name);
88+ let pager_path = PathBuf::from(pager_name);
8989
9090 if pager_path.file_stem() == Some(&OsString::from("bat")) {
91− pager_path = PathBuf::from("less");
91+ return Err(ErrorKind::InvalidPagerValueBat.into());
9292 }
9393
9494 let is_less = pager_path.file_stem() == Some(&OsString::from("less"));
tests/assets.rs+4
@@ -1,7 +1,9 @@
11use bat::assets::HighlightingAssets;
22
33/// This test ensures that we are not accidentally removing themes due to submodule updates.
4+/// It is 'ignore'd by default because it requires themes.bin to be up-to-date.
45#[test]
6+#[ignore]
57fn all_themes_are_present() {
68 let assets = HighlightingAssets::from_binary();
79
@@ -12,6 +14,8 @@ fn all_themes_are_present() {
1214 themes,
1315 vec![
1416 "1337",
17+ "Coldark-Cold",
18+ "Coldark-Dark",
1519 "DarkNeon",
1620 "Dracula",
1721 "GitHub",
tests/integration_tests.rs+10
@@ -405,6 +405,16 @@ fn pager_disable() {
405405 .stdout(predicate::eq("hello world\n").normalize());
406406}
407407
408+#[test]
409+fn pager_value_bat() {
410+ bat()
411+ .arg("--pager=bat")
412+ .arg("--paging=always")
413+ .arg("test.txt")
414+ .assert()
415+ .failure();
416+}
417+
408418#[test]
409419fn alias_pager_disable() {
410420 bat()
tests/syntax-tests/highlighted/D/test.dnew file+44
@@ -0,0 +1,44 @@
1+// selective import
2+import std.stdio : writeln, writefln;
3+// non-selective import
4+import std.algorithm;
5+
6+/* a multiline comment
7+*
8+* this function is safe because it doesn't use pointer arithmetic
9+*/
10+int the_ultimate_answer() @safe {
11+ // assert1on
12+ assert(1 != 2);
13+ // now we can safely return our answer 
14+ return 42;
15+}
16+
17+void main()
18+{
19+ // function call with string literal
20+ writeln("Hello World!");
21+
22+ // an int array declaration
23+ int[] arr1 = [1, 2, 3];
24+ // an immutable double
25+ immutable double pi = 3.14;
26+ // a mutable double
27+ double d1 = pi;
28+ // a pointer
29+ double* dp1 = &d1;
30+ // another pointer to the same thingy
31+ auto a1 = &d1;
32+ // a constant bool
33+ const bool b1 = true;
34+ if (b1) {
35+ // another function call 
36+ writefln("%s\n%s\n%s\n", arr1, d1, the_ultimate_answer());
37+ }
38+ else if (!b1) {
39+ writeln("this seems wrong");
40+ }
41+ else {
42+ writeln("I'm giving up, this is too crazy for me");
43+ }
44+}
tests/syntax-tests/highlighted/EtcGroup/test.groupnew file+67
@@ -0,0 +1,67 @@
1+root:x:0:root
2+sys:x:3:bin
3+mem:x:8:
4+ftp:x:11:
5+mail:x:12:
6+log:x:19:
7+smmsp:x:25:
8+proc:x:26:polkitd
9+games:x:50:
10+lock:x:54:
11+network:x:90:
12+floppy:x:94:
13+scanner:x:96:
14+power:x:98:
15+adm:x:999:daemon
16+wheel:x:998:username
17+kmem:x:997:
18+tty:x:5:
19+utmp:x:996:
20+audio:x:995:mpd,username
21+disk:x:994:
22+input:x:993:
23+kvm:x:992:
24+lp:x:991:
25+optical:x:990:username
26+render:x:989:
27+storage:x:988:username
28+uucp:x:987:
29+video:x:986:username
30+users:x:985:
31+systemd-journal:x:984:
32+rfkill:x:983:
33+bin:x:1:daemon
34+daemon:x:2:bin
35+http:x:33:
36+nobody:x:65534:
37+dbus:x:81:
38+systemd-journal-remote:x:982:
39+systemd-network:x:981:
40+systemd-resolve:x:980:
41+systemd-timesync:x:979:
42+systemd-coredump:x:978:
43+uuidd:x:68:
44+username:x:1000:
45+git:x:977:
46+avahi:x:976:
47+colord:x:975:
48+polkitd:x:102:
49+mpd:x:45:
50+rtkit:x:133:
51+transmission:x:169:
52+wireshark:x:150:username
53+lightdm:x:974:
54+geoclue:x:973:
55+usbmux:x:140:
56+dhcpcd:x:972:
57+brlapi:x:971:
58+gdm:x:120:
59+libvirt:x:970:
60+flatpak:x:969:
61+gluster:x:968:
62+rpc:x:32:
63+tor:x:43:
64+rslsync:x:967:
65+docker:x:966:username
66+sambashare:x:1002:username
67+named:x:40:
tests/syntax-tests/highlighted/Git Attributes/example.gitattributesnew file+16
@@ -0,0 +1,16 @@
1+#
2+# Comment
3+
4+[attr]binary -diff -merge -text
5+
6+* text=auto
7+*.c diff=c
8+*.cc text diff=cpp
9+*.o binary
10+*.bat text eol=crlf
11+*.lock text -diff
12+*.*ignore text
13+*.patch -text
14+
15+.gitattributes linguist-language=gitattributes
16+.gitkeep export-ignore
tests/syntax-tests/highlighted/Git Config/text.gitconfignew file+107
@@ -0,0 +1,107 @@
1+[alias]
2+ br = branch
3+ branch = branch -a
4+ c = clone --recursive
5+ ci = commit
6+ cl = clone
7+ co = checkout
8+ contributors = shortlog --summary --numbered
9+ lg = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)'
10+ remote = remote -v
11+ st = status
12+ tag = tag -l
13+[apply]
14+ whitespace = fix
15+[color]
16+ ui = true
17+[color "branch"]
18+ current = yellow
19+ local = yellow
20+ remote = green
21+[color "diff"]
22+ commit = yellow bold
23+ frag = magenta bold
24+ meta = yellow
25+ new = green bold
26+ old = red bold
27+ whitespace = red reverse
28+[color "diff-highlight"]
29+ newHighlight = green bold 22
30+ newNormal = green bold
31+ oldHighlight = red bold 52
32+ oldNormal = red bold
33+[color "status"]
34+ added = green
35+ changed = yellow
36+ untracked = cyan
37+[commit]
38+ gpgsign = true
39+[core]
40+ editor = /usr/bin/vim
41+ # global exclude
42+ excludesfile = /home/frank/.config/git/ignore
43+ pager = delta
44+ ; broken on old machines
45+ untrackedCache = true
46+[credential]
47+ helper = store
48+[delta]
49+ features = line-numbers decorations
50+ max-line-length = 1024
51+ whitespace-error-style = 22 reverse
52+[delta "decorations"]
53+ commit-decoration-style = bold yellow box ul
54+ file-decoration-style = none
55+ file-style = bold yellow
56+ syntax-theme = gruvbox
57+[diff]
58+ submodule = diff
59+ algorithm = histogram
60+ renames = copies
61+[difftool]
62+ prompt = false
63+[difftool "wrapper"]
64+ binary = true
65+ cmd = git-difftool-wrapper \"$LOCAL\" \"$REMOTE\"
66+[diff "pdfconv"]
67+ textconv = pdftohtml -stdout
68+[fetch]
69+ negotiationAlgorithm = skipping
70+ parallel = 0
71+[help]
72+ autocorrect = 1
73+[index]
74+ version = 4
75+[interactive]
76+ diffFilter = delta --color-only
77+[merge]
78+ log = true
79+[protocol]
80+ version = 2
81+[pull]
82+ rebase = true
83+[push]
84+ default = current
85+ recurseSubmodules = on-demand
86+[rebase]
87+ autoStash = true
88+[rerere]
89+ autoUpdate = true
90+ enabled = true
91+[sequence]
92+ editor = interactive-rebase-tool
93+[submodule]
94+ fetchJobs = 0
95+[tag]
96+ gpgSign = true
97+ sort = -version:refname
98+[url "git@gist.github.com:"]
99+ insteadOf = gist:
100+ pushInsteadOf = https://gist.github.com/
101+[url "git@github.com:"]
102+ insteadOf = gh:
103+ pushInsteadOf = https://github.com/
104+[user]
105+ email = f.nord@example.com
106+ name = Frank Nord
107+ signingkey = AAAAAAAAAAAAAAAA
tests/syntax-tests/highlighted/Graphviz DOT/test_digraph.dotnew file+41
@@ -0,0 +1,41 @@
1+digraph {
2+ label = <Label <font color='red'><b>formating</b></font>,<br/> test <font point-size='20'>is</font> done<br/> here <i>now.</i>>;
3+
4+ node [shape=box]
5+ rankdir=LR
6+ margin=0.1
7+ a->b
8+
9+ // http://www.graphviz.org/doc/info/colors.html
10+ // note: style=filled!
11+ node [shape=box colorscheme=paired12 style=filled]
12+ margin=0.1
13+ a2[fillcolor=1]
14+ b2[fillcolor=3]
15+ a2->b2->x2
16+
17+ // http://www.graphviz.org/doc/info/colors.html
18+ // note: style=filled!
19+ node [shape=box colorscheme=paired12 style=filled]
20+ rankdir=LR
21+ margin=0.1
22+ c1[fillcolor=1]
23+ c2[fillcolor=2]
24+ c3[fillcolor=3]
25+ c4[fillcolor=4]
26+ c5[fillcolor=5]
27+ c6[fillcolor=6]
28+ c7[fillcolor=7]
29+ c8[fillcolor=8]
30+ c9[fillcolor=9]
31+ c10[fillcolor=10]
32+ c11[fillcolor=11]
33+ c12[fillcolor=12]
34+ c->{c1 c3 c5 c7 c9 c11}
35+ c1->c2
36+ c3->c4
37+ c5->c6
38+ c7->c8
39+ c9->c10
40+ c11->c12
41+}
tests/syntax-tests/highlighted/Graphviz DOT/test_graph.dotnew file+3
@@ -0,0 +1,3 @@
1+graph {
2+ a--b
3+}
tests/syntax-tests/highlighted/MATLAB/test.matlabnew file+34
@@ -0,0 +1,34 @@
1+function zz=sample(aa)
2+%%%%%%%%%%%%%%%%%%
3+% some comments
4+%%%%%%%%%%%%%%%%%%
5+
6+x = 'a string'; % some 'ticks' in a comment
7+y = 'a string with ''interal'' quotes';
8+
9+for i=1:20
10+ disp(i);
11+end
12+
13+a = rand(30);
14+b = rand(30);
15+
16+c = a .* b ./ a \ ... comment at end of line and continuation
17+ (b .* a + b - a);
18+
19+c = a' * b'; % note: these ticks are for transpose, not quotes.
20+
21+disp('a comment symbol, %, in a string');
22+
23+!echo abc % this isn't a comment - it's passed to system command
24+
25+function y=myfunc(x)
26+y = exp(x);
27+
28+%{
29+ a block comment
30+%}
31+
32+function no_arg_func
33+fprintf('%s\n', 'function with no args')
34+end
tests/syntax-tests/highlighted/Manpage/bat-0.16.man+3−3
@@ -1,12 +1,12 @@
11BAT(1) General Commands Manual BAT(1)
22
33NAME
4− bat - a cat(1) clone with syntax highlighting and Git integration.
4+ bat - a cat(1) clone with syntax highlighting and Git integration.
55
66USAGE
7− bat [OPTIONS] [FILE]...
7+ bat [OPTIONS] [FILE]...
88
9− bat cache [CACHE-OPTIONS] [--build|--clear]
9+ bat cache [CACHE-OPTIONS] [--build|--clear]
1010
1111DESCRIPTION
1212 bat prints the syntax-highlighted content of a collection of FILEs to
tests/syntax-tests/highlighted/Manpage/select-2.man+49−49
@@ -18,9 +18,9 @@
1818 fd_set *exceptfds, const struct timespec *timeout,
1919 const sigset_t *sigmask);
2020
21− Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
21+ Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
2222
23− pselect(): _POSIX_C_SOURCE >= 200112L
23+ pselect(): _POSIX_C_SOURCE >= 200112L
2424
2525DESCRIPTION
2626 select() allows a program to monitor multiple file descriptors, waiting until one or more of the file descriptors become
@@ -142,17 +142,17 @@
142142 The timeout
143143 The timeout argument for select() is a structure of the following type:
144144
145− struct timeval {
146− time_t tv_sec; /* seconds */
147− suseconds_t tv_usec; /* microseconds */
148− };
145+ struct timeval {
146+ time_t tv_sec; /* seconds */
147+ suseconds_t tv_usec; /* microseconds */
148+ };
149149
150150 The corresponding argument for pselect() has the following type:
151151
152− struct timespec {
153− time_t tv_sec; /* seconds */
154− long tv_nsec; /* nanoseconds */
155− };
152+ struct timespec {
153+ time_t tv_sec; /* seconds */
154+ long tv_nsec; /* nanoseconds */
155+ };
156156
157157 On Linux, select() modifies timeout to reflect the amount of time not slept; most other implementations do not do this.
158158 (POSIX.1 permits either behavior.) This causes problems both when Linux code which reads timeout is ported to other operating
@@ -213,14 +213,14 @@
213213 Within the Linux kernel source, we find the following definitions which show the correspondence between the readable,
214214 writable, and exceptional condition notifications of select() and the event notifications provided by poll(2) and epoll(7):
215215
216− #define POLLIN_SET (EPOLLRDNORM | EPOLLRDBAND | EPOLLIN |
217− EPOLLHUP | EPOLLERR)
218− /* Ready for reading */
219− #define POLLOUT_SET (EPOLLWRBAND | EPOLLWRNORM | EPOLLOUT |
220− EPOLLERR)
221− /* Ready for writing */
222− #define POLLEX_SET (EPOLLPRI)
223− /* Exceptional condition */
216+ #define POLLIN_SET (EPOLLRDNORM | EPOLLRDBAND | EPOLLIN |
217+ EPOLLHUP | EPOLLERR)
218+ /* Ready for reading */
219+ #define POLLOUT_SET (EPOLLWRBAND | EPOLLWRNORM | EPOLLOUT |
220+ EPOLLERR)
221+ /* Ready for writing */
222+ #define POLLEX_SET (EPOLLPRI)
223+ /* Exceptional condition */
224224
225225 Multithreaded applications
226226 If a file descriptor being monitored by select() is closed in another thread, the result is unspecified. On some UNIX sys‐
@@ -242,11 +242,11 @@
242242
243243 The final argument of the pselect6() system call is not a sigset_t * pointer, but is instead a structure of the form:
244244
245− struct {
246− const kernel_sigset_t *ss; /* Pointer to signal set */
247− size_t ss_len; /* Size (in bytes) of object
248− pointed to by 'ss' */
249− };
245+ struct {
246+ const kernel_sigset_t *ss; /* Pointer to signal set */
247+ size_t ss_len; /* Size (in bytes) of object
248+ pointed to by 'ss' */
249+ };
250250
251251 This allows the system call to obtain both a pointer to the signal set and its size, while allowing for the fact that most ar‐
252252 chitectures support a maximum of 6 arguments to a system call. See sigprocmask(2) for a discussion of the difference between
@@ -283,40 +283,40 @@
283283 by internally copying the timeout to a local variable and passing that variable to the system call.
284284
285285EXAMPLES
286− #include <stdio.h>
287− #include <stdlib.h>
288− #include <sys/select.h>
286+ #include <stdio.h>
287+ #include <stdlib.h>
288+ #include <sys/select.h>
289289
290− int
291− main(void)
292− {
293− fd_set rfds;
294− struct timeval tv;
295− int retval;
290+ int
291+ main(void)
292+ {
293+ fd_set rfds;
294+ struct timeval tv;
295+ int retval;
296296
297− /* Watch stdin (fd 0) to see when it has input. */
297+ /* Watch stdin (fd 0) to see when it has input. */
298298
299− FD_ZERO(&rfds);
300− FD_SET(0, &rfds);
299+ FD_ZERO(&rfds);
300+ FD_SET(0, &rfds);
301301
302− /* Wait up to five seconds. */
302+ /* Wait up to five seconds. */
303303
304− tv.tv_sec = 5;
305− tv.tv_usec = 0;
304+ tv.tv_sec = 5;
305+ tv.tv_usec = 0;
306306
307− retval = select(1, &rfds, NULL, NULL, &tv);
308− /* Don't rely on the value of tv now! */
307+ retval = select(1, &rfds, NULL, NULL, &tv);
308+ /* Don't rely on the value of tv now! */
309309
310− if (retval == -1)
311− perror("select()");
312− else if (retval)
313− printf("Data is available now.\n");
314− /* FD_ISSET(0, &rfds) will be true. */
315− else
316− printf("No data within five seconds.\n");
310+ if (retval == -1)
311+ perror("select()");
312+ else if (retval)
313+ printf("Data is available now.\n");
314+ /* FD_ISSET(0, &rfds) will be true. */
315+ else
316+ printf("No data within five seconds.\n");
317317
318− exit(EXIT_SUCCESS);
319− }
318+ exit(EXIT_SUCCESS);
319+ }
320320
321321SEE ALSO
322322 accept(2), connect(2), poll(2), read(2), recv(2), restart_syscall(2), send(2), sigprocmask(2), write(2), epoll(7), time(7)
tests/syntax-tests/highlighted/PowerShell/test.ps1new file+25
@@ -0,0 +1,25 @@
1+# PowerShell script for testing syntax highlighting
2+
3+function Get-FutureTime {
4+ param (
5+ [Int32] $Minutes
6+ )
7+ 
8+ $time = Get-Date | % { $_.AddMinutes($Minutes) }
9+ "{0:d2}:{1:d2}:{2:d2}" -f @($time.hour, $time.minute, $time.second)
10+}
11+
12+if ($env:PATH -match '.*rust.*') {
13+ 'Path contains Rust'
14+ try {
15+ & "cargo" "--version"
16+ } catch {
17+ Write-Error "Failed to run cargo"
18+ }
19+} else {
20+ 'Path does not contain Rust'
21+}
22+
23+(5..30) | ? { $_ % (2 * 2 + 1) -eq 0 } | % {"In {0} minutes, the time will be {1}." -f $_, $( Get-FutureTime $_ )}
24+$later = Get-FutureTime -Minutes $( Get-Random -Minimum 60 -Maximum 120 )
25+"The time will be " + $later + " later."
tests/syntax-tests/highlighted/QML/BatSyntaxTest.qmlnew file+219
@@ -0,0 +1,219 @@
1+import QtQuick 2.0
2+import "../components"
3+
4+Page {
5+ id: page
6+
7+ // properties
8+
9+ property bool startup: true
10+ readonly property var var1: null
11+ readonly property QtObject var2: null
12+
13+ allowedOrientations: Orientation.All
14+
15+ /* components */
16+
17+ DBusServiceWatcher {
18+ id: dbusService
19+ service: "org.bat.service"
20+
21+ onRegisteredChanged: {
22+ if (dbusService.registered) {
23+ announcedNameField.text = daemon.announcedName()
24+ }
25+ }
26+ }
27+
28+ Component.onCompleted: {
29+ console.debug("completed")
30+ }
31+
32+ Flickable {
33+ anchors.fill: parent
34+ contentHeight: column.height
35+ visible: dbusService.registered
36+
37+ ViewPlaceholder {
38+ enabled: !startup
39+ && trustedDevices.count == 0
40+ && nearDevices.count == 0
41+ text: qsTr("Install Bat.")
42+ }
43+
44+ Column {
45+ id: column
46+
47+ width: page.width
48+ spacing: Theme.paddingLarge
49+
50+ PageHeader {
51+ title: qsTr("Syntax Test")
52+ }
53+
54+ TextField {
55+ id: announcedNameField
56+ width: parent.width
57+ label: qsTr("Device Name")
58+ text: dbusService.registered ? daemon.announcedName() : ""
59+
60+ onActiveFocusChanged: {
61+ if (activeFocus)
62+ return
63+
64+ if (text.length === 0) {
65+ text = daemon.announcedName()
66+ } else {
67+ daemon.setAnnouncedName(text)
68+ placeholderText = text
69+ }
70+ }
71+
72+ EnterKey.onClicked: announcedNameField.focus = false
73+ EnterKey.iconSource: "image://theme/icon-m-enter-close"
74+ }
75+
76+
77+ Component {
78+ id: deviceDelegate
79+
80+ ListItem {
81+ id: listItem
82+
83+ property bool showStatus: deviceStatusLabel.text.length
84+
85+ width: page.width
86+ height: Theme.itemSizeMedium
87+
88+ Image {
89+ id: icon
90+ source: iconUrl
91+
92+ x: Theme.horizontalPageMargin
93+ anchors.verticalCenter: parent.verticalCenter
94+ sourceSize.width: Theme.iconSizeMedium
95+ sourceSize.height: Theme.iconSizeMedium
96+ }
97+
98+ Label {
99+ id: deviceNameLabel
100+ anchors {
101+ left: icon.right
102+ leftMargin: Theme.paddingLarge
103+ right: parent.right
104+ rightMargin: Theme.horizontalPageMargin
105+ }
106+ y: listItem.contentHeight / 2 - implicitHeight / 2
107+ - showStatus * (deviceStatusLabel.implicitHeight / 2)
108+
109+ text: name
110+ color: listItem.highlighted
111+ ? Theme.highlightColor
112+ : Theme.primaryColor
113+ truncationMode: TruncationMode.Fade
114+ textFormat: Text.PlainText
115+
116+ Behavior on y { NumberAnimation {} }
117+ }
118+
119+ Label {
120+ id: deviceStatusLabel
121+ anchors {
122+ left: deviceNameLabel.left
123+ top: deviceNameLabel.bottom
124+ right: parent.right
125+ rightMargin: Theme.horizontalPageMargin
126+ }
127+
128+ text: (trusted && reachable)
129+ ? qsTr("Connected")
130+ : (hasPairingRequests || waitsForPairing
131+ ? qsTr("Pending pairing request ...") : "")
132+ color: listItem.highlighted
133+ ? Theme.secondaryHighlightColor
134+ : Theme.secondaryColor
135+ truncationMode: TruncationMode.Fade
136+ font.pixelSize: Theme.fontSizeExtraSmall
137+ opacity: showStatus ? 1.0 : 0.0
138+ width: parent.width
139+ textFormat: Text.PlainText
140+
141+ Behavior on opacity { FadeAnimation {} }
142+ }
143+
144+ onClicked: {
145+ pageStack.push(
146+ Qt.resolvedUrl("DevicePage.qml"),
147+ { deviceId: id })
148+ }
149+ }
150+ }
151+
152+ DeviceListModel {
153+ id: devicelistModel
154+ }
155+
156+ ColumnView {
157+ id: devicesView
158+ width: page.width
159+ itemHeight: Theme.itemSizeMedium
160+
161+
162+ model: trustedDevicesModel
163+ delegate: deviceDelegate
164+ visible: devicesView.count > 0
165+ }
166+ }
167+
168+ PullDownMenu {
169+// MenuItem {
170+// text: qsTr("About ...")
171+// onClicked: pageStack.push(Qt.resolvedUrl("AboutPage.qml"))
172+// }
173+
174+ MenuItem {
175+ text: qsTr("Settings ...")
176+ onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
177+ }
178+ }
179+
180+ VerticalScrollDecorator {}
181+ }
182+
183+ /*
184+ Connections {
185+ target: ui
186+ onOpeningDevicePage: openDevicePage(deviceId)
187+ }*/
188+
189+ Timer {
190+ interval: 1000
191+ running: true
192+ repeat: false
193+ onTriggered: startup = false
194+ }
195+
196+ function openDevicePage(deviceId) {
197+ if (typeof pageStack === "undefined")
198+ return;
199+
200+ console.log("opening device " + deviceId)
201+
202+ window.activate()
203+
204+ var devicePage = pageStack.find(function(page) {
205+ return page.objectName === "DevicePage"
206+ })
207+ if (devicePage !== null && devicePage.deviceId === deviceId) {
208+ pageStack.pop(devicePage)
209+ ui.showMainWindow()
210+ return
211+ }
212+
213+ pageStack.pop(page, PageStackAction.Immediate)
214+ pageStack.push(
215+ Qt.resolvedUrl("DevicePage.qml"),
216+ { deviceId: deviceId },
217+ PageStackAction.Immediate)
218+ }
219+}
tests/syntax-tests/highlighted/SLS/test.slsnew file+57
@@ -0,0 +1,57 @@
1+required_packages:
2+ pkg.installed:
3+ - pkgs:
4+ - git
5+ - perl
6+ - fortune
7+
8+cowsay_source:
9+ git.latest:
10+ - name: https://github.com/jasonm23/cowsay.git
11+ - target: /root/cowsay
12+
13+run_installer:
14+ cmd.run:
15+ - name: ./install.sh /usr/local
16+ - cwd: /root/cowsay
17+ - onchanges:
18+ - git: cowsay_source
19+
20+{% set cowfiles = salt.cmd.run('cowsay -l').split('\n')[1:] %}
21+{% set ascii_arts = cowfiles | join(' ') %}
22+
23+{% for ascii_art in ascii_arts.split(' ') %}
24+run_cowsay_{{ ascii_art }}: # name must be unique
25+ cmd.run:
26+ {% if ascii_art is in ['head-in', 'sodomized', 'telebears'] %}
27+ - name: echo cowsay -f {{ ascii_art }} should not be used
28+ {% else %}
29+ - name: fortune | cowsay -f {{ ascii_art }}
30+ {% endif %}
31+{% endfor %}
32+
33+echo_pillar_demo_1:
34+ cmd.run:
35+ - name: "echo {{ pillar.demo_text | default('pillar not defined') }}"
36+
37+echo_pillar_demo_2:
38+ cmd.run:
39+ - name: "echo {{ pillar.demo.text | default('pillar not defined') }}"
40+
41+# Comment
42+{% set rand = salt['random.get_str'](20) %}
43+{% set IP_Address = pillar['IP_Address'] %}
44+
45+wait:
46+ cmd.run:
47+ - name: sleep 210 # another comment
48+
49+create_roster_file:
50+ file.managed:
51+ - name: /tmp/salt-roster-{{ rand }}
52+ - contents:
53+ - 'switch:'
54+ - ' host: {{ IP_Address }}'
55+ - " user: test"
56+ - " passwd: {{ passwd }}"
57+
tests/syntax-tests/highlighted/Svelte/App.sveltenew file+57
@@ -0,0 +1,57 @@
1+<script>
2+ import { onMount } from 'svelte';
3+ import List from './List.svelte';
4+ import Item from './Item.svelte';
5+
6+ let item;
7+ let page;
8+
9+ async function hashchange() {
10+ // the poor man's router!
11+ const path = window.location.hash.slice(1);
12+
13+ if (path.startsWith('/item')) {
14+ const id = path.slice(6);
15+ item = await fetch(`https://node-hnapi.herokuapp.com/item/${id}`).then(r => r.json());
16+
17+ window.scrollTo(0,0);
18+ } else if (path.startsWith('/top')) {
19+ page = +path.slice(5);
20+ item = null;
21+ } else {
22+ window.location.hash = '/top/1';
23+ }
24+ }
25+
26+ onMount(hashchange);
27+</script>
28+
29+<style>
30+ main {
31+ position: relative;
32+ max-width: 800px;
33+ margin: 0 auto;
34+ min-height: 101vh;
35+ padding: 1em;
36+ }
37+
38+ main :global(.meta) {
39+ color: #999;
40+ font-size: 12px;
41+ margin: 0 0 1em 0;
42+ }
43+
44+ main :global(a) {
45+ color: rgb(0,0,150);
46+ }
47+</style>
48+
49+<svelte:window on:hashchange={hashchange}/>
50+
51+<main>
52+ {#if item}
53+ <Item {item} returnTo="#/top/{page}"/>
54+ {:else if page}
55+ <List {page}/>
56+ {/if}
57+</main>
tests/syntax-tests/highlighted/Vue/example.vuenew file+55
@@ -0,0 +1,55 @@
1+<template>
2+ <div id="app" class="container-fluid">
3+ <AppHeader></AppHeader>
4+ <transition name="page" mode="out-in" v-if="!isLoading">
5+ <router-view></router-view>
6+ </transition>
7+ <AppLoadingIndicator></AppLoadingIndicator>
8+ </div>
9+</template>
10+
11+<script>
12+import AppHeader from "@/components/AppHeader";
13+import AppLoadingIndicator from "@/components/AppLoadingIndicator";
14+import { mapGetters } from "vuex";
15+
16+export default {
17+ name: "App",
18+ components: {
19+ AppHeader,
20+ AppLoadingIndicator,
21+ },
22+ beforeCreate() {
23+ this.$store.dispatch("fetchData");
24+ },
25+ data: {
26+ message: "Hello!"
27+ },
28+ computed: {
29+ ...mapGetters({
30+ isLoading: "isLoading",
31+ }),
32+ },
33+};
34+</script>
35+
36+<style>
37+body {
38+ background-color: rgba(72, 163, 184, 0.05) !important;
39+}
40+
41+.page-enter-active,
42+.page-leave-active {
43+ transition: opacity 0.2s;
44+}
45+
46+.page-enter,
47+.page-leave-active {
48+ opacity: 0;
49+}
50+
51+.page-enter:hover {
52+ opacity: 1;
53+}
54+
55+</style>
tests/syntax-tests/highlighted/nginx/nginx.confnew file+140
@@ -0,0 +1,140 @@
1+#user nobody;
2+worker_processes 1;
3+#pid logs/nginx.pid;
4+
5+load_module "/usr/local/libexec/nginx/ngx_http_xslt_filter_module.so";
6+load_module "/usr/local/libexec/nginx/ngx_rtmp_module.so";
7+
8+events {
9+ worker_connections 1024;
10+}
11+
12+http {
13+ include mime.types;
14+ default_type application/octet-stream;
15+ sendfile  on;
16+ keepalive_timeout 65;
17+ gzip  on;
18+ gzip_disable "msie6";
19+
20+ include /usr/local/etc/nginx/sites.d/*;
21+}
22+
23+rtmp {
24+ server {
25+ listen 1935;
26+ max_message 10M;
27+
28+ application wnob {
29+ live on;
30+ record off;
31+ }
32+
33+ application strim {
34+ live on;
35+ hls on;
36+
37+ hls_path /usr/local/www/hls/;
38+
39+ hls_variant _low BANDWIDTH=250000;
40+ hls_variant _mid BANDWIDTH=500000;
41+ hls_variant _high BANDWIDTH=1000000;
42+ hls_variant _hd720 BANDWIDTH=1500000;
43+ hls_variant _src BANDWIDTH=2000000;
44+ }
45+ }
46+}
47+
48+server {
49+ listen 443 ssl;
50+ server_name host.example.com
51+ root /usr/local/www/host.example.com/;
52+ error_page 404 /404.html;
53+
54+ index index.html;
55+ autoindex on;
56+ autoindex_localtime off;
57+ autoindex_format xml;
58+
59+ location / {
60+ xslt_stylesheet /usr/local/www/host.example.com/index.xslt;
61+ }
62+
63+ location ~ /\..* {
64+ return 404;
65+ }
66+
67+ location ~ /.+/ {
68+ xslt_stylesheet /usr/local/www/host.example.com/project.xslt;
69+ }
70+
71+ location ~ /.*\.xslt/ {
72+ return 404;
73+ }
74+
75+ location ~ \.thumb\.png$ {
76+ error_page 404 /404.thumb.png;
77+ }
78+ ssl_certificate /usr/local/etc/letsencrypt/live/host.example.com/fullchain.pem; # managed by Certbot
79+ ssl_certificate_key /usr/local/etc/letsencrypt/live/host.example.com/privkey.pem; # managed by Certbot
80+
81+ include /usr/local/etc/letsencrypt/options-ssl-nginx.conf;
82+ ssl_dhparam /usr/local/etc/letsencrypt/ssl-dhparams.pem;
83+
84+ add_header Strict-Transport-Security "max-age=31536000" always;
85+
86+}
87+
88+server {
89+ listen 80;
90+ server_name host.example.com;
91+
92+ if ($host = host.example.com) {
93+ return 301 https://$host$request_uri;
94+ }
95+
96+ return 404;
97+}
98+
99+server {
100+ listen 443 ssl;
101+ server_name other.example.com;
102+
103+ ssl_certificate /usr/local/etc/letsencrypt/live/other.example.com/fullchain.pem;
104+ ssl_certificate_key /usr/local/etc/letsencrypt/live/other.example.com/privkey.pem;
105+
106+ include /usr/local/etc/letsencrypt/options-ssl-nginx.conf;
107+ ssl_dhparam /usr/local/etc/letsencrypt/ssl-dhparams.pem;
108+
109+ add_header Strict-Transport-Security "max-age=31536000" always;
110+
111+ access_log /home/otherapp/logs/access.log;
112+ error_log /home/otherapp/logs/error.log;
113+
114+ client_max_body_size 5M;
115+
116+ location / {
117+ root /home/otherapp/app/static;
118+ index man.txt;
119+ try_files $uri @proxy;
120+ }
121+
122+ location @proxy {
123+ proxy_set_header Host $http_host;
124+ proxy_set_header X-Forwarded-Host $host;
125+ proxy_set_header X-Real-IP $remote_addr;
126+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
127+ proxy_pass http://unix:/var/run/otherapp/sock:;
128+ }
129+}
130+
131+server {
132+ listen 80;
133+ server_name other.example.com;
134+
135+ if ($host = other.example.com) {
136+ return 301 https://$host$request_uri;
137+ }
138+
139+ return 404;
140+}
tests/syntax-tests/highlighted/nix/test.nixnew file+15
@@ -0,0 +1,15 @@
1+{ nixpkgs ? <nixpkgs>
2+, nixpkgs' ? import nixpkgs {}}: with nixpkgs';
3+
4+# some comment
5+stdenv.mkDerivation rec {
6+ pname = "test";
7+ version = "0.2.3";
8+ name = "${pname}-${version}";
9+
10+ buildInputs = [
11+ gzip
12+ bzip2
13+ python27
14+ ];
15+}
tests/syntax-tests/highlighted/orgmode/test.orgnew file+38
@@ -0,0 +1,38 @@
1+* This is header
2+** sub header
3+*** sub sub header
4+**** sub sub sub header
5+
6+* Table representation
7+| Name | Age |
8+|---------+-----|
9+| Milli | 23 |
10+| Vanilli | 22 |
11+
12+* Spreadsheets
13+| n | n + 2 | n ^ 2 |
14+|---+-------+-------|
15+| 1 | 3 | 1 |
16+| 2 | 4 | 4 |
17+| 3 | 5 | 9 |
18+#+TBLFM: $2=$1+2::$3=$1*$1
19+
20+* Source Code
21+
22+#+BEGIN_SRC rust
23+ # recursive fibonacci
24+ fn fib(n: u32) -> u32 {
25+ match n {
26+ 0 | 1 => 1,
27+ _ => fib(n - 1) + fib(n - 2),
28+ }
29+ }
30+#+END_SRC
31+
32+* ToDo and Checkboxes Example
33+** DONE Write source example
34+** TODO Generate highlighted example [1/3]
35+ - [X] run update script
36+ - [-] get code review
37+ - [ ] merge into master
38+
tests/syntax-tests/source/D/test.dnew file+44
@@ -0,0 +1,44 @@
1+// selective import
2+import std.stdio : writeln, writefln;
3+// non-selective import
4+import std.algorithm;
5+
6+/* a multiline comment
7+*
8+* this function is safe because it doesn't use pointer arithmetic
9+*/
10+int the_ultimate_answer() @safe {
11+ // assert1on
12+ assert(1 != 2);
13+ // now we can safely return our answer
14+ return 42;
15+}
16+
17+void main()
18+{
19+ // function call with string literal
20+ writeln("Hello World!");
21+
22+ // an int array declaration
23+ int[] arr1 = [1, 2, 3];
24+ // an immutable double
25+ immutable double pi = 3.14;
26+ // a mutable double
27+ double d1 = pi;
28+ // a pointer
29+ double* dp1 = &d1;
30+ // another pointer to the same thingy
31+ auto a1 = &d1;
32+ // a constant bool
33+ const bool b1 = true;
34+ if (b1) {
35+ // another function call
36+ writefln("%s\n%s\n%s\n", arr1, d1, the_ultimate_answer());
37+ }
38+ else if (!b1) {
39+ writeln("this seems wrong");
40+ }
41+ else {
42+ writeln("I'm giving up, this is too crazy for me");
43+ }
44+}
tests/syntax-tests/source/EtcGroup/test.groupnew file+67
@@ -0,0 +1,67 @@
1+root:x:0:root
2+sys:x:3:bin
3+mem:x:8:
4+ftp:x:11:
5+mail:x:12:
6+log:x:19:
7+smmsp:x:25:
8+proc:x:26:polkitd
9+games:x:50:
10+lock:x:54:
11+network:x:90:
12+floppy:x:94:
13+scanner:x:96:
14+power:x:98:
15+adm:x:999:daemon
16+wheel:x:998:username
17+kmem:x:997:
18+tty:x:5:
19+utmp:x:996:
20+audio:x:995:mpd,username
21+disk:x:994:
22+input:x:993:
23+kvm:x:992:
24+lp:x:991:
25+optical:x:990:username
26+render:x:989:
27+storage:x:988:username
28+uucp:x:987:
29+video:x:986:username
30+users:x:985:
31+systemd-journal:x:984:
32+rfkill:x:983:
33+bin:x:1:daemon
34+daemon:x:2:bin
35+http:x:33:
36+nobody:x:65534:
37+dbus:x:81:
38+systemd-journal-remote:x:982:
39+systemd-network:x:981:
40+systemd-resolve:x:980:
41+systemd-timesync:x:979:
42+systemd-coredump:x:978:
43+uuidd:x:68:
44+username:x:1000:
45+git:x:977:
46+avahi:x:976:
47+colord:x:975:
48+polkitd:x:102:
49+mpd:x:45:
50+rtkit:x:133:
51+transmission:x:169:
52+wireshark:x:150:username
53+lightdm:x:974:
54+geoclue:x:973:
55+usbmux:x:140:
56+dhcpcd:x:972:
57+brlapi:x:971:
58+gdm:x:120:
59+libvirt:x:970:
60+flatpak:x:969:
61+gluster:x:968:
62+rpc:x:32:
63+tor:x:43:
64+rslsync:x:967:
65+docker:x:966:username
66+sambashare:x:1002:username
67+named:x:40:
tests/syntax-tests/source/Git Attributes/example.gitattributesnew file+16
@@ -0,0 +1,16 @@
1+#
2+# Comment
3+
4+[attr]binary -diff -merge -text
5+
6+* text=auto
7+*.c diff=c
8+*.cc text diff=cpp
9+*.o binary
10+*.bat text eol=crlf
11+*.lock text -diff
12+*.*ignore text
13+*.patch -text
14+
15+.gitattributes linguist-language=gitattributes
16+.gitkeep export-ignore
tests/syntax-tests/source/Git Config/LICENSE.mdnew file+1
@@ -0,0 +1 @@
1+The `test.gitconfig` file has been added from https://github.com/sharkdp/bat/pull/1336#issuecomment-715905807. Its "free to use".
tests/syntax-tests/source/Git Config/text.gitconfignew file+107
@@ -0,0 +1,107 @@
1+[alias]
2+ br = branch
3+ branch = branch -a
4+ c = clone --recursive
5+ ci = commit
6+ cl = clone
7+ co = checkout
8+ contributors = shortlog --summary --numbered
9+ lg = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)'
10+ remote = remote -v
11+ st = status
12+ tag = tag -l
13+[apply]
14+ whitespace = fix
15+[color]
16+ ui = true
17+[color "branch"]
18+ current = yellow
19+ local = yellow
20+ remote = green
21+[color "diff"]
22+ commit = yellow bold
23+ frag = magenta bold
24+ meta = yellow
25+ new = green bold
26+ old = red bold
27+ whitespace = red reverse
28+[color "diff-highlight"]
29+ newHighlight = green bold 22
30+ newNormal = green bold
31+ oldHighlight = red bold 52
32+ oldNormal = red bold
33+[color "status"]
34+ added = green
35+ changed = yellow
36+ untracked = cyan
37+[commit]
38+ gpgsign = true
39+[core]
40+ editor = /usr/bin/vim
41+ # global exclude
42+ excludesfile = /home/frank/.config/git/ignore
43+ pager = delta
44+ ; broken on old machines
45+ untrackedCache = true
46+[credential]
47+ helper = store
48+[delta]
49+ features = line-numbers decorations
50+ max-line-length = 1024
51+ whitespace-error-style = 22 reverse
52+[delta "decorations"]
53+ commit-decoration-style = bold yellow box ul
54+ file-decoration-style = none
55+ file-style = bold yellow
56+ syntax-theme = gruvbox
57+[diff]
58+ submodule = diff
59+ algorithm = histogram
60+ renames = copies
61+[difftool]
62+ prompt = false
63+[difftool "wrapper"]
64+ binary = true
65+ cmd = git-difftool-wrapper \"$LOCAL\" \"$REMOTE\"
66+[diff "pdfconv"]
67+ textconv = pdftohtml -stdout
68+[fetch]
69+ negotiationAlgorithm = skipping
70+ parallel = 0
71+[help]
72+ autocorrect = 1
73+[index]
74+ version = 4
75+[interactive]
76+ diffFilter = delta --color-only
77+[merge]
78+ log = true
79+[protocol]
80+ version = 2
81+[pull]
82+ rebase = true
83+[push]
84+ default = current
85+ recurseSubmodules = on-demand
86+[rebase]
87+ autoStash = true
88+[rerere]
89+ autoUpdate = true
90+ enabled = true
91+[sequence]
92+ editor = interactive-rebase-tool
93+[submodule]
94+ fetchJobs = 0
95+[tag]
96+ gpgSign = true
97+ sort = -version:refname
98+[url "git@gist.github.com:"]
99+ insteadOf = gist:
100+ pushInsteadOf = https://gist.github.com/
101+[url "git@github.com:"]
102+ insteadOf = gh:
103+ pushInsteadOf = https://github.com/
104+[user]
105+ email = f.nord@example.com
106+ name = Frank Nord
107+ signingkey = AAAAAAAAAAAAAAAA
tests/syntax-tests/source/Graphviz DOT/LICENSE.mdnew file+22
@@ -0,0 +1,22 @@
1+The files `test_digraph.dot` and `test_graph.dot` are modified versions the files from https://github.com/scriptum/graphviz-examples/tree/a7762875efa32f90f6f1a37d866b2c26d362202a under the following license:
2+
3+The MIT License (MIT)
4+
5+Copyright (c) 2014 Pavel Roschin
6+
7+Permission is hereby granted, free of charge, to any person obtaining a copy of
8+this software and associated documentation files (the "Software"), to deal in
9+the Software without restriction, including without limitation the rights to
10+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11+the Software, and to permit persons to whom the Software is furnished to do so,
12+subject to the following conditions:
13+
14+The above copyright notice and this permission notice shall be included in all
15+copies or substantial portions of the Software.
16+
17+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
tests/syntax-tests/source/Graphviz DOT/test_digraph.dotnew file+41
@@ -0,0 +1,41 @@
1+digraph {
2+ label = <Label <font color='red'><b>formating</b></font>,<br/> test <font point-size='20'>is</font> done<br/> here <i>now.</i>>;
3+
4+ node [shape=box]
5+ rankdir=LR
6+ margin=0.1
7+ a->b
8+
9+ // http://www.graphviz.org/doc/info/colors.html
10+ // note: style=filled!
11+ node [shape=box colorscheme=paired12 style=filled]
12+ margin=0.1
13+ a2[fillcolor=1]
14+ b2[fillcolor=3]
15+ a2->b2->x2
16+
17+ // http://www.graphviz.org/doc/info/colors.html
18+ // note: style=filled!
19+ node [shape=box colorscheme=paired12 style=filled]
20+ rankdir=LR
21+ margin=0.1
22+ c1[fillcolor=1]
23+ c2[fillcolor=2]
24+ c3[fillcolor=3]
25+ c4[fillcolor=4]
26+ c5[fillcolor=5]
27+ c6[fillcolor=6]
28+ c7[fillcolor=7]
29+ c8[fillcolor=8]
30+ c9[fillcolor=9]
31+ c10[fillcolor=10]
32+ c11[fillcolor=11]
33+ c12[fillcolor=12]
34+ c->{c1 c3 c5 c7 c9 c11}
35+ c1->c2
36+ c3->c4
37+ c5->c6
38+ c7->c8
39+ c9->c10
40+ c11->c12
41+}
tests/syntax-tests/source/Graphviz DOT/test_graph.dotnew file+3
@@ -0,0 +1,3 @@
1+graph {
2+ a--b
3+}
tests/syntax-tests/source/MATLAB/LICENSE.mdnew file+27
@@ -0,0 +1,27 @@
1+The `test.matlab` file is a modified version of https://github.com/pygments/pygments/blob/3e1b79c82d2df318f63f24984d875fd2a3400808/tests/test_matlab.py under the following license:
2+
3+Copyright (c) 2006-2020 by the respective authors (see AUTHORS file).
4+All rights reserved.
5+
6+Redistribution and use in source and binary forms, with or without
7+modification, are permitted provided that the following conditions are
8+met:
9+
10+* Redistributions of source code must retain the above copyright
11+ notice, this list of conditions and the following disclaimer.
12+
13+* Redistributions in binary form must reproduce the above copyright
14+ notice, this list of conditions and the following disclaimer in the
15+ documentation and/or other materials provided with the distribution.
16+
17+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
tests/syntax-tests/source/MATLAB/test.matlabnew file+34
@@ -0,0 +1,34 @@
1+function zz=sample(aa)
2+%%%%%%%%%%%%%%%%%%
3+% some comments
4+%%%%%%%%%%%%%%%%%%
5+
6+x = 'a string'; % some 'ticks' in a comment
7+y = 'a string with ''interal'' quotes';
8+
9+for i=1:20
10+ disp(i);
11+end
12+
13+a = rand(30);
14+b = rand(30);
15+
16+c = a .* b ./ a \ ... comment at end of line and continuation
17+ (b .* a + b - a);
18+
19+c = a' * b'; % note: these ticks are for transpose, not quotes.
20+
21+disp('a comment symbol, %, in a string');
22+
23+!echo abc % this isn't a comment - it's passed to system command
24+
25+function y=myfunc(x)
26+y = exp(x);
27+
28+%{
29+ a block comment
30+%}
31+
32+function no_arg_func
33+fprintf('%s\n', 'function with no args')
34+end
tests/syntax-tests/source/PowerShell/test.ps1new file

Binary file not shown.

tests/syntax-tests/source/QML/BatSyntaxTest.qmlnew file+219
@@ -0,0 +1,219 @@
1+import QtQuick 2.0
2+import "../components"
3+
4+Page {
5+ id: page
6+
7+ // properties
8+
9+ property bool startup: true
10+ readonly property var var1: null
11+ readonly property QtObject var2: null
12+
13+ allowedOrientations: Orientation.All
14+
15+ /* components */
16+
17+ DBusServiceWatcher {
18+ id: dbusService
19+ service: "org.bat.service"
20+
21+ onRegisteredChanged: {
22+ if (dbusService.registered) {
23+ announcedNameField.text = daemon.announcedName()
24+ }
25+ }
26+ }
27+
28+ Component.onCompleted: {
29+ console.debug("completed")
30+ }
31+
32+ Flickable {
33+ anchors.fill: parent
34+ contentHeight: column.height
35+ visible: dbusService.registered
36+
37+ ViewPlaceholder {
38+ enabled: !startup
39+ && trustedDevices.count == 0
40+ && nearDevices.count == 0
41+ text: qsTr("Install Bat.")
42+ }
43+
44+ Column {
45+ id: column
46+
47+ width: page.width
48+ spacing: Theme.paddingLarge
49+
50+ PageHeader {
51+ title: qsTr("Syntax Test")
52+ }
53+
54+ TextField {
55+ id: announcedNameField
56+ width: parent.width
57+ label: qsTr("Device Name")
58+ text: dbusService.registered ? daemon.announcedName() : ""
59+
60+ onActiveFocusChanged: {
61+ if (activeFocus)
62+ return
63+
64+ if (text.length === 0) {
65+ text = daemon.announcedName()
66+ } else {
67+ daemon.setAnnouncedName(text)
68+ placeholderText = text
69+ }
70+ }
71+
72+ EnterKey.onClicked: announcedNameField.focus = false
73+ EnterKey.iconSource: "image://theme/icon-m-enter-close"
74+ }
75+
76+
77+ Component {
78+ id: deviceDelegate
79+
80+ ListItem {
81+ id: listItem
82+
83+ property bool showStatus: deviceStatusLabel.text.length
84+
85+ width: page.width
86+ height: Theme.itemSizeMedium
87+
88+ Image {
89+ id: icon
90+ source: iconUrl
91+
92+ x: Theme.horizontalPageMargin
93+ anchors.verticalCenter: parent.verticalCenter
94+ sourceSize.width: Theme.iconSizeMedium
95+ sourceSize.height: Theme.iconSizeMedium
96+ }
97+
98+ Label {
99+ id: deviceNameLabel
100+ anchors {
101+ left: icon.right
102+ leftMargin: Theme.paddingLarge
103+ right: parent.right
104+ rightMargin: Theme.horizontalPageMargin
105+ }
106+ y: listItem.contentHeight / 2 - implicitHeight / 2
107+ - showStatus * (deviceStatusLabel.implicitHeight / 2)
108+
109+ text: name
110+ color: listItem.highlighted
111+ ? Theme.highlightColor
112+ : Theme.primaryColor
113+ truncationMode: TruncationMode.Fade
114+ textFormat: Text.PlainText
115+
116+ Behavior on y { NumberAnimation {} }
117+ }
118+
119+ Label {
120+ id: deviceStatusLabel
121+ anchors {
122+ left: deviceNameLabel.left
123+ top: deviceNameLabel.bottom
124+ right: parent.right
125+ rightMargin: Theme.horizontalPageMargin
126+ }
127+
128+ text: (trusted && reachable)
129+ ? qsTr("Connected")
130+ : (hasPairingRequests || waitsForPairing
131+ ? qsTr("Pending pairing request ...") : "")
132+ color: listItem.highlighted
133+ ? Theme.secondaryHighlightColor
134+ : Theme.secondaryColor
135+ truncationMode: TruncationMode.Fade
136+ font.pixelSize: Theme.fontSizeExtraSmall
137+ opacity: showStatus ? 1.0 : 0.0
138+ width: parent.width
139+ textFormat: Text.PlainText
140+
141+ Behavior on opacity { FadeAnimation {} }
142+ }
143+
144+ onClicked: {
145+ pageStack.push(
146+ Qt.resolvedUrl("DevicePage.qml"),
147+ { deviceId: id })
148+ }
149+ }
150+ }
151+
152+ DeviceListModel {
153+ id: devicelistModel
154+ }
155+
156+ ColumnView {
157+ id: devicesView
158+ width: page.width
159+ itemHeight: Theme.itemSizeMedium
160+
161+
162+ model: trustedDevicesModel
163+ delegate: deviceDelegate
164+ visible: devicesView.count > 0
165+ }
166+ }
167+
168+ PullDownMenu {
169+// MenuItem {
170+// text: qsTr("About ...")
171+// onClicked: pageStack.push(Qt.resolvedUrl("AboutPage.qml"))
172+// }
173+
174+ MenuItem {
175+ text: qsTr("Settings ...")
176+ onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
177+ }
178+ }
179+
180+ VerticalScrollDecorator {}
181+ }
182+
183+ /*
184+ Connections {
185+ target: ui
186+ onOpeningDevicePage: openDevicePage(deviceId)
187+ }*/
188+
189+ Timer {
190+ interval: 1000
191+ running: true
192+ repeat: false
193+ onTriggered: startup = false
194+ }
195+
196+ function openDevicePage(deviceId) {
197+ if (typeof pageStack === "undefined")
198+ return;
199+
200+ console.log("opening device " + deviceId)
201+
202+ window.activate()
203+
204+ var devicePage = pageStack.find(function(page) {
205+ return page.objectName === "DevicePage"
206+ })
207+ if (devicePage !== null && devicePage.deviceId === deviceId) {
208+ pageStack.pop(devicePage)
209+ ui.showMainWindow()
210+ return
211+ }
212+
213+ pageStack.pop(page, PageStackAction.Immediate)
214+ pageStack.push(
215+ Qt.resolvedUrl("DevicePage.qml"),
216+ { deviceId: deviceId },
217+ PageStackAction.Immediate)
218+ }
219+}
tests/syntax-tests/source/SLS/test.slsnew file+57
@@ -0,0 +1,57 @@
1+required_packages:
2+ pkg.installed:
3+ - pkgs:
4+ - git
5+ - perl
6+ - fortune
7+
8+cowsay_source:
9+ git.latest:
10+ - name: https://github.com/jasonm23/cowsay.git
11+ - target: /root/cowsay
12+
13+run_installer:
14+ cmd.run:
15+ - name: ./install.sh /usr/local
16+ - cwd: /root/cowsay
17+ - onchanges:
18+ - git: cowsay_source
19+
20+{% set cowfiles = salt.cmd.run('cowsay -l').split('\n')[1:] %}
21+{% set ascii_arts = cowfiles | join(' ') %}
22+
23+{% for ascii_art in ascii_arts.split(' ') %}
24+run_cowsay_{{ ascii_art }}: # name must be unique
25+ cmd.run:
26+ {% if ascii_art is in ['head-in', 'sodomized', 'telebears'] %}
27+ - name: echo cowsay -f {{ ascii_art }} should not be used
28+ {% else %}
29+ - name: fortune | cowsay -f {{ ascii_art }}
30+ {% endif %}
31+{% endfor %}
32+
33+echo_pillar_demo_1:
34+ cmd.run:
35+ - name: "echo {{ pillar.demo_text | default('pillar not defined') }}"
36+
37+echo_pillar_demo_2:
38+ cmd.run:
39+ - name: "echo {{ pillar.demo.text | default('pillar not defined') }}"
40+
41+# Comment
42+{% set rand = salt['random.get_str'](20) %}
43+{% set IP_Address = pillar['IP_Address'] %}
44+
45+wait:
46+ cmd.run:
47+ - name: sleep 210 # another comment
48+
49+create_roster_file:
50+ file.managed:
51+ - name: /tmp/salt-roster-{{ rand }}
52+ - contents:
53+ - 'switch:'
54+ - ' host: {{ IP_Address }}'
55+ - " user: test"
56+ - " passwd: {{ passwd }}"
57+
tests/syntax-tests/source/Svelte/App.sveltenew file+57
@@ -0,0 +1,57 @@
1+<script>
2+ import { onMount } from 'svelte';
3+ import List from './List.svelte';
4+ import Item from './Item.svelte';
5+
6+ let item;
7+ let page;
8+
9+ async function hashchange() {
10+ // the poor man's router!
11+ const path = window.location.hash.slice(1);
12+
13+ if (path.startsWith('/item')) {
14+ const id = path.slice(6);
15+ item = await fetch(`https://node-hnapi.herokuapp.com/item/${id}`).then(r => r.json());
16+
17+ window.scrollTo(0,0);
18+ } else if (path.startsWith('/top')) {
19+ page = +path.slice(5);
20+ item = null;
21+ } else {
22+ window.location.hash = '/top/1';
23+ }
24+ }
25+
26+ onMount(hashchange);
27+</script>
28+
29+<style>
30+ main {
31+ position: relative;
32+ max-width: 800px;
33+ margin: 0 auto;
34+ min-height: 101vh;
35+ padding: 1em;
36+ }
37+
38+ main :global(.meta) {
39+ color: #999;
40+ font-size: 12px;
41+ margin: 0 0 1em 0;
42+ }
43+
44+ main :global(a) {
45+ color: rgb(0,0,150);
46+ }
47+</style>
48+
49+<svelte:window on:hashchange={hashchange}/>
50+
51+<main>
52+ {#if item}
53+ <Item {item} returnTo="#/top/{page}"/>
54+ {:else if page}
55+ <List {page}/>
56+ {/if}
57+</main>
tests/syntax-tests/source/Svelte/LICENSEnew file+14
@@ -0,0 +1,14 @@
1+The `App.svelte` file has been added from:
2+
3+https://github.com/sveltejs/svelte/blob/master/site/content/examples/21-miscellaneous/01-hacker-news/App.svelte
4+
5+Under the following license:
6+
7+
8+Copyright (c) 2016-20 [these people](https://github.com/sveltejs/svelte/graphs/contributors)
9+
10+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
11+
12+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13+
14+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
tests/syntax-tests/source/Vue/example.vuenew file+55
@@ -0,0 +1,55 @@
1+<template>
2+ <div id="app" class="container-fluid">
3+ <AppHeader></AppHeader>
4+ <transition name="page" mode="out-in" v-if="!isLoading">
5+ <router-view></router-view>
6+ </transition>
7+ <AppLoadingIndicator></AppLoadingIndicator>
8+ </div>
9+</template>
10+
11+<script>
12+import AppHeader from "@/components/AppHeader";
13+import AppLoadingIndicator from "@/components/AppLoadingIndicator";
14+import { mapGetters } from "vuex";
15+
16+export default {
17+ name: "App",
18+ components: {
19+ AppHeader,
20+ AppLoadingIndicator,
21+ },
22+ beforeCreate() {
23+ this.$store.dispatch("fetchData");
24+ },
25+ data: {
26+ message: "Hello!"
27+ },
28+ computed: {
29+ ...mapGetters({
30+ isLoading: "isLoading",
31+ }),
32+ },
33+};
34+</script>
35+
36+<style>
37+body {
38+ background-color: rgba(72, 163, 184, 0.05) !important;
39+}
40+
41+.page-enter-active,
42+.page-leave-active {
43+ transition: opacity 0.2s;
44+}
45+
46+.page-enter,
47+.page-leave-active {
48+ opacity: 0;
49+}
50+
51+.page-enter:hover {
52+ opacity: 1;
53+}
54+
55+</style>
tests/syntax-tests/source/nginx/nginx.confnew file+140
@@ -0,0 +1,140 @@
1+#user nobody;
2+worker_processes 1;
3+#pid logs/nginx.pid;
4+
5+load_module "/usr/local/libexec/nginx/ngx_http_xslt_filter_module.so";
6+load_module "/usr/local/libexec/nginx/ngx_rtmp_module.so";
7+
8+events {
9+ worker_connections 1024;
10+}
11+
12+http {
13+ include mime.types;
14+ default_type application/octet-stream;
15+ sendfile on;
16+ keepalive_timeout 65;
17+ gzip on;
18+ gzip_disable "msie6";
19+
20+ include /usr/local/etc/nginx/sites.d/*;
21+}
22+
23+rtmp {
24+ server {
25+ listen 1935;
26+ max_message 10M;
27+
28+ application wnob {
29+ live on;
30+ record off;
31+ }
32+
33+ application strim {
34+ live on;
35+ hls on;
36+
37+ hls_path /usr/local/www/hls/;
38+
39+ hls_variant _low BANDWIDTH=250000;
40+ hls_variant _mid BANDWIDTH=500000;
41+ hls_variant _high BANDWIDTH=1000000;
42+ hls_variant _hd720 BANDWIDTH=1500000;
43+ hls_variant _src BANDWIDTH=2000000;
44+ }
45+ }
46+}
47+
48+server {
49+ listen 443 ssl;
50+ server_name host.example.com
51+ root /usr/local/www/host.example.com/;
52+ error_page 404 /404.html;
53+
54+ index index.html;
55+ autoindex on;
56+ autoindex_localtime off;
57+ autoindex_format xml;
58+
59+ location / {
60+ xslt_stylesheet /usr/local/www/host.example.com/index.xslt;
61+ }
62+
63+ location ~ /\..* {
64+ return 404;
65+ }
66+
67+ location ~ /.+/ {
68+ xslt_stylesheet /usr/local/www/host.example.com/project.xslt;
69+ }
70+
71+ location ~ /.*\.xslt/ {
72+ return 404;
73+ }
74+
75+ location ~ \.thumb\.png$ {
76+ error_page 404 /404.thumb.png;
77+ }
78+ ssl_certificate /usr/local/etc/letsencrypt/live/host.example.com/fullchain.pem; # managed by Certbot
79+ ssl_certificate_key /usr/local/etc/letsencrypt/live/host.example.com/privkey.pem; # managed by Certbot
80+
81+ include /usr/local/etc/letsencrypt/options-ssl-nginx.conf;
82+ ssl_dhparam /usr/local/etc/letsencrypt/ssl-dhparams.pem;
83+
84+ add_header Strict-Transport-Security "max-age=31536000" always;
85+
86+}
87+
88+server {
89+ listen 80;
90+ server_name host.example.com;
91+
92+ if ($host = host.example.com) {
93+ return 301 https://$host$request_uri;
94+ }
95+
96+ return 404;
97+}
98+
99+server {
100+ listen 443 ssl;
101+ server_name other.example.com;
102+
103+ ssl_certificate /usr/local/etc/letsencrypt/live/other.example.com/fullchain.pem;
104+ ssl_certificate_key /usr/local/etc/letsencrypt/live/other.example.com/privkey.pem;
105+
106+ include /usr/local/etc/letsencrypt/options-ssl-nginx.conf;
107+ ssl_dhparam /usr/local/etc/letsencrypt/ssl-dhparams.pem;
108+
109+ add_header Strict-Transport-Security "max-age=31536000" always;
110+
111+ access_log /home/otherapp/logs/access.log;
112+ error_log /home/otherapp/logs/error.log;
113+
114+ client_max_body_size 5M;
115+
116+ location / {
117+ root /home/otherapp/app/static;
118+ index man.txt;
119+ try_files $uri @proxy;
120+ }
121+
122+ location @proxy {
123+ proxy_set_header Host $http_host;
124+ proxy_set_header X-Forwarded-Host $host;
125+ proxy_set_header X-Real-IP $remote_addr;
126+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
127+ proxy_pass http://unix:/var/run/otherapp/sock:;
128+ }
129+}
130+
131+server {
132+ listen 80;
133+ server_name other.example.com;
134+
135+ if ($host = other.example.com) {
136+ return 301 https://$host$request_uri;
137+ }
138+
139+ return 404;
140+}
tests/syntax-tests/source/nix/test.nixnew file+15
@@ -0,0 +1,15 @@
1+{ nixpkgs ? <nixpkgs>
2+, nixpkgs' ? import nixpkgs {}}: with nixpkgs';
3+
4+# some comment
5+stdenv.mkDerivation rec {
6+ pname = "test";
7+ version = "0.2.3";
8+ name = "${pname}-${version}";
9+
10+ buildInputs = [
11+ gzip
12+ bzip2
13+ python27
14+ ];
15+}
tests/syntax-tests/source/orgmode/test.orgnew file+38
@@ -0,0 +1,38 @@
1+* This is header
2+** sub header
3+*** sub sub header
4+**** sub sub sub header
5+
6+* Table representation
7+| Name | Age |
8+|---------+-----|
9+| Milli | 23 |
10+| Vanilli | 22 |
11+
12+* Spreadsheets
13+| n | n + 2 | n ^ 2 |
14+|---+-------+-------|
15+| 1 | 3 | 1 |
16+| 2 | 4 | 4 |
17+| 3 | 5 | 9 |
18+#+TBLFM: $2=$1+2::$3=$1*$1
19+
20+* Source Code
21+
22+#+BEGIN_SRC rust
23+ # recursive fibonacci
24+ fn fib(n: u32) -> u32 {
25+ match n {
26+ 0 | 1 => 1,
27+ _ => fib(n - 1) + fib(n - 2),
28+ }
29+ }
30+#+END_SRC
31+
32+* ToDo and Checkboxes Example
33+** DONE Write source example
34+** TODO Generate highlighted example [1/3]
35+ - [X] run update script
36+ - [-] get code review
37+ - [ ] merge into master
38+