tikzify 0.0.31 → 0.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -4
- package/src/common.ts +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tikzify",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.33",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": "./src/index.ts",
|
|
6
6
|
"files": [
|
|
@@ -13,12 +13,10 @@
|
|
|
13
13
|
"scripts": {},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@types/bun": "^1.3.6",
|
|
16
|
-
"@types/node": "^22.10.0"
|
|
17
|
-
"bun": "^1.3.6"
|
|
16
|
+
"@types/node": "^22.10.0"
|
|
18
17
|
},
|
|
19
18
|
"dependencies": {
|
|
20
19
|
"@types/sax": "^1.2.7",
|
|
21
|
-
"assert": "^2.1.0",
|
|
22
20
|
"p-queue": "^9.1.0",
|
|
23
21
|
"sax": "^1.4.4",
|
|
24
22
|
"zod": "^4.3.5"
|
package/src/common.ts
CHANGED
|
@@ -60,7 +60,7 @@ type Close = {
|
|
|
60
60
|
[t in types]: () => void
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
function hex(s: string | undefined): string | undefined {
|
|
64
64
|
if (!s) return
|
|
65
65
|
const res = s.replace('#', '')
|
|
66
66
|
assert([3, 6].includes(res.length), `Color ${s} is not valid hex`)
|
|
@@ -142,7 +142,7 @@ export function getColors(e: Element): (string | undefined)[] {
|
|
|
142
142
|
return [e.fill]
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
function fillStr(fill: string | undefined, colors: Record<string, number>) {
|
|
146
146
|
if (!fill) return ''
|
|
147
147
|
assert(fill in colors, `Color ${fill} not in ${Object.keys(colors)}`)
|
|
148
148
|
return `fill=c${colors[fill]}`
|
|
@@ -152,7 +152,7 @@ type To = {
|
|
|
152
152
|
[t in types]: (args: Extract<Element, { type: t }>, colors: Record<string, number>) => string
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
|
|
155
|
+
const toTikz: To = {
|
|
156
156
|
circle({ cx, cy, r, fill }, colors) {
|
|
157
157
|
return `\\fill[${fillStr(fill, colors)}] (${cx}, ${cy}) circle (${r});`
|
|
158
158
|
},
|