├── .github ├── FUNDING.yml └── workflows │ ├── ci.yml │ └── release.yml ├── .gitignore ├── .npmrc ├── .vscode └── settings.json ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── eslint.config.js ├── grammars └── uri.json ├── package.json ├── playground ├── README.md ├── index.html ├── package.json ├── src │ ├── App.vue │ ├── main.ts │ └── vite-env.d.ts └── vite.config.ts ├── pnpm-lock.yaml ├── pnpm-workspace.yaml ├── src └── index.ts ├── test ├── fixtures.test.ts ├── output │ └── url.html └── uris.txt └── tsconfig.json /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [antfu] 2 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | pull_request: 9 | branches: 10 | - main 11 | 12 | jobs: 13 | lint: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v3 17 | 18 | - name: Install pnpm 19 | uses: pnpm/action-setup@v2 20 | 21 | - name: Set node 22 | uses: actions/setup-node@v3 23 | with: 24 | node-version: lts/* 25 | 26 | - name: Setup 27 | run: npm i -g @antfu/ni 28 | 29 | - name: Install 30 | run: nci 31 | 32 | - name: Lint 33 | run: nr lint 34 | 35 | typecheck: 36 | runs-on: ubuntu-latest 37 | steps: 38 | - uses: actions/checkout@v3 39 | 40 | - name: Install pnpm 41 | uses: pnpm/action-setup@v2 42 | 43 | - name: Set node 44 | uses: actions/setup-node@v3 45 | with: 46 | node-version: lts/* 47 | 48 | - name: Setup 49 | run: npm i -g @antfu/ni 50 | 51 | - name: Install 52 | run: nci 53 | 54 | - name: Typecheck 55 | run: nr typecheck 56 | 57 | test: 58 | runs-on: ${{ matrix.os }} 59 | 60 | strategy: 61 | matrix: 62 | node: [lts/*] 63 | os: [ubuntu-latest, windows-latest, macos-latest] 64 | fail-fast: false 65 | 66 | steps: 67 | - uses: actions/checkout@v3 68 | 69 | - name: Install pnpm 70 | uses: pnpm/action-setup@v2 71 | 72 | - name: Set node ${{ matrix.node }} 73 | uses: actions/setup-node@v3 74 | with: 75 | node-version: ${{ matrix.node }} 76 | 77 | - name: Setup 78 | run: npm i -g @antfu/ni 79 | 80 | - name: Install 81 | run: nci 82 | 83 | - name: Build 84 | run: nr build 85 | 86 | - name: Test 87 | run: nr test 88 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | permissions: 4 | contents: write 5 | 6 | on: 7 | push: 8 | tags: 9 | - 'v*' 10 | 11 | jobs: 12 | release: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v3 16 | with: 17 | fetch-depth: 0 18 | 19 | - name: Install pnpm 20 | uses: pnpm/action-setup@v2 21 | 22 | - name: Set node 23 | uses: actions/setup-node@v3 24 | with: 25 | node-version: lts/* 26 | 27 | - run: npx changelogithub 28 | env: 29 | GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .cache 2 | .DS_Store 3 | .idea 4 | *.log 5 | *.tgz 6 | coverage 7 | dist 8 | lib-cov 9 | logs 10 | node_modules 11 | temp 12 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | ignore-workspace-root-check=true 2 | shell-emulator=true 3 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | // Auto generate metadata 3 | "emeraldwalk.runonsave": { 4 | "commands": [ 5 | { 6 | "match": "src/index.ts", 7 | "isAsync": true, 8 | "cmd": "npx tsx src/index.ts" 9 | } 10 | ] 11 | }, 12 | 13 | // Disable the default formatter, use eslint instead 14 | "prettier.enable": false, 15 | "editor.formatOnSave": false, 16 | 17 | // Auto fix 18 | "editor.codeActionsOnSave": { 19 | "source.fixAll": "explicit", 20 | "source.organizeImports": "never" 21 | }, 22 | 23 | // Silent the stylistic rules in you IDE, but still auto fix them 24 | "eslint.rules.customizations": [ 25 | { "rule": "style/*", "severity": "off" }, 26 | { "rule": "*-indent", "severity": "off" }, 27 | { "rule": "*-spacing", "severity": "off" }, 28 | { "rule": "*-spaces", "severity": "off" }, 29 | { "rule": "*-order", "severity": "off" }, 30 | { "rule": "*-dangle", "severity": "off" }, 31 | { "rule": "*-newline", "severity": "off" }, 32 | { "rule": "*quotes", "severity": "off" }, 33 | { "rule": "*semi", "severity": "off" } 34 | ], 35 | 36 | // Enable eslint for all supported languages 37 | "eslint.validate": [ 38 | "javascript", 39 | "javascriptreact", 40 | "typescript", 41 | "typescriptreact", 42 | "vue", 43 | "html", 44 | "markdown", 45 | "json", 46 | "jsonc", 47 | "yaml" 48 | ] 49 | } 50 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Please refer to https://github.com/antfu/contribute 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Anthony Fu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # textmate-grammar-uri 2 | 3 | [![npm version][npm-version-src]][npm-version-href] 4 | [![npm downloads][npm-downloads-src]][npm-downloads-href] 5 | [![bundle][bundle-src]][bundle-href] 6 | [![JSDocs][jsdocs-src]][jsdocs-href] 7 | [![License][license-src]][license-href] 8 | 9 | TextMate grammar for URI 10 | 11 | Screenshot 12 | 13 | ## Sponsors 14 | 15 |

16 | 17 | 18 | 19 |

20 | 21 | ## License 22 | 23 | [MIT](./LICENSE) License © 2023-PRESENT [Anthony Fu](https://github.com/antfu) 24 | 25 | 26 | 27 | [npm-version-src]: https://img.shields.io/npm/v/textmate-grammar-uri?style=flat&colorA=080f12&colorB=1fa669 28 | [npm-version-href]: https://npmjs.com/package/textmate-grammar-uri 29 | [npm-downloads-src]: https://img.shields.io/npm/dm/textmate-grammar-uri?style=flat&colorA=080f12&colorB=1fa669 30 | [npm-downloads-href]: https://npmjs.com/package/textmate-grammar-uri 31 | [bundle-src]: https://img.shields.io/bundlephobia/minzip/textmate-grammar-uri?style=flat&colorA=080f12&colorB=1fa669&label=minzip 32 | [bundle-href]: https://bundlephobia.com/result?p=textmate-grammar-uri 33 | [license-src]: https://img.shields.io/github/license/antfu/textmate-grammar-uri.svg?style=flat&colorA=080f12&colorB=1fa669 34 | [license-href]: https://github.com/antfu/textmate-grammar-uri/blob/main/LICENSE 35 | [jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669 36 | [jsdocs-href]: https://www.jsdocs.io/package/textmate-grammar-uri 37 | -------------------------------------------------------------------------------- /eslint.config.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | import antfu from '@antfu/eslint-config' 3 | 4 | export default antfu( 5 | { 6 | ignores: [ 7 | 'grammars/**', 8 | ], 9 | }, 10 | ) 11 | -------------------------------------------------------------------------------- /grammars/uri.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "uri", 3 | "patterns": [ 4 | { 5 | "include": "#root" 6 | } 7 | ], 8 | "repository": { 9 | "root": { 10 | "patterns": [ 11 | { 12 | "include": "#start" 13 | } 14 | ], 15 | "end": "\n" 16 | }, 17 | "start": { 18 | "patterns": [ 19 | { 20 | "include": "#datauri" 21 | }, 22 | { 23 | "include": "#mailto" 24 | }, 25 | { 26 | "include": "#windows-driver" 27 | }, 28 | { 29 | "include": "#double-slash" 30 | }, 31 | { 32 | "include": "#scheme" 33 | }, 34 | { 35 | "include": "#relative-path" 36 | }, 37 | { 38 | "include": "#path" 39 | } 40 | ] 41 | }, 42 | "path": { 43 | "patterns": [ 44 | { 45 | "include": "#encoded-char" 46 | }, 47 | { 48 | "include": "#separator" 49 | }, 50 | { 51 | "include": "#extension" 52 | }, 53 | { 54 | "include": "#query" 55 | }, 56 | { 57 | "include": "#fragment" 58 | } 59 | ] 60 | }, 61 | "windows-driver": { 62 | "match": "(^[a-zA-Z])(:\\\\)", 63 | "captures": { 64 | "1": { 65 | "name": "constant.language.uri.scheme" 66 | }, 67 | "2": { 68 | "name": "punctuation.separator.uri" 69 | } 70 | } 71 | }, 72 | "scheme": { 73 | "match": "(^[a-zA-Z][a-zA-Z0-9+.-]*)(:[/\\\\]*)([^/\\\\]*)", 74 | "captures": { 75 | "1": { 76 | "name": "constant.language.uri.scheme" 77 | }, 78 | "2": { 79 | "name": "punctuation.separator.uri" 80 | }, 81 | "3": { 82 | "patterns": [ 83 | { 84 | "include": "#host-user" 85 | }, 86 | { 87 | "include": "#hostname" 88 | }, 89 | { 90 | "include": "#port" 91 | } 92 | ] 93 | } 94 | } 95 | }, 96 | "double-slash": { 97 | "match": "^(:?//)([^/\\\\]*)", 98 | "captures": { 99 | "1": { 100 | "name": "punctuation.separator.uri" 101 | }, 102 | "2": { 103 | "patterns": [ 104 | { 105 | "include": "#host-user" 106 | }, 107 | { 108 | "include": "#hostname" 109 | }, 110 | { 111 | "include": "#port" 112 | } 113 | ] 114 | } 115 | } 116 | }, 117 | "relative-path": { 118 | "match": "^([.~#]+)", 119 | "captures": { 120 | "1": { 121 | "name": "constant.language.uri.scheme" 122 | } 123 | } 124 | }, 125 | "mailto": { 126 | "match": "^(mailto)(:)([^@]*)(@)?(.*)$", 127 | "captures": { 128 | "1": { 129 | "name": "constant.language.uri.scheme" 130 | }, 131 | "2": { 132 | "name": "punctuation.separator.uri" 133 | }, 134 | "3": {}, 135 | "4": { 136 | "name": "keyword.operator.uri.at" 137 | }, 138 | "5": { 139 | "name": "entity.name.uri.hostname" 140 | } 141 | } 142 | }, 143 | "host-user": { 144 | "match": "([^:@]+)(:)([^:@]+)(@)", 145 | "captures": { 146 | "1": { 147 | "name": "property.user.uri" 148 | }, 149 | "2": { 150 | "name": "punctuation.separator.uri" 151 | }, 152 | "3": { 153 | "name": "identifier.password.uri" 154 | }, 155 | "4": { 156 | "name": "keyword.operator.uri.at" 157 | } 158 | } 159 | }, 160 | "hostname": { 161 | "match": "([^:]+)", 162 | "name": "entity.name.uri.hostname" 163 | }, 164 | "port": { 165 | "match": "(:)([0-9]+)", 166 | "captures": { 167 | "1": { 168 | "name": "punctuation.separator.uri" 169 | }, 170 | "2": { 171 | "name": "number.uri.port" 172 | } 173 | } 174 | }, 175 | "separator": { 176 | "match": "[/\\\\]", 177 | "name": "punctuation.separator.uri" 178 | }, 179 | "encoded-char": { 180 | "match": "(%)([0-9a-fA-F]{2})", 181 | "captures": { 182 | "1": { 183 | "name": "punctuation.definition.string.begin.uri" 184 | }, 185 | "2": { 186 | "name": "constant.character.uri.encoded" 187 | } 188 | } 189 | }, 190 | "extension": { 191 | "match": "(\\.[a-zA-Z0-9]+)$", 192 | "name": "type.identifier.uri.extension" 193 | }, 194 | "datauri": { 195 | "match": "(^data)(:)([\\w/]+)([;,])(.*)$", 196 | "captures": { 197 | "1": { 198 | "name": "constant.language.uri.scheme" 199 | }, 200 | "2": { 201 | "name": "punctuation.separator.uri" 202 | }, 203 | "3": { 204 | "name": "keyword.operator.uri.mime" 205 | }, 206 | "4": { 207 | "name": "punctuation.separator.uri" 208 | }, 209 | "5": { 210 | "patterns": [ 211 | { 212 | "include": "#base64" 213 | }, 214 | { 215 | "include": "#path" 216 | } 217 | ] 218 | } 219 | } 220 | }, 221 | "base64": { 222 | "match": "(base64)(,)([A-Za-z0-9+/=]+)$", 223 | "captures": { 224 | "1": { 225 | "name": "constant.language.uri.scheme" 226 | }, 227 | "2": { 228 | "name": "punctuation.separator.uri" 229 | }, 230 | "3": { 231 | "name": "comment.uri.data" 232 | } 233 | } 234 | }, 235 | "query": { 236 | "match": "([?&])([^=]+)(=)([^&#]+)", 237 | "captures": { 238 | "1": { 239 | "name": "keyword.operator.uri.query" 240 | }, 241 | "2": { 242 | "name": "entity.name.uri.query.key" 243 | }, 244 | "3": { 245 | "name": "punctuation.separator.uri" 246 | }, 247 | "4": { 248 | "name": "string.value.uri.query.value" 249 | } 250 | } 251 | }, 252 | "fragment": { 253 | "match": "(#)(.*)$", 254 | "captures": { 255 | "1": { 256 | "name": "punctuation.separator.uri" 257 | }, 258 | "2": { 259 | "name": "comment.uri.fragment" 260 | } 261 | } 262 | } 263 | }, 264 | "scopeName": "text.uri" 265 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "textmate-grammar-uri", 3 | "type": "module", 4 | "version": "0.1.0", 5 | "packageManager": "pnpm@8.15.6", 6 | "description": "TextMate grammar for URI", 7 | "author": "Anthony Fu ", 8 | "license": "MIT", 9 | "funding": "https://github.com/sponsors/antfu", 10 | "homepage": "https://github.com/antfu/textmate-grammar-uri#readme", 11 | "repository": { 12 | "type": "git", 13 | "url": "git+https://github.com/antfu/textmate-grammar-uri.git" 14 | }, 15 | "bugs": "https://github.com/antfu/textmate-grammar-uri/issues", 16 | "keywords": [ 17 | "textmate-grammar" 18 | ], 19 | "sideEffects": false, 20 | "exports": { 21 | "./grammars/*": "./grammars/*" 22 | }, 23 | "files": [ 24 | "grammars" 25 | ], 26 | "scripts": { 27 | "build": "esno src/index.ts", 28 | "lint": "eslint .", 29 | "prepublishOnly": "nr build", 30 | "release": "bumpp && npm publish", 31 | "start": "esno src/index.ts", 32 | "play": "nr -C playground dev", 33 | "test": "vitest", 34 | "typecheck": "vue-tsc --noEmit", 35 | "prepare": "simple-git-hooks" 36 | }, 37 | "devDependencies": { 38 | "@antfu/eslint-config": "^2.13.2", 39 | "@antfu/ni": "^0.21.12", 40 | "@antfu/utils": "^0.7.7", 41 | "@types/node": "^20.12.6", 42 | "bumpp": "^9.4.0", 43 | "eslint": "^9.0.0", 44 | "esno": "^4.7.0", 45 | "lint-staged": "^15.2.2", 46 | "pnpm": "^8.15.6", 47 | "rimraf": "^5.0.5", 48 | "shiki": "^1.2.4", 49 | "simple-git-hooks": "^2.11.1", 50 | "tsx": "^4.17.0", 51 | "typescript": "^5.4.4", 52 | "unbuild": "^2.0.0", 53 | "vite": "^5.2.8", 54 | "vitest": "^1.4.0", 55 | "vue": "^3.4.21", 56 | "vue-tsc": "^2.0.6" 57 | }, 58 | "simple-git-hooks": { 59 | "pre-commit": "pnpm lint-staged" 60 | }, 61 | "lint-staged": { 62 | "*": "eslint --fix" 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /playground/README.md: -------------------------------------------------------------------------------- 1 | # Vue 3 + TypeScript + Vite 2 | 3 | This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 ` 12 | 13 | 14 | -------------------------------------------------------------------------------- /playground/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "playground", 3 | "type": "module", 4 | "version": "0.0.0", 5 | "private": true, 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "vue-tsc && vite build", 9 | "preview": "vite preview" 10 | }, 11 | "dependencies": { 12 | "vue": "^3.4.21" 13 | }, 14 | "devDependencies": { 15 | "@vitejs/plugin-vue": "^5.0.4", 16 | "shiki": "^1.2.4", 17 | "typescript": "^5.2.2", 18 | "vite": "^5.2.0", 19 | "vue-tsc": "^2.0.6" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /playground/src/App.vue: -------------------------------------------------------------------------------- 1 | 31 | 32 |