From 072fb380d82df11e167d34b6a37dfe9fe1a2fb19 Mon Sep 17 00:00:00 2001 From: Kyle Hubert Date: Thu, 29 Oct 2020 14:33:09 -0400 Subject: [PATCH] Add Svelte as a syntax --- .gitmodules | 3 + CHANGELOG.md | 1 + assets/syntaxes/02_Extra/Svelte | 1 + .../highlighted/Svelte/App.svelte | 57 +++++++++++++++++++ tests/syntax-tests/source/Svelte/App.svelte | 57 +++++++++++++++++++ tests/syntax-tests/source/Svelte/LICENSE | 14 +++++ 6 files changed, 133 insertions(+) create mode 160000 assets/syntaxes/02_Extra/Svelte create mode 100644 tests/syntax-tests/highlighted/Svelte/App.svelte create mode 100644 tests/syntax-tests/source/Svelte/App.svelte create mode 100644 tests/syntax-tests/source/Svelte/LICENSE diff --git a/.gitmodules b/.gitmodules index 09ef55f3..e25256f1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -197,6 +197,9 @@ [submodule "assets/syntaxes/02_Extra/Apache"] path = assets/syntaxes/02_Extra/Apache url = https://github.com/colinta/ApacheConf.tmLanguage +[submodule "assets/syntaxes/02_Extra/Svelte"] + path = assets/syntaxes/02_Extra/Svelte + url = https://github.com/corneliusio/svelte-sublime [submodule "assets/themes/Coldark"] path = assets/themes/Coldark url = https://github.com/ArmandPhilippot/coldark-bat.git diff --git a/CHANGELOG.md b/CHANGELOG.md index f67e3bf8..f374dd3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ ## Syntaxes - Manpage syntax highlighting has been improved, see #1315 (@keith-hall) +- Add Svelte file syntax, see #1285 (@kjmph) ## New themes diff --git a/assets/syntaxes/02_Extra/Svelte b/assets/syntaxes/02_Extra/Svelte new file mode 160000 index 00000000..bf92f5b7 --- /dev/null +++ b/assets/syntaxes/02_Extra/Svelte @@ -0,0 +1 @@ +Subproject commit bf92f5b7b69c8ea641d6822fd6d12cc2d9341956 diff --git a/tests/syntax-tests/highlighted/Svelte/App.svelte b/tests/syntax-tests/highlighted/Svelte/App.svelte new file mode 100644 index 00000000..aff961d5 --- /dev/null +++ b/tests/syntax-tests/highlighted/Svelte/App.svelte @@ -0,0 +1,57 @@ +<script> + import { onMount } from 'svelte'; + import List from './List.svelte'; + import Item from './Item.svelte'; + + let item; + let page; + + async function hashchange() { + // the poor man's router! + const path = window.location.hash.slice(1); + + if (path.startsWith('/item')) { + const id = path.slice(6); + item = await fetch(`https://node-hnapi.herokuapp.com/item/${id}`).then(r => r.json()); + + window.scrollTo(0,0); + } else if (path.startsWith('/top')) { + page = +path.slice(5); + item = null; + } else { + window.location.hash = '/top/1'; + } + } + + onMount(hashchange); + + +<style> + main { + position: relative; + max-width: 800px; + margin: 0 auto; + min-height: 101vh; + padding: 1em; + } + + main :global(.meta) { + color: #999; + font-size: 12px; + margin: 0 0 1em 0; + } + + main :global(a) { + color: rgb(0,0,150); + } + + +<svelte:window on:hashchange={hashchange}/> + +<main> + {#if item} + <Item {item} returnTo="#/top/{page}"/> + {:else if page} + <List {page}/> + {/if} + diff --git a/tests/syntax-tests/source/Svelte/App.svelte b/tests/syntax-tests/source/Svelte/App.svelte new file mode 100644 index 00000000..0ede0a00 --- /dev/null +++ b/tests/syntax-tests/source/Svelte/App.svelte @@ -0,0 +1,57 @@ + + + + + + +
+ {#if item} + + {:else if page} + + {/if} +
diff --git a/tests/syntax-tests/source/Svelte/LICENSE b/tests/syntax-tests/source/Svelte/LICENSE new file mode 100644 index 00000000..91bf34d4 --- /dev/null +++ b/tests/syntax-tests/source/Svelte/LICENSE @@ -0,0 +1,14 @@ +The `App.svelte` file has been added from: + +https://github.com/sveltejs/svelte/blob/master/site/content/examples/21-miscellaneous/01-hacker-news/App.svelte + +Under the following license: + + +Copyright (c) 2016-20 [these people](https://github.com/sveltejs/svelte/graphs/contributors) + +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: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +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.