-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new hats and preprocessing script
- Loading branch information
Showing
14 changed files
with
89 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
### Installation | ||
|
||
```sh | ||
yarn install | ||
``` | ||
|
||
### Running tests | ||
|
||
```sh | ||
yarn run test | ||
``` | ||
|
||
### Adding tests | ||
|
||
See [test-case-recorder.md](docs/test-case-recorder.md). | ||
|
||
### Adding a new programming language | ||
|
||
See [docs](docs/adding-a-new-language.md). | ||
|
||
### Adding syntactic scope types to an existing language | ||
|
||
See [parse-tree-patterns.md](docs/parse-tree-patterns.md). | ||
|
||
### Changing SVGs | ||
|
||
You'll probably want to run the following to make sure the SVGs have everything they need: | ||
|
||
```sh | ||
yarn run compile && node ./out/scripts/preprocessSvgHats.js | ||
``` | ||
|
||
This script will add dummy width, height and fill attributes as necessary to appease the regex in `Decorations.ts` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import * as parser from "fast-xml-parser"; | ||
import { promises as fsp, read, readdirSync } from "fs"; | ||
import * as path from "path"; | ||
|
||
async function main() { | ||
const directory = path.join(__dirname, "../../images/hats"); | ||
|
||
const dumper = new parser.j2xParser({ | ||
ignoreAttributes: false, | ||
supressEmptyNode: true, | ||
}); | ||
|
||
readdirSync(directory, { withFileTypes: true }).forEach(async (dirent) => { | ||
const filePath = path.join(directory, dirent.name); | ||
const rawSvg = await fsp.readFile(filePath, { encoding: "utf8" }); | ||
const svgJson = parser.parse(rawSvg, { ignoreAttributes: false }); | ||
|
||
svgJson.svg["@_width"] = "0.7em"; | ||
svgJson.svg["@_height"] = "0.7em"; | ||
|
||
if ( | ||
rawSvg.match(/fill="[^"]+"/) == null && | ||
rawSvg.match(/fill:[^;]+;/) == null | ||
) { | ||
svgJson.svg["@_fill"] = "#123456"; | ||
} | ||
|
||
await fsp.writeFile(filePath, dumper.parse(svgJson)); | ||
}); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters