@zombie-mermaid/svg-renderer 2.2.6 → 3.1.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zombie-mermaid/svg-renderer",
3
- "version": "2.2.6",
3
+ "version": "3.1.0",
4
4
  "license": "MIT",
5
5
  "description": "SVG rendering primitives and the ELK-backed layout engine behind zombie-mermaid's SVG output.",
6
6
  "repository": {
@@ -36,7 +36,8 @@
36
36
  ],
37
37
  "dependencies": {
38
38
  "elkjs": "^0.11.0",
39
- "@zombie-mermaid/core": "2.2.6",
40
- "@zombie-mermaid/mermaid-parser": "2.2.6"
39
+ "entities": "^7.0.1",
40
+ "@zombie-mermaid/core": "3.1.0",
41
+ "@zombie-mermaid/mermaid-parser": "3.1.0"
41
42
  }
42
43
  }
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Smoke tests for `renderMermaidSVG` — the "Mermaid text in, SVG out" front
3
+ * door moved into this package under #1111, for parity with
4
+ * `@zombie-mermaid/ascii-renderer`'s `renderMermaidASCII`. The umbrella's own
5
+ * extensive `src/__tests__/*` suite already exercises this function
6
+ * end-to-end (through the re-export in `src/index.ts`), so this file only
7
+ * checks what's specific to *this* package: every registered diagram type
8
+ * dispatches to real SVG output through `./registry.ts`'s `diagramRegistry`
9
+ * when called directly from `@zombie-mermaid/svg-renderer`, not just via the
10
+ * umbrella.
11
+ */
12
+ import { describe, it, expect } from 'vitest'
13
+ import {
14
+ renderMermaidSVG,
15
+ renderMermaidSVGAsync,
16
+ renderMermaidSync,
17
+ renderMermaid,
18
+ themeCssVariables,
19
+ } from '@zombie-mermaid/svg-renderer'
20
+
21
+ describe('renderMermaidSVG', () => {
22
+ it.each([
23
+ ['flowchart', 'graph TD\n A --> B'],
24
+ ['state', 'stateDiagram-v2\n [*] --> A'],
25
+ ['sequence', 'sequenceDiagram\n A->>B: hi'],
26
+ ['class', 'classDiagram\n Animal <|-- Dog'],
27
+ ['er', 'erDiagram\n A ||--o{ B : has'],
28
+ ['xychart', 'xychart-beta\n line [1, 2, 3]'],
29
+ ])('renders a %s diagram to an SVG string', (_label, source) => {
30
+ const svg = renderMermaidSVG(source)
31
+ expect(svg).toContain('<svg')
32
+ expect(svg).toContain('</svg>')
33
+ })
34
+
35
+ it('embeds the original source when embedSource is set', () => {
36
+ const svg = renderMermaidSVG('graph TD\n A --> B', { embedSource: true })
37
+ expect(svg).toContain('data-src=')
38
+ })
39
+ })
40
+
41
+ describe('renderMermaidSVGAsync', () => {
42
+ it('resolves to the same output as the sync render', async () => {
43
+ const source = 'graph TD\n A --> B'
44
+ expect(await renderMermaidSVGAsync(source)).toBe(renderMermaidSVG(source))
45
+ })
46
+ })
47
+
48
+ describe('themeCssVariables', () => {
49
+ it('includes the resolved --bg/--fg custom properties', () => {
50
+ const css = themeCssVariables({ bg: '#111111', fg: '#eeeeee' })
51
+ expect(css).toContain('--bg:#111111')
52
+ expect(css).toContain('--fg:#eeeeee')
53
+ })
54
+ })
55
+
56
+ describe('deprecated aliases', () => {
57
+ it('renderMermaidSync matches renderMermaidSVG', () => {
58
+ expect(renderMermaidSync).toBe(renderMermaidSVG)
59
+ })
60
+
61
+ it('renderMermaid matches renderMermaidSVGAsync', () => {
62
+ expect(renderMermaid).toBe(renderMermaidSVGAsync)
63
+ })
64
+ })
@@ -16,6 +16,7 @@ import {
16
16
  escapeXml as escapeXmlUtil,
17
17
  escapeAttr,
18
18
  safeHref,
19
+ f,
19
20
  } from '@zombie-mermaid/core'
20
21
  import { withDataSrc } from '../renderer.ts'
21
22
  import {
@@ -230,20 +231,20 @@ function renderClassBox(
230
231
  // data-label: class name
231
232
  // data-annotation: stereotype (interface, abstract, etc.)
232
233
  const annotationAttr = cls.annotation
233
- ? ` data-annotation="${escapeAttr(cls.annotation)}"`
234
+ ? f` data-annotation="${escapeAttr(cls.annotation)}"`
234
235
  : ''
235
236
  // A style class from `cssClass`/`class A name`/`:::name` is emitted onto
236
237
  // the group so external CSS can target it, after the same allowlist the
237
238
  // flowchart renderer applies.
238
239
  const safeClassName = sanitizeClassName(cls.className)
239
240
  const groupAttrs = [
240
- `class="${safeClassName ? `class-node ${safeClassName}` : 'class-node'}"`,
241
- `data-id="${escapeAttr(cls.id)}"`,
242
- `data-label="${escapeAttr(cls.label)}"`,
241
+ f`class="${safeClassName ? f`class-node ${safeClassName}` : 'class-node'}"`,
242
+ f`data-id="${escapeAttr(cls.id)}"`,
243
+ f`data-label="${escapeAttr(cls.label)}"`,
243
244
  ]
244
245
  // `click ClassName call fn()` is parsed, never invoked, and never written
245
246
  // into the markup — see renderNode() in packages/svg-renderer/src/renderer.ts for the rationale.
246
- parts.push(`<g ${groupAttrs.join(' ')}${annotationAttr}>`)
247
+ parts.push(f`<g ${groupAttrs.join(' ')}${annotationAttr}>`)
247
248
 
248
249
  // An href becomes a real SVG link, which needs no script to work.
249
250
  // `interactivity: 'none'` strips it — a link is meaningless in
@@ -251,28 +252,28 @@ function renderClassBox(
251
252
  const href = linksEnabled ? safeHref(interaction?.href) : undefined
252
253
  if (href) {
253
254
  const targetAttr = interaction?.target
254
- ? ` target="${escapeAttr(interaction.target)}"`
255
+ ? f` target="${escapeAttr(interaction.target)}"`
255
256
  : ''
256
- parts.push(` <a href="${escapeAttr(href)}"${targetAttr}>`)
257
+ parts.push(f` <a href="${escapeAttr(href)}"${targetAttr}>`)
257
258
  }
258
259
 
259
260
  if (linksEnabled && interaction?.tooltip) {
260
261
  // <title> is SVG's native tooltip — no script, no CSS. Gated by
261
262
  // linksEnabled alongside href above: both come from the same `click`
262
263
  // statement, and 'none' strips both.
263
- parts.push(` <title>${escapeXml(interaction.tooltip)}</title>`)
264
+ parts.push(f` <title>${escapeXml(interaction.tooltip)}</title>`)
264
265
  }
265
266
 
266
267
  // Outer rectangle (full box)
267
268
  parts.push(
268
- ` <rect x="${x}" y="${y}" width="${width}" height="${height}" ` +
269
- `rx="0" ry="0" fill="${fill}" stroke="${stroke}" stroke-width="${strokeWidth}" />`,
269
+ f` <rect x="${x}" y="${y}" width="${width}" height="${height}" ` +
270
+ f`rx="0" ry="0" fill="${fill}" stroke="${stroke}" stroke-width="${strokeWidth}" />`,
270
271
  )
271
272
 
272
273
  // Header background
273
274
  parts.push(
274
- ` <rect x="${x}" y="${y}" width="${width}" height="${headerHeight}" ` +
275
- `rx="0" ry="0" fill="${headerFill}" stroke="${stroke}" stroke-width="${strokeWidth}" />`,
275
+ f` <rect x="${x}" y="${y}" width="${width}" height="${headerHeight}" ` +
276
+ f`rx="0" ry="0" fill="${headerFill}" stroke="${stroke}" stroke-width="${strokeWidth}" />`,
276
277
  )
277
278
 
278
279
  // Annotation (<<interface>>, <<abstract>>, etc.)
@@ -280,9 +281,9 @@ function renderClassBox(
280
281
  if (cls.annotation) {
281
282
  const annotY = y + 12
282
283
  parts.push(
283
- ` <text x="${x + width / 2}" y="${annotY}" text-anchor="middle" dy="${TEXT_BASELINE_SHIFT}" ` +
284
- `font-size="${CLS_FONT.annotationSize}" font-weight="${CLS_FONT.annotationWeight}" ` +
285
- `font-style="italic" fill="${textColor ?? 'var(--_text-muted)'}">&lt;&lt;${escapeXml(cls.annotation)}&gt;&gt;</text>`,
284
+ f` <text x="${x + width / 2}" y="${annotY}" text-anchor="middle" dy="${TEXT_BASELINE_SHIFT}" ` +
285
+ f`font-size="${CLS_FONT.annotationSize}" font-weight="${CLS_FONT.annotationWeight}" ` +
286
+ f`font-style="italic" fill="${textColor ?? 'var(--_text-muted)'}">&lt;&lt;${escapeXml(cls.annotation)}&gt;&gt;</text>`,
286
287
  )
287
288
  nameY = y + headerHeight / 2 + 6
288
289
  }
@@ -295,15 +296,15 @@ function renderClassBox(
295
296
  x + width / 2,
296
297
  nameY,
297
298
  fontSizes.nodeLabel,
298
- `text-anchor="middle" font-size="${fontSizes.nodeLabel}" font-weight="700" fill="${textColor ?? 'var(--_text)'}"`,
299
+ f`text-anchor="middle" font-size="${fontSizes.nodeLabel}" font-weight="700" fill="${textColor ?? 'var(--_text)'}"`,
299
300
  ),
300
301
  )
301
302
 
302
303
  // Divider line between header and attributes
303
304
  const attrTop = y + headerHeight
304
305
  parts.push(
305
- ` <line x1="${x}" y1="${attrTop}" x2="${x + width}" y2="${attrTop}" ` +
306
- `stroke="${stroke}" stroke-width="${STROKE_WIDTHS.innerBox}" />`,
306
+ f` <line x1="${x}" y1="${attrTop}" x2="${x + width}" y2="${attrTop}" ` +
307
+ f`stroke="${stroke}" stroke-width="${STROKE_WIDTHS.innerBox}" />`,
307
308
  )
308
309
 
309
310
  // Attributes
@@ -317,8 +318,8 @@ function renderClassBox(
317
318
  // Divider line between attributes and methods
318
319
  const methodTop = attrTop + attrHeight
319
320
  parts.push(
320
- ` <line x1="${x}" y1="${methodTop}" x2="${x + width}" y2="${methodTop}" ` +
321
- `stroke="${stroke}" stroke-width="${STROKE_WIDTHS.innerBox}" />`,
321
+ f` <line x1="${x}" y1="${methodTop}" x2="${x + width}" y2="${methodTop}" ` +
322
+ f`stroke="${stroke}" stroke-width="${STROKE_WIDTHS.innerBox}" />`,
322
323
  )
323
324
 
324
325
  // Methods
@@ -366,27 +367,27 @@ function renderMember(
366
367
 
367
368
  if (member.visibility) {
368
369
  spans.push(
369
- `<tspan fill="${faint}">${escapeXml(member.visibility)} </tspan>`,
370
+ f`<tspan fill="${faint}">${escapeXml(member.visibility)} </tspan>`,
370
371
  )
371
372
  }
372
373
 
373
374
  // Add parentheses for methods to distinguish from attributes, including parameters if present
374
375
  const displayName = member.isMethod
375
- ? `${member.name}(${member.params || ''})`
376
+ ? f`${member.name}(${member.params || ''})`
376
377
  : member.name
377
378
  // False positive: displayName is passed through escapeXml() (see packages/core/src/multiline-utils.ts),
378
379
  // which escapes &, <, >, ", ' before interpolation, so this is not raw/unescaped HTML.
379
- spans.push(`<tspan fill="${secondary}">${escapeXml(displayName)}</tspan>`) // nosemgrep: javascript.express.security.injection.raw-html-format.raw-html-format
380
+ spans.push(f`<tspan fill="${secondary}">${escapeXml(displayName)}</tspan>`) // nosemgrep: javascript.express.security.injection.raw-html-format.raw-html-format
380
381
 
381
382
  if (member.type) {
382
- spans.push(`<tspan fill="${faint}">: </tspan>`)
383
- spans.push(`<tspan fill="${muted}">${escapeXml(member.type)}</tspan>`)
383
+ spans.push(f`<tspan fill="${faint}">: </tspan>`)
384
+ spans.push(f`<tspan fill="${muted}">${escapeXml(member.type)}</tspan>`)
384
385
  }
385
386
 
386
387
  return (
387
- `<text x="${x}" y="${y}" class="mono" dy="${TEXT_BASELINE_SHIFT}" ` +
388
- `font-size="${CLS_FONT.memberSize}" font-weight="${CLS_FONT.memberWeight}"${fontStyle}${decoration}>` +
389
- `${spans.join('')}</text>`
388
+ f`<text x="${x}" y="${y}" class="mono" dy="${TEXT_BASELINE_SHIFT}" ` +
389
+ f`font-size="${CLS_FONT.memberSize}" font-weight="${CLS_FONT.memberWeight}"${fontStyle}${decoration}>` +
390
+ f`${spans.join('')}</text>`
390
391
  )
391
392
  }
392
393
 
@@ -408,33 +409,33 @@ function renderNote(note: PositionedClassNote, fontSizes: FontSizes): string {
408
409
  const { x, y, width: w, height: h } = note
409
410
  const forAttr =
410
411
  note.forClass !== undefined
411
- ? ` data-for="${escapeAttr(note.forClass)}"`
412
+ ? f` data-for="${escapeAttr(note.forClass)}"`
412
413
  : ''
413
414
 
414
415
  // Note body: (x,y) → (x+w-fold,y) → (x+w,y+fold) → (x+w,y+h) → (x,y+h)
415
416
  const bodyPoints = [
416
- `${x},${y}`,
417
- `${x + w - NOTE_FOLD},${y}`,
418
- `${x + w},${y + NOTE_FOLD}`,
419
- `${x + w},${y + h}`,
420
- `${x},${y + h}`,
417
+ f`${x},${y}`,
418
+ f`${x + w - NOTE_FOLD},${y}`,
419
+ f`${x + w},${y + NOTE_FOLD}`,
420
+ f`${x + w},${y + h}`,
421
+ f`${x},${y + h}`,
421
422
  ].join(' ')
422
423
  const foldPoints =
423
- `${x + w - NOTE_FOLD},${y} ${x + w},${y + NOTE_FOLD} ` +
424
- `${x + w - NOTE_FOLD},${y + NOTE_FOLD}`
424
+ f`${x + w - NOTE_FOLD},${y} ${x + w},${y + NOTE_FOLD} ` +
425
+ f`${x + w - NOTE_FOLD},${y + NOTE_FOLD}`
425
426
 
426
427
  return (
427
- `<g class="class-note"${forAttr}>` +
428
- `\n <polygon points="${bodyPoints}" ` +
429
- `fill="var(--bg)" stroke="var(--_node-stroke)" stroke-width="${STROKE_WIDTHS.innerBox}" />` +
430
- `\n <polygon points="${foldPoints}" ` +
431
- `fill="var(--_inner-stroke)" stroke="var(--_node-stroke)" stroke-width="${STROKE_WIDTHS.innerBox}" />` +
432
- `\n ${renderMultilineText(
428
+ f`<g class="class-note"${forAttr}>` +
429
+ f`\n <polygon points="${bodyPoints}" ` +
430
+ f`fill="var(--bg)" stroke="var(--_node-stroke)" stroke-width="${STROKE_WIDTHS.innerBox}" />` +
431
+ f`\n <polygon points="${foldPoints}" ` +
432
+ f`fill="var(--_inner-stroke)" stroke="var(--_node-stroke)" stroke-width="${STROKE_WIDTHS.innerBox}" />` +
433
+ f`\n ${renderMultilineText(
433
434
  note.text,
434
435
  x + w / 2,
435
436
  y + h / 2,
436
437
  fontSizes.edgeLabel,
437
- `font-size="${fontSizes.edgeLabel}" text-anchor="middle" font-weight="${FONT_WEIGHTS.edgeLabel}" fill="var(--_text-muted)"`,
438
+ f`font-size="${fontSizes.edgeLabel}" text-anchor="middle" font-weight="${FONT_WEIGHTS.edgeLabel}" fill="var(--_text-muted)"`,
438
439
  )}` +
439
440
  `\n</g>`
440
441
  )
@@ -446,14 +447,14 @@ function renderNote(note: PositionedClassNote, fontSizes: FontSizes): string {
446
447
  */
447
448
  function renderNoteLink(note: PositionedClassNote): string {
448
449
  if (!note.linkPoints || note.linkPoints.length < 2) return ''
449
- const pathData = note.linkPoints.map((p) => `${p.x},${p.y}`).join(' ')
450
+ const pathData = note.linkPoints.map((p) => f`${p.x},${p.y}`).join(' ')
450
451
  const forAttr =
451
452
  note.forClass !== undefined
452
- ? ` data-for="${escapeAttr(note.forClass)}"`
453
+ ? f` data-for="${escapeAttr(note.forClass)}"`
453
454
  : ''
454
455
  return (
455
- `<polyline class="class-note-link"${forAttr} points="${pathData}" ` +
456
- `fill="none" stroke="var(--_line)" stroke-width="${STROKE_WIDTHS.connector}" stroke-dasharray="2 3" />`
456
+ f`<polyline class="class-note-link"${forAttr} points="${pathData}" ` +
457
+ f`fill="none" stroke="var(--_line)" stroke-width="${STROKE_WIDTHS.connector}" stroke-dasharray="2 3" />`
457
458
  )
458
459
  }
459
460
 
@@ -468,7 +469,7 @@ function renderNoteLink(note: PositionedClassNote): string {
468
469
  function renderRelationship(rel: PositionedClassRelationship): string {
469
470
  if (rel.points.length < 2) return ''
470
471
 
471
- const pathData = rel.points.map((p) => `${p.x},${p.y}`).join(' ')
472
+ const pathData = rel.points.map((p) => f`${p.x},${p.y}`).join(' ')
472
473
  const isDashed = rel.type === 'dependency' || rel.type === 'realization'
473
474
  const dashArray = isDashed ? ' stroke-dasharray="6 4"' : ''
474
475
 
@@ -484,24 +485,26 @@ function renderRelationship(rel: PositionedClassRelationship): string {
484
485
  // - data-label: relationship label if present
485
486
  const dataAttrs = [
486
487
  'class="class-relationship"',
487
- `data-from="${escapeAttr(rel.from)}"`,
488
- `data-to="${escapeAttr(rel.to)}"`,
489
- `data-type="${rel.type}"`,
490
- `data-marker-at="${rel.markerAt}"`,
488
+ f`data-from="${escapeAttr(rel.from)}"`,
489
+ f`data-to="${escapeAttr(rel.to)}"`,
490
+ f`data-type="${rel.type}"`,
491
+ f`data-marker-at="${rel.markerAt}"`,
491
492
  ]
492
493
  if (rel.label) {
493
- dataAttrs.push(`data-label="${escapeAttr(rel.label)}"`)
494
+ dataAttrs.push(f`data-label="${escapeAttr(rel.label)}"`)
494
495
  }
495
496
  if (rel.fromCardinality) {
496
- dataAttrs.push(`data-from-cardinality="${escapeAttr(rel.fromCardinality)}"`)
497
+ dataAttrs.push(
498
+ f`data-from-cardinality="${escapeAttr(rel.fromCardinality)}"`,
499
+ )
497
500
  }
498
501
  if (rel.toCardinality) {
499
- dataAttrs.push(`data-to-cardinality="${escapeAttr(rel.toCardinality)}"`)
502
+ dataAttrs.push(f`data-to-cardinality="${escapeAttr(rel.toCardinality)}"`)
500
503
  }
501
504
 
502
505
  return (
503
- `<polyline ${dataAttrs.join(' ')} points="${pathData}" fill="none" stroke="var(--_line)" ` +
504
- `stroke-width="${STROKE_WIDTHS.connector}"${dashArray}${markers} />`
506
+ f`<polyline ${dataAttrs.join(' ')} points="${pathData}" fill="none" stroke="var(--_line)" ` +
507
+ f`stroke-width="${STROKE_WIDTHS.connector}"${dashArray}${markers} />`
505
508
  )
506
509
  }
507
510
 
@@ -519,9 +522,9 @@ function getRelationshipMarkers(
519
522
  if (!markerId) return ''
520
523
 
521
524
  if (markerAt === 'from') {
522
- return ` marker-start="url(#${markerId})"`
525
+ return f` marker-start="url(#${markerId})"`
523
526
  } else {
524
- return ` marker-end="url(#${markerId})"`
527
+ return f` marker-end="url(#${markerId})"`
525
528
  }
526
529
  }
527
530
 
@@ -562,7 +565,7 @@ function renderRelationshipLabels(
562
565
  pos.x,
563
566
  pos.y - 8,
564
567
  fontSizes.edgeLabel,
565
- `font-size="${fontSizes.edgeLabel}" text-anchor="middle" font-weight="${FONT_WEIGHTS.edgeLabel}" fill="var(--_text-muted)"`,
568
+ f`font-size="${fontSizes.edgeLabel}" text-anchor="middle" font-weight="${FONT_WEIGHTS.edgeLabel}" fill="var(--_text-muted)"`,
566
569
  ),
567
570
  )
568
571
  }
@@ -578,7 +581,7 @@ function renderRelationshipLabels(
578
581
  p.x + offset.x,
579
582
  p.y + offset.y,
580
583
  fontSizes.edgeLabel,
581
- `font-size="${fontSizes.edgeLabel}" text-anchor="middle" font-weight="${FONT_WEIGHTS.edgeLabel}" fill="var(--_text-muted)"`,
584
+ f`font-size="${fontSizes.edgeLabel}" text-anchor="middle" font-weight="${FONT_WEIGHTS.edgeLabel}" fill="var(--_text-muted)"`,
582
585
  ),
583
586
  )
584
587
  }
@@ -594,7 +597,7 @@ function renderRelationshipLabels(
594
597
  p.x + offset.x,
595
598
  p.y + offset.y,
596
599
  fontSizes.edgeLabel,
597
- `font-size="${fontSizes.edgeLabel}" text-anchor="middle" font-weight="${FONT_WEIGHTS.edgeLabel}" fill="var(--_text-muted)"`,
600
+ f`font-size="${fontSizes.edgeLabel}" text-anchor="middle" font-weight="${FONT_WEIGHTS.edgeLabel}" fill="var(--_text-muted)"`,
598
601
  ),
599
602
  )
600
603
  }
@@ -10,10 +10,11 @@
10
10
  // ============================================================================
11
11
 
12
12
  import type { Point, CurveStyle } from '@zombie-mermaid/core'
13
+ import { f } from '@zombie-mermaid/core'
13
14
 
14
15
  /** `M x y` for the first point. */
15
16
  function moveTo(p: Point): string {
16
- return `M ${p.x} ${p.y}`
17
+ return f`M ${p.x} ${p.y}`
17
18
  }
18
19
 
19
20
  /** Straight segments through every point — the historical default. */
@@ -22,7 +23,7 @@ function linearPath(points: Point[]): string {
22
23
  moveTo(points[0]!) +
23
24
  points
24
25
  .slice(1)
25
- .map((p) => ` L ${p.x} ${p.y}`)
26
+ .map((p) => f` L ${p.x} ${p.y}`)
26
27
  .join('')
27
28
  )
28
29
  }
@@ -51,14 +52,14 @@ function basisPath(points: Point[]): string {
51
52
 
52
53
  /** One B-spline segment across three successive control points. */
53
54
  const segment = (p0: Point, p1: Point, p2: Point): string =>
54
- ` C ${(2 * p0.x + p1.x) / 3} ${(2 * p0.y + p1.y) / 3},` +
55
- ` ${(p0.x + 2 * p1.x) / 3} ${(p0.y + 2 * p1.y) / 3},` +
56
- ` ${(p0.x + 4 * p1.x + p2.x) / 6} ${(p0.y + 4 * p1.y + p2.y) / 6}`
55
+ f` C ${(2 * p0.x + p1.x) / 3} ${(2 * p0.y + p1.y) / 3},` +
56
+ f` ${(p0.x + 2 * p1.x) / 3} ${(p0.y + 2 * p1.y) / 3},` +
57
+ f` ${(p0.x + 4 * p1.x + p2.x) / 6} ${(p0.y + 4 * p1.y + p2.y) / 6}`
57
58
 
58
59
  // Lead-in to the first knot, one sixth of the way along the opening leg.
59
60
  parts.push(
60
- ` L ${(5 * points[0]!.x + points[1]!.x) / 6}` +
61
- ` ${(5 * points[0]!.y + points[1]!.y) / 6}`,
61
+ f` L ${(5 * points[0]!.x + points[1]!.x) / 6}` +
62
+ f` ${(5 * points[0]!.y + points[1]!.y) / 6}`,
62
63
  )
63
64
 
64
65
  for (let i = 2; i < points.length; i++) {
@@ -67,7 +68,7 @@ function basisPath(points: Point[]): string {
67
68
 
68
69
  // d3 closes by feeding the last point twice, then drawing to it.
69
70
  parts.push(segment(points[points.length - 2]!, last, last))
70
- parts.push(` L ${last.x} ${last.y}`)
71
+ parts.push(f` L ${last.x} ${last.y}`)
71
72
 
72
73
  return parts.join('')
73
74
  }
@@ -109,7 +110,7 @@ function naturalPath(points: Point[]): string {
109
110
  // A zero-length leg means duplicated routed points; there is no corner
110
111
  // to round, so pass straight through.
111
112
  if (inLen === 0 || outLen === 0) {
112
- parts.push(` L ${corner.x} ${corner.y}`)
113
+ parts.push(f` L ${corner.x} ${corner.y}`)
113
114
  continue
114
115
  }
115
116
 
@@ -123,12 +124,12 @@ function naturalPath(points: Point[]): string {
123
124
  const endY = corner.y + ((next.y - corner.y) / outLen) * radius
124
125
 
125
126
  // Straight up to the fillet, then a quadratic through the corner.
126
- parts.push(` L ${startX} ${startY}`)
127
- parts.push(` Q ${corner.x} ${corner.y}, ${endX} ${endY}`)
127
+ parts.push(f` L ${startX} ${startY}`)
128
+ parts.push(f` Q ${corner.x} ${corner.y}, ${endX} ${endY}`)
128
129
  }
129
130
 
130
131
  const last = points[points.length - 1]!
131
- parts.push(` L ${last.x} ${last.y}`)
132
+ parts.push(f` L ${last.x} ${last.y}`)
132
133
 
133
134
  return parts.join('')
134
135
  }
@@ -155,17 +156,17 @@ function stepPath(points: Point[], where: 'mid' | 'before' | 'after'): string {
155
156
  const b = points[i + 1]!
156
157
 
157
158
  if (i === lastIndex - 1) {
158
- parts.push(` L ${b.x} ${b.y}`)
159
+ parts.push(f` L ${b.x} ${b.y}`)
159
160
  break
160
161
  }
161
162
 
162
163
  if (where === 'before') {
163
- parts.push(` L ${a.x} ${b.y} L ${b.x} ${b.y}`)
164
+ parts.push(f` L ${a.x} ${b.y} L ${b.x} ${b.y}`)
164
165
  } else if (where === 'after') {
165
- parts.push(` L ${b.x} ${a.y} L ${b.x} ${b.y}`)
166
+ parts.push(f` L ${b.x} ${a.y} L ${b.x} ${b.y}`)
166
167
  } else {
167
168
  const midY = (a.y + b.y) / 2
168
- parts.push(` L ${a.x} ${midY} L ${b.x} ${midY} L ${b.x} ${b.y}`)
169
+ parts.push(f` L ${a.x} ${midY} L ${b.x} ${midY} L ${b.x} ${b.y}`)
169
170
  }
170
171
  }
171
172