|
26 | 26 | }) |
27 | 27 |
|
28 | 28 | #let auto-frame(content) = compatibled-html(() => html.frame, () => content) |
29 | | -#let auto-figure(content) = compatibled-html( |
30 | | - () => html.figure, |
31 | | - () => align(center, content), // main.css: `figure { text-align: center; }` |
32 | | -) |
| 29 | +#let auto-figure(content) = with-target-check((export-target) => { |
| 30 | + if export-target == "html" { |
| 31 | + html.figure(content) // main.css: `figure { text-align: center; }` |
| 32 | + } else { |
| 33 | + align(center, content) |
| 34 | + } |
| 35 | +}) |
33 | 36 |
|
34 | 37 | #let html-font-size = 15.525pt |
35 | 38 |
|
|
368 | 371 | set par(spacing: 1.5em) |
369 | 372 | doc |
370 | 373 | } else { |
| 374 | + // show math.equation.where(block: false): it => { |
| 375 | + // with-target-check( |
| 376 | + // (export-target) => { |
| 377 | + // if export-target == "html" { |
| 378 | + // let label = repr(it) |
| 379 | + // if label in equations-height-dict.final().keys() { |
| 380 | + // let height = equations-height-dict.final().at(label, default: none) |
| 381 | + // equations-height-dict.update(d => { |
| 382 | + // d.insert(label, height); d |
| 383 | + // }) |
| 384 | + // let y-length = measure(bounded(it)).height |
| 385 | + // let shift = y-length - height |
| 386 | + // box(html.elem("span", attrs: (style: "vertical-align: -" + to-em(shift.pt()) + ";"), html.frame(bounded(it)))) |
| 387 | + // } else { |
| 388 | + // box(html.frame(add-pin(it))) |
| 389 | + // } |
| 390 | + // } else { |
| 391 | + // it |
| 392 | + // } |
| 393 | + // }, |
| 394 | + // ) |
| 395 | + // } |
| 396 | + // show math.equation.where(block: true): it => { |
| 397 | + // with-target-check( |
| 398 | + // (export-target) => { |
| 399 | + // if export-target == "html" { |
| 400 | + // if is-inside-pin.get() { |
| 401 | + // html.frame(it) |
| 402 | + // } else { |
| 403 | + // html.elem("div", attrs: (style: "display: flex; justify-content: center; width: 100%; margin: 1em 0;"), html.frame(it)) |
| 404 | + // } |
| 405 | + // } else { |
| 406 | + // it |
| 407 | + // } |
| 408 | + // }, |
| 409 | + // ) |
| 410 | + // } |
| 411 | + // |
371 | 412 | show math.equation.where(block: false): it => { |
372 | | - with-target-check( |
373 | | - (export-target) => { |
374 | | - if export-target == "html" { |
375 | | - let label = repr(it) |
376 | | - if label in equations-height-dict.final().keys() { |
377 | | - let height = equations-height-dict.final().at(label, default: none) |
378 | | - equations-height-dict.update(d => { |
379 | | - d.insert(label, height); d |
380 | | - }) |
381 | | - let y-length = measure(bounded(it)).height |
382 | | - let shift = y-length - height |
383 | | - box(html.elem("span", attrs: (style: "vertical-align: -" + to-em(shift.pt()) + ";"), html.frame(bounded(it)))) |
384 | | - } else { |
385 | | - box(html.frame(add-pin(it))) |
386 | | - } |
387 | | - } else { |
388 | | - it |
389 | | - } |
390 | | - }, |
391 | | - ) |
| 413 | + if target() == "html" { |
| 414 | + html.elem("span", attrs: (role: "math"), html.frame(it)) |
| 415 | + } else { |
| 416 | + it |
| 417 | + } |
392 | 418 | } |
393 | 419 | show math.equation.where(block: true): it => { |
394 | | - with-target-check( |
395 | | - (export-target) => { |
396 | | - if export-target == "html" { |
397 | | - if is-inside-pin.get() { |
398 | | - html.frame(it) |
399 | | - } else { |
400 | | - html.elem("div", attrs: (style: "display: flex; justify-content: center; width: 100%; margin: 1em 0;"), html.frame(it)) |
401 | | - } |
402 | | - } else { |
403 | | - it |
404 | | - } |
405 | | - }, |
406 | | - ) |
| 420 | + if target() == "html" { |
| 421 | + html.elem("figure", attrs: (role: "math"), html.frame(it)) |
| 422 | + } else { |
| 423 | + it |
| 424 | + } |
407 | 425 | } |
408 | 426 | doc |
409 | 427 | } |
|
0 commit comments