on master help sign in
Add Svelte as a syntax
commit072fb380d82df11e167d34b6a37dfe9fe1a2fb19 authorKyle Hubert <kjmph@users.noreply.github.com> dateThu 29 Oct 2020, 14:33 (6 years ago) parent8559495
6 files changed+133
.gitmodules+3 CHANGELOG.md+1 assets/syntaxes/02_Extra/Svelte+1 tests/syntax-tests/highlighted/Svelte/App.svelte+57 tests/syntax-tests/source/Svelte/App.svelte+57 tests/syntax-tests/source/Svelte/LICENSE+14
.gitmodules+3
@@ -197,6 +197,9 @@
197197[submodule "assets/syntaxes/02_Extra/Apache"]
198198 path = assets/syntaxes/02_Extra/Apache
199199 url = https://github.com/colinta/ApacheConf.tmLanguage
200+[submodule "assets/syntaxes/02_Extra/Svelte"]
201+ path = assets/syntaxes/02_Extra/Svelte
202+ url = https://github.com/corneliusio/svelte-sublime
200203[submodule "assets/themes/Coldark"]
201204 path = assets/themes/Coldark
202205 url = https://github.com/ArmandPhilippot/coldark-bat.git
CHANGELOG.md+1
@@ -13,6 +13,7 @@
1313## Syntaxes
1414
1515- Manpage syntax highlighting has been improved, see #1315 (@keith-hall)
16+- Add Svelte file syntax, see #1285 (@kjmph)
1617
1718## New themes
1819
assets/syntaxes/02_Extra/Sveltenew file+1

Submodule changed.

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/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.