- commit
- 618dec713a785d7f02c919bc1c683bf6750b0cd8
- parent
- 714fe738c6ab2eed7f0678375180eeb645af9760
- author
- Dami <dami.etoile@gmail.com>
| M | apps/ | 19 | +++++++++++++++++++ |
| M | shared/ | 14 | ++++++++++++-- |
@@ -179,6 +179,25 @@ test('applies D2, PlantUML, Svgbob, and neutral SVG family roles', () => {
179179 }180180 })181181 182+test('themes every Svgbob stroke without treating open curves as object surfaces', () => {183+ const canonical = canonicalizeSvg(184+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 20" class="svgbob"><path id="curve" d="M 8,2 A 8,8 0,0,0 8,18" class="nofill"></path><path id="closed" d="M20 2L30 2L30 18L20 18Z" class="nofill"></path><line id="plain" x1="2" y1="10" x2="6" y2="10"></line><rect id="box" x="32" y="2" width="6" height="16" class="solid nofill"></rect></svg>',185+ metadata, 'svgbob', 'svgbob@0.7.6/edge-wasm-1',186+ )187+188+ const curve = canonical.match(/<path id="curve"[^>]*>/)?.[0] ?? ''189+ const closed = canonical.match(/<path id="closed"[^>]*>/)?.[0] ?? ''190+ const plain = canonical.match(/<line id="plain"[^>]*>/)?.[0] ?? ''191+ const box = canonical.match(/<rect id="box"[^>]*>/)?.[0] ?? ''192+ assert.match(curve, /data-dz-stroke="line"/)193+ assert.doesNotMatch(curve, /data-dz-fill=/)194+ assert.match(closed, /data-dz-stroke="line"/)195+ assert.match(closed, /data-dz-fill="surface-1"/)196+ assert.match(plain, /data-dz-stroke="line"/)197+ assert.match(box, /data-dz-stroke="line"/)198+ assert.match(box, /data-dz-fill="surface-1"/)199+})200+182201 test('adapts neutral authored paint while preserving non-neutral paint and transparent support', () => {183202 const source = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"><rect width="10" height="10" fill="white"></rect><path d="M1 1L9 9" stroke="hotpink"></path><text x="2" y="6" fill="black">A</text></svg>'184203 const canonical = canonicalizeSvg(source, metadata, 'tikz', '@planktimerr/tikzjax@1.0.63/client-unit-1')@@ -506,8 +506,18 @@ function applySvgbobProfile(root) {
506506 const nextMarker = name === 'marker' ? node.attributes.get('id') ?? '' : marker507507 if (classes.has('backdrop')) node.attributes.set('data-dz-role', 'canvas')508508 if (TEXT_ELEMENTS.has(name)) node.attributes.set('data-dz-fill', 'ink')509- if (classes.has('solid')) node.attributes.set('data-dz-stroke', 'line')510- if (classes.has('nofill') || classes.has('bg_filled')) node.attributes.set('data-dz-fill', 'surface-1')509+ if (SHAPE_ELEMENTS.has(name)510+ && !classes.has('backdrop')511+ && node.attributes.get('data-dz-owned') !== 'normalizer') {512+ node.attributes.set('data-dz-stroke', 'line')513+ }514+ const closedPath = name === 'path' && /(?:z|Z)\s*$/.test(node.attributes.get('d') ?? '')515+ const objectSurface = classes.has('bg_filled')516+ || (classes.has('nofill') && (['circle', 'ellipse', 'polygon', 'rect'].includes(name) || closedPath))517+ if (objectSurface) node.attributes.set('data-dz-fill', 'surface-1')518+ else if (classes.has('nofill') && node.attributes.get('data-dz-fill') === 'surface-1') {519+ node.attributes.delete('data-dz-fill')520+ }511521 if (classes.has('filled') || ['arrow', 'diamond', 'circle'].includes(nextMarker)) node.attributes.set('data-dz-fill', 'line')512522 if (classes.has('filled') || classes.has('bg_filled') || nextMarker !== '') node.attributes.set('data-dz-stroke', 'line')513523 for (const child of node.children) visit(child, nextMarker)